()
| 15 | }); |
| 16 | |
| 17 | const retrieveRecordedExpectations = async () => { |
| 18 | const promise = new Promise((resolve, reject) => { |
| 19 | mockServerClient(PROXY_HOST, PROXY_PORT) |
| 20 | .retrieveRecordedExpectations({}) |
| 21 | .then(resolve, reject); |
| 22 | }); |
| 23 | |
| 24 | let timeout; |
| 25 | const timeoutPromise = new Promise(resolve => { |
| 26 | timeout = setTimeout(() => { |
| 27 | console.warn('retrieveRecordedExpectations timeout'); |
| 28 | resolve([]); |
| 29 | }, 3000); |
| 30 | }); |
| 31 | |
| 32 | let recorded = await Promise.race([promise, timeoutPromise]); |
| 33 | clearTimeout(timeout); |
| 34 | |
| 35 | recorded = recorded.filter(({ httpRequest }) => { |
| 36 | const { Host = [] } = httpRequest.headers; |
| 37 | |
| 38 | // Host is an array of strings |
| 39 | return ( |
| 40 | Host.includes('api.github.com') || |
| 41 | (Host.includes('gitlab.com') && httpRequest.path.includes('api/v4')) || |
| 42 | Host.includes('api.bitbucket.org') || |
| 43 | (Host.includes('bitbucket.org') && httpRequest.path.includes('info/lfs')) || |
| 44 | Host.includes('api.media.atlassian.com') || |
| 45 | Host.some(host => host.includes('netlify.com')) || |
| 46 | Host.some(host => host.includes('netlify.app')) || |
| 47 | Host.some(host => host.includes('s3.amazonaws.com')) |
| 48 | ); |
| 49 | }); |
| 50 | |
| 51 | return recorded; |
| 52 | }; |
| 53 | |
| 54 | const resetMockServerState = async () => { |
| 55 | const promise = new Promise((resolve, reject) => { |
no test coverage detected