question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow to override `resetMocks` and `resetModules` Jest configuration?

See original GitHub issue

I am wondering if you would be opened to allow overriding the resetMocks and resetModules options from Jest configuration? Currently, when trying to update them directly in the package.json such as:

{
  "jest": {
    "resetMocks": true
  }
}

I got a message telling me it is not configurable:

Out of the box, Create React App only supports overriding these Jest options:

  • collectCoverageFrom
  • coverageReporters
  • coverageThreshold
  • snapshotSerializers.

As an absent minded developer, I will always forget to restore a mock one day or another. And this parameter would save (the future) me a lot of time. Is there any particular reason to restrict these two options? Or is it just a lack waiting for a PR? 😃

Related Jest documentation: https://facebook.github.io/jest/docs/en/configuration.html#resetmocks-boolean

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
GAumalacommented, Sep 12, 2017

overriding resetMocks would be a really nice feature. I wish jest would let the user configure it via a command line argument, though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Jest
To read TypeScript configuration files Jest requires ts-node . ... resetMocks [boolean]; resetModules [boolean]; resolver [string] ...
Read more >
reactjs - How to make absolute import modules with ...
Out of the box, Create React App only supports overriding these Jest options: • clearMocks • collectCoverageFrom ...
Read more >
Running Tests | Create React App
Jest is a Node-based runner. This means that the tests always run in a Node environment and not in a real browser. This...
Read more >
Configuring package.json · Jest
Jest's configuration can be defined in the package.json file of your project or through ... preset [string]; resetMocks [boolean]; resetModules [boolean] ...
Read more >
How to automatically reset mocks and restore spies in Jest
fn(). To guard your codebase against the overriding a method by reassigning it with jest.fn( .. ) , you could configure ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found