@@ -153,7 +153,7 @@ export async function setResponseFromFixture (getFixtureFn: GetFixtureFn, static
153
153
* @param backendRequest BackendRequest object.
154
154
* @param staticResponse BackendStaticResponse object.
155
155
*/
156
- export function sendStaticResponse ( backendRequest : Pick < InterceptedRequest , 'res' | 'onError' | 'onResponse' > , staticResponse : BackendStaticResponse ) {
156
+ export async function sendStaticResponse ( backendRequest : Pick < InterceptedRequest , 'res' | 'onError' | 'onResponse' > , staticResponse : BackendStaticResponse ) {
157
157
const { onError, onResponse } = backendRequest
158
158
159
159
if ( staticResponse . forceNetworkError ) {
@@ -173,12 +173,12 @@ export function sendStaticResponse (backendRequest: Pick<InterceptedRequest, 're
173
173
body,
174
174
} )
175
175
176
- const bodyStream = getBodyStream ( body , _ . pick ( staticResponse , 'throttleKbps' , 'delay' ) )
176
+ const bodyStream = await getBodyStream ( body , _ . pick ( staticResponse , 'throttleKbps' , 'delay' ) )
177
177
178
178
onResponse ! ( incomingRes , bodyStream )
179
179
}
180
180
181
- export function getBodyStream ( body : Buffer | string | Readable | undefined , options : { delay ?: number , throttleKbps ?: number } ) : Readable {
181
+ export async function getBodyStream ( body : Buffer | string | Readable | undefined , options : { delay ?: number , throttleKbps ?: number } ) : Promise < Readable > {
182
182
const { delay, throttleKbps } = options
183
183
const pt = new PassThrough ( )
184
184
@@ -203,11 +203,19 @@ export function getBodyStream (body: Buffer | string | Readable | undefined, opt
203
203
return writable . end ( )
204
204
}
205
205
206
- delay ? setTimeout ( sendBody , delay ) : sendBody ( )
206
+ delay ? await wait ( sendBody , delay ) : sendBody ( )
207
207
208
208
return pt
209
209
}
210
210
211
+ function wait ( fn , ms ) {
212
+ return new Promise ( ( resolve ) => {
213
+ setTimeout ( ( ) => {
214
+ resolve ( fn ( ) )
215
+ } , ms )
216
+ } )
217
+ }
218
+
211
219
export function mergeDeletedHeaders ( before : CyHttpMessages . BaseMessage , after : CyHttpMessages . BaseMessage ) {
212
220
for ( const k in before . headers ) {
213
221
// a header was deleted from `after` but was present in `before`, delete it in `before` too
4 commit comments
cypress-bot[bot] commentedon Jul 13, 2021
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
cypress-bot[bot] commentedon Jul 13, 2021
AppVeyor has built the
win32 ia32
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
cypress-bot[bot] commentedon Jul 13, 2021
AppVeyor has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
cypress-bot[bot] commentedon Jul 13, 2021
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: