0

When I add into my test-setup.js import "@testing-library/jest-dom"; Jest throws me this error when I run any test. If I remove the import everything works fine. Tried to add the import directly in test files, without success.

This is how test-setup.js looks like:

import '@testing-library/jest-dom';
import { server } from 'mocks/server';

beforeAll(() => server.listen());

afterEach(() => server.resetHandlers());

afterAll(() => server.close());

Error:

Cannot find module 'css' from 'node_modules/@testing-library/jest-dom/dist/utils.js'

Require stack:
 node_modules/@testing-library/jest-dom/dist/utils.js
 node_modules/@testing-library/jest-dom/dist/to-be-in-the-dom.js
 node_modules/@testing-library/jest-dom/dist/matchers.js
 node_modules/@testing-library/jest-dom/dist/extend-expect.js
 node_modules/@testing-library/jest-dom/extend-expect.js
 test-setup.js

at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:311:11)
at Object.<anonymous> (node_modules/@testing-library/jest-dom/dist/utils.js:22:12)
woaouh
  • 1
  • 1

1 Answers1

0

Try installing it separately

npm install -D jest-dom
# or yarn
yarn add --dev jest-dom
shaswat.dharaiya
  • 381
  • 4
  • 13