Skip to content

got() automatic retries makes for confusing failures in Nock tests #1523

Closed
@paulmelnikow

Description

As I mentioned at #1515 (comment), Got automatically retries failed requests twice.

That means if you have a test which mocks a 4xx or 5xx response, got will immediately reissue it.

At that point, the mock will have been consumed. The test will error out with Nock: No match for request.

Adding { retry: 0 } to the got calls will disable this behavior, and will make the tests behave less confusingly.

As I also mentioned in that thread:

While automatic retrying may be nice in certain cases, it is unsuited to testing. I am not convinced it is a good default.

We should use got.extend() to set defaults that turn off this behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions