Skip to content
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

Using jest.config.ts causes "ReferenceError: globalThis is not defined" #11217

Closed
TranquilMarmot opened this issue Mar 19, 2021 · 2 comments
Closed

Comments

@TranquilMarmot
Copy link

πŸ› Bug Report

If I use a jest.config.ts file to configure Jest as laid out in the Configuring Jest page, then when I run tests I get the following error:

  ● Test suite failed to run

    evalmachine.<anonymous>:1
    globalThis
    ^

    ReferenceError: globalThis is not defined

      at evalmachine.<anonymous>:1:1
      at setupWindow (node_modules/jsdom/lib/jsdom/browser/Window.js:111:55)
      at new Window (node_modules/jsdom/lib/jsdom/browser/Window.js:223:3)
      at exports.createWindow (node_modules/jsdom/lib/jsdom/browser/Window.js:95:10)
      at new JSDOM (node_modules/jsdom/lib/api.js:36:20)

Switching this to a jest.config.js file or moving the config into package.json fixes this.

I have ts-node version 9.1.1 installed in my package.json file.

I wonder if this is because I'm using asdf as my Node version manager and/or because I'm using Node 10.14.2.

envinfo

  System:
    OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
  Binaries:
    Node: 10.14.2 - ~/.asdf/installs/nodejs/10.14.2/bin/node
    npm: 6.13.6 - ~/.asdf/installs/nodejs/10.14.2/bin/npm
  npmPackages:
    jest: 26.6.3 => 26.6.3 
@SimenB
Copy link
Member

SimenB commented Mar 20, 2021

Vaguely related to jsdom/jsdom#2961 (comment).

And yes, it's triggered since you run with Node 10. Updating to Node 12 (or newer) should fix it.

Real fix is the stalled jsdom/jsdom#2975

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants