Open
Description
It would be really useful to have a lint rule that tells you when the path supplied to jest.mock
does not exist. I would envision the rule working like this:
Disallow mocking of module paths that do not exist
When using jest.mock
and jest.doMock
, the path supplied must be an module or local file that exists.
Rule details
This rule triggers an error if the path supplied to jest.mock
or jest.doMock
does not exist.
The following patterns are considered errors:
// Module that cannot be found
jest.mock('some-module-not-in-package-json');
// Local file that cannot be found
jest.mock('../../this/path/does/not/exist');
The following patterns not considered errors:
// Module that can be found
jest.mock('some-module-in-package-json');
// Local file that can be found
jest.mock('../../this/path/really/does/exist');