Skip to content

Set resetMocks to true by default #9047

Closed as not planned
Closed as not planned
@EmmanuelDemey

Description

@EmmanuelDemey

🚀 Feature Proposal

As described in the thread https://twitter.com/kentcdodds/status/1182744387190607872, we should set resetMocks param to true by default.

Motivation

In order to make our tests isolated.

Example

thanks to this new default value, we won't have to define afterAll method in our unit tests, in order to reset something.

afterEach(() => {
  jest.clearAllMocks()
})

Pitch

This feature is part of the core project . https://jestjs.io/docs/en/configuration#resetmocks-boolean. This change will make de developer experience smoother when writing unit test with jest.
As writing isolated test is a good practice, we should make it easy to implement, without writing extra code.

Why does this feature belong in the Jest core platform?

Common feature proposals that do not typically make it to core:

  • New matchers (see jest-extended)
  • Changes to the default reporter (use custom reporters instead)
  • Changes to node/jsdom test environments (use custom environments instead)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions