cypress-autorecord
cypress-autorecord copied to clipboard
The upstream server is always contacted, even if a stubbed request is provided
Here is the code that sends the stubbed responses:
(req) => {
return req.reply((res) => {
const newResponse = sortedRoutes[method][url][index];
res.send(
newResponse.status,
newResponse.fixtureId
The docs of .reply() are:
/**
* Control the response to this request.
* If a function is passed, the request will be sent outgoing, and the function will be called
* with the response from the upstream server.
* If a `StaticResponse` is passed, it will be used as the response, and no request will be made
* to the upstream server.
*/
reply(interceptor?: StaticResponse | HttpResponseInterceptor): void
Since a function is provided, the actual request is made and then it's merged with the fixture. This ends up failing tests where the origin is no longer accessible, like in CI environments.