jest-dom icon indicating copy to clipboard operation
jest-dom copied to clipboard

Error in --experimental-vm-modules, when resolveStubModuleName(), jest-dom cause wrong from params

Open jaredhan418 opened this issue 2 years ago • 0 comments

  • @testing-library/jest-dom version: 6.1.3
  • node version: 18.17
  • jest (or vitest) version: 29.7.0
  • npm (or yarn) version: 10.0

Relevant code or config:

jest.unstable_mockModule("./xxxx-list/index.js", () => ({
  XXXXList: jest.fn(() => null),
}));

What you did:

Normal test case, crash when upgrade to 6.1.3

What happened:

截屏2023-09-20 18 25 39

Reproduction:

Create a test file with

jest.unstable_mockModule("./xxxx-list/index.js", () => ({
  XXXXList: jest.fn(() => null),
}));

Start jest with node --experimental-vm-modules node_modules/jest/bin/jest.js then jest will try to execute resolveStubModuleName(from, moduleName) at node_modules/jest-resolve/build/resolver.js

without jest-dom the function looks like below 截屏2023-09-20 18 13 09

after I import import "@testing-library/jest-dom/jest-globals"; in setup file.

the from param will become @testing-library/jest-dom/dist/jest-globals.mjs as screenshot below 截屏2023-09-20 18 11 51

Problem description:

Suggested solution:

jaredhan418 avatar Sep 20 '23 10:09 jaredhan418