Something went wrong while setting issue due date.
Cannot import a jest.mock() when running tests with --coverage
Closed
Cannot import a jest.mock() when running tests with --coverage
Created by: gaelollivier
Steps:
- Create a new app:
create-react-app my-app
- Create a new file that does a
jest.mock()
, ex:
src/mock.js
jest.mock('react-dom', () => {})
- Import this file in App.test.js:
src/App.test.js
import './mock.js'
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
...
- Run the tests with
--coverage
:
npm run test -- --coverage
I can't find a workaround for this, there's no documentation on how to import mocks so I can reuse them.
@cpojer It may be a Jest issue ? Am I doing something wrong ?