linuxdan
linuxdan

Reputation: 4864

How to never mock a particular module with jest?

In particular our codebase uses underscore in many places, and I never want to mock underscore. I know I can jest.unmock('underscore'); in each test that interacts with underscore. Is there a way to unmock underscore globally?

Upvotes: 0

Views: 247

Answers (1)

J. Mark Stevens
J. Mark Stevens

Reputation: 4945

You could add this to package.json.

"jest": {
    "scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
    "unmockedModulePathPatterns": [
      "enzyme",
      "react",
      "react-addons-test-utils"
    ],
    "verbose": true
  }

Upvotes: 1

Related Questions