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

ReferenceError: global is not defined #11525

Closed
cellebriteevi opened this issue Jun 4, 2021 · 9 comments
Closed

ReferenceError: global is not defined #11525

cellebriteevi opened this issue Jun 4, 2021 · 9 comments

Comments

@cellebriteevi
Copy link

I'm trying to run some tests here but i can't pass through the following error:

Test suite failed to run

    ReferenceError: global is not defined

      at Object.<anonymous> (node_modules/jest-cli/node_modules/expect/build/index.js:3:14)

and it refers to this line:

var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;

My jest.config.js is like this:

module.exports = {
  verbose: true,
  moduleNameMapper: {
    '\\.(css|less|scss|sass)$': 'identity-obj-proxy'
  },
  testEnvironment: 'jsdom',
  errorOnDeprecated: true,
  preset: 'ts-jest'
};

Am I missing something?

@Smrtnyk
Copy link

Smrtnyk commented Jun 4, 2021

@ahnpnl I am not sure if his config for ts-jest is correct here

@ahnpnl
Copy link
Contributor

ahnpnl commented Jun 4, 2021

The config is correct, this issue might be related to #10957

@SimenB
Copy link
Member

SimenB commented Jun 4, 2021

Please provide a full reproduction (and minimal, i.e. without ts-jest etc if possible)

@guoyunhe
Copy link

Same here. I also use ts-jest.

@SimenB
Copy link
Member

SimenB commented Jun 11, 2021

No reproduction has been provided. If anybody has the same problem, please open up a new issue and follow the issue template

@SimenB SimenB closed this as completed Jun 11, 2021
@guoyunhe
Copy link

I solved my issue and found the reason. I run npm list jest:

mypackage@1.0.0 /Users/guoyunhe/Git/mypackage
├─┬ @alib/build-scripts@0.1.31
│ └── jest@26.6.3 
└── jest@27.0.4

Here are two different jest major version installed. I removed @alib/build-scripts and then everything worked.

@drop
Copy link

drop commented Jun 30, 2021

Thanks! This worked! In my case this is was react-scripts package with wrong version of jest as dependency

@bernbecht
Copy link

@drop how did you solve? Did you have to remove react-scripts?

@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 Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants