Jest26 on Node10 fails with 'ReferenceError: globalThis is not defined' with V8 coverage provider
See original GitHub issueCurrent 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
collectCoverage: true,
cooverageProvider: "v8"
Run npm run test
Failure Logs
ng run jestee:test FAIL apps/jestee/src/app/app.component.spec.ts ● Test suite failed to run
evalmachine.<anonymous>:1
globalThis
^
ReferenceError: globalThis is not defined
at ../../evalmachine.<anonymous>:1:1
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
Issue Analytics
- State:
- Created 3 years ago
- Comments:21 (7 by maintainers)
@Lonli-Lokli here’s a solution:
yarn add jest-environment-jsdom-fifteen --dev
Then change your rootjest.config.js
to have this: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 😮
I switched to node 12.18.4 and everything was fine.