-
Notifications
You must be signed in to change notification settings - Fork 449
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]: config:init should create ESM version of jest.config.js when type = module #4012
Comments
PR is welcome :) |
It would have been nice to show how, for those of us who have this bug and are looking to fix it. |
You can either change the config's extension to or change module.exports = {
// config
} to ESM (any requires should also be changed to export default {
// same config
} |
Version
29.0.5
Steps to reproduce
"type": "module"
in itspackage.json
jest
,typescript
, andts-jest
config:init
script to generatejest.config.js
jest
Expected behavior
Jest reads the config file and runs normally if tests found.
Actual behavior
Jest can't read the config file because:
ReferenceError: module is not defined in ES module scope
Debug log
n/a
Additional context
It's not the biggest bug, and can easily be fixed manually, by changing the generated
jest.config.js
to ESM. But it would be nice if it just worked out of the box.It should be a simple fix in the
cli/config/init.ts
script, I can make a PR if it's okay.Environment
The text was updated successfully, but these errors were encountered: