-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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]: Enabling the code-coverage flag without babel installed produces a error #12925
Comments
I experienced this error suddenly migrating from [email protected] to [email protected]. the following test, which expects a Promise to reject with an instance of a custom Error
returns the error
when running All tests pass when running jest without the Setting I'm trying to write a minimal case repro but I'm having trouble reproducing it in a vanilla Node & Typescript project. |
- Fix jest config to address source map issue while running unit tests. - Had to lower the `functions` coverage, after moving from `babel` to `v8` for coverage checking. - If `v8` is not used in jest it falls back to use babel and needs three more dependencies to install: ``` npm install --save-dev babel-jest @babel/core @babel/preset-env ``` Source: https://stackoverflow.com/questions/72491664/jest-fails-coverage-reports-with-no-element-indexed/72500248#72500248 Issue: jestjs/jest#12925
Interestingly, |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Not stale |
Not stale, having the exact same issue. |
I faced a similar issue; in my case, I could fix the test case by removing |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This sounds like a duplicate of #12998 (comment) - can you update If it does not, please open up a new issue with a reproduction. |
I have the same error |
|
Hi @SimenB I think you're misunderstanding the issue. The fix in that pr is a fix in Babel. I'm saying I shouldn't need to install Babel to get this to work, or at least I'd expect jest to tell me that the problem can be fixed by installing Babel. My understanding is that jest should work correctly, including code coverage, using V8. So this does not fix the issue I'm afraid |
Then please open up a reproducing repo like the template asks you to. Your current steps don't. That said, it is listed as a dependency within Jest: https://github.com/facebook/jest/blob/c8452412fa0e0f56955a3975aec996d4ec5b6702/packages/jest-transform/package.json#L20 All your installation command in the OP does is update the versions The bug is in an older version of dependencies, not in Jest - so just update the versions in your lockfile. The bugged dependencies have been fixed so your steps to reproduce no longer do. |
I'll give it a go |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
28.1.0
Steps to reproduce
npx jest --collect-coverage
Expected behavior
Code coverage should work
Actual behavior
You receive the error:
Additional context
Installing babel
npm install --save-dev babel-jest @babel/core @babel/preset-env
fixes this issue.The default provider is
babel
for this source but this is not listed as a dependancy.It could be good enough to produce a more meaningful error message.
Environment
The text was updated successfully, but these errors were encountered: