Skip to content

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

Description

@paulmelnikow

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

  1. added 2 commits that reference this issue on May 1, 2019
    8730485
    51a74af
  2. added a commit that references this issue on May 2, 2019
    e4916bc
  3. nockbot commented on May 2, 2019

    @nockbot
    Collaborator

    🎉 This issue has been resolved in version 11.0.0-beta.11 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  4. nockbot commented on Aug 13, 2019

    @nockbot
    Collaborator

    🎉 This issue has been resolved in version 11.0.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  5. added 3 commits that reference this issue on Sep 4, 2019
    9a36792
    b93fdfa
    947bfa1
  6. added a commit that references this issue on Mar 21, 2026
    4020f77
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