Error in --experimental-vm-modules, when resolveStubModuleName(), jest-dom cause wrong from params
jaredhan418 opened this issue · comments
@testing-library/jest-dom
version: 6.1.3node
version: 18.17jest
(orvitest
) version: 29.7.0npm
(oryarn
) 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](https://private-user-images.githubusercontent.com/11781874/269252418-262d1925-7847-47cf-b361-583ba7d35b3f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDI1MzcxNTMsIm5iZiI6MTcwMjUzNjg1MywicGF0aCI6Ii8xMTc4MTg3NC8yNjkyNTI0MTgtMjYyZDE5MjUtNzg0Ny00N2NmLWIzNjEtNTgzYmE3ZDM1YjNmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzEyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMjE0VDA2NTQxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ1ZmQ0NDA4ZDdjZDE5MDBlOWIyZWM5ODBjNjhiMmEyY2RjZTUzOTkyY2Y4ODU4MTg3OWY4OTk3MzVkMWEwMjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.QT8kBZbc-4yXbj-Qrgn5BbobiSm8pnYL3pp2QXaalOQ)
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
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