New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow timing to be boolean, default to 'false' due to Pretender handling #1093
Comments
To get around this in the meantime (it gets passed through to Pretender just fine): server.timing = false as unknown as number; |
This should be fixed in https://github.com/miragejs/miragejs/releases/tag/v0.1.48, and |
@IanVS unfortunately |
It seems to me like you should not expect http requests, even mocked ones, to return synchronously, and it's very strange to me that a single tick of the event loop would take half a second, which is why I think something else must be going on. Out of curiosity, what timing do you get if you pass |
Passing 1 is similar; any value between 0 and 500 is about the same at around 500, and anything above that takes about as long as the timing |
In Pretender, a delay value of zero will still cause the request to be handled async with a setTimeout: https://github.com/pretenderjs/pretender/blob/65fbf0a608f2e4b4fd79657a77a41f52077074a9/src/pretender.ts#L259-L276
The timing parameter should be typed as
number | boolean
so that false can be passed for synchronous handling, and it's worth considering making the default 'false' during tests. I found that with the setTimeout, even with a value of 0, my responses were taking about 500ms to return, whereas with false the same measurement is about 50msThe text was updated successfully, but these errors were encountered: