Skip to content

The upstream server is always contacted, even if a stubbed request is provided #66

@Sam152

Description

@Sam152

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions