How to override Jest mock in setupTests

I added jest.mock('./Component') in setupTests.js because I don't want to do it in every test that has Component.

But now, when I want to test Component, it is mocked.

How can I override or reset it, in order to have the original Component?

I have tried so far:

and:

jest.mock('./index', () => ({
  Component: 'Component'
}));

Upvotes: 2

Views: 3996

Answers (1)

Andrea Carraro
Andrea Carraro

Reputation: 10489

jest.unmock(moduleName) should make the work but only when it's used before test's describe block.

Jest transpiles your tests in its very own way in order to make all the mocking/unmocking magic happen.

Upvotes: 5

Related Questions