Skip to content

Version 6.0.1 returns cannot find module #516

@tonskton

Description

@tonskton
  • @testing-library/jest-dom version: ^6.0.1
  • node version: v18.16.1
  • npm (or yarn) version: yarn 1.22.19

Relevant code or config:

// jest.config.js
import '@testing-library/jest-dom/extend-expect';

What you did:

Trying to run a test in next js

What happened: It returns an cannot find module error even though the library is in the package.json under dev dependencies

"Cannot find module '@testing-library/jest-dom/extend-expect' from 'jest.setup.js'"

Reproduction:

Problem description:

Tried to run npm test with next js but returns a cannot find module with jest-dom using the latest version(6.0.1).
If you try to hover then click the imported library vs code will typically route you the the file, but in this case it seems like vs code cant find the js-dome library.

  • @testing-library/jest-dom is already existing in package json dev dependency.
  • Already tried deleting node_modules and lock file but error still there.

I tried switching to older version like 5.6 and the error is gone.

Cannot proceed on running the test.

Suggested solution:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions