-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Failing to parse ESM files imported from node_modules
with a .js
extension
#2913
Comments
It seems like there is an issue when using Workaround is you do this
|
Is this the same bug I'm getting when including this library? The library consists of ts and js files and the test fails on the js files
The index.js file looks like this I've tried the above example on how to fix it but without any luck. This is my jest.config.ts
|
@richardsengers Have you tried different |
@briancodes yes I've tried a lot of different transform patterns. IN the end I've ended up with
This seems to work, but to be honest, I don't know why this works ans all the other options gave an error |
I bumped into this issue when attempting to update TypeScript from 5.5.4 to 5.7.3. I was able to bisect that the first TypeScript release that has this problem is 5.6.0-dev.20240801. |
This to me is crazy. I myself have applied fixes without understanding them. There must be a better way. |
Version
14.4.2
Steps to reproduce
Easy reproduction steps:
Clone repository, install deps, run tests
Manual Reproduction Steps:
1. Create a new Angular project with
@angular/cli v19.0.6
2. Install jest
3. Add Jest configuration to project root
4. Run tests (should run successfully)
npm exec jest
5. Introduce a basic ESM library, e.g. set-utilities
6. Use the library
7. Run tests (Should fail)
Expected behavior
Should be able to parse and transform ESM files with a
.js
extensionActual behavior
Jest fails to parse ESM files with a
.js
extension.Console Output:
Additional context
Manually changing the file names of the
set-utilities
library from.js
->.mjs
resolves the issue.Environment
The text was updated successfully, but these errors were encountered: