-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Jest26 on Node10 fails with 'ReferenceError: globalThis is not defined' with V8 coverage provider #3776
Comments
I can confirm this with node 10.19.0. After running
|
Might be related to jsdom/jsdom#2795 (comment) |
I switched to node 12.18.4 and everything was fine. |
@rbroen unfortunately for my project Node10 is the only option right now. |
@Cammisuli do you think this is an issue with Jest? If that's the case, node 10 users can use an earlier version of Jest, right? |
I've created sample with pure angular, jest26 and jest-preset-angular and it works on node10. |
From the looks of it this is definitely something in jsdom. The fix they applied doesn't work :( @Lonli-Lokli there's probably a polyfill that's being added in the sample you have. Can you share it? |
@Cammisuli do you need sample with issue (with nrwl) or without (pure angular)? |
@Lonli-Lokli the one that's working please. |
@Cammisuli here is it https://github.com/Lonli-Lokli/jest-26 |
Thank you! It looks like it's related to something in Yup, it looks like |
@Lonli-Lokli here's a solution:
That should allow it to work better with Node 10. But we do really recommend that you update to the latest LTS as Node 10 will be EOL next year 😮 |
@Cammisuli I was going to use v8 coverage, introduced in jest26 with jest-envieonment-jsdom@16. So I believe your proposal will be like use Jest 26 without new enhancements. Pure angular allows to use it, why is it broken with nrwl? |
The v8
Using Jest v26 will still give you the same benefits, but the test environment will be different. You can also use puppeteer as a testEnvironment, right? As to why it doesn't work well with Nx, is because of the |
@Cammisuli agree with you now. |
Changing the Thank you! |
… 'ReferenceError: globalThis is not defined' on Node 10.x (nrwl/nx#3776 (comment))
Just FYI, Jest-runner (https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner) requires this setting to be added to every project and ignores root-level jest.config.js. |
You should be able to add any options into the root |
@Cammisuli it does not work when this option exists in latest (> 10.3) root config, I have to add it to the project configs. |
I had the same problem and as I am stuck with node version 10 for this project the only solution I found was to lock
I use yarn, npm probably does not support it, although you could use |
Solved to me |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
CodeCoverage on Node 10 fails when coverage provider is v8
Expected Behavior
It should work
Steps to Reproduce
Generate empty angular application with Nx and update jest.config.js
Run npm run test
Failure Logs
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.752 s
Ran all test suites.
Environment
Node 10
nx : Not Found
@nrwl/angular : 10.2.1
@nrwl/cli : 10.2.1
@nrwl/cypress : 10.2.1
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : Not Found
@nrwl/jest : 10.2.1
@nrwl/linter : Not Found
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 10.2.1
@nrwl/web : Not Found
@nrwl/workspace : 10.2.1
typescript : 3.9.7
The text was updated successfully, but these errors were encountered: