question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jest26 on Node10 fails with 'ReferenceError: globalThis is not defined' with V8 coverage provider

See original GitHub issue

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

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:closed
  • Created 3 years ago
  • Comments:21 (7 by maintainers)

github_iconTop GitHub Comments

12reactions
Cammisulicommented, Sep 25, 2020

@Lonli-Lokli here’s a solution: yarn add jest-environment-jsdom-fifteen --dev Then change your root jest.config.js to have this:

 testEnvironment: "jest-environment-jsdom-fifteen"

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 😮

1reaction
rbroencommented, Sep 22, 2020

I switched to node 12.18.4 and everything was fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: globalThis is not defined - npm - Stack Overflow
Consider updating your version of node.js to >=12 . globalThis was added in node.js v12.0.0 according to this compatibility table.
Read more >
globalThis is not defined although node version is v14.4.0
If you experience errors saying that globalThis is not defined, be sure to run a recent version ... But in node js i...
Read more >
'globalThis is not defined' in JSS Site - Rock, Paper, Sitecore
[NodeInvocationException: globalThis is not defined ReferenceError: globalThis is not defined at react.Component.react.Component.
Read more >
referenceerror: globalthis is not defined node js Code Example
Answers related to “referenceerror: globalthis is not defined node js” · error message is not defined · chartjs Uncaught ReferenceError: Utils is not...
Read more >
ReferenceError: globalThis is not defined - Ionic Framework
now i found a way to remote debugg it in chrome devtools, this is the error output: ReferenceError: globalThis is not defined at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found