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.

Do not import `@jest/globals` outside of the Jest test environment

See original GitHub issue

Hello,

I have upgraded my project to jest 25.5.0 and I found that if I try to use jest-runner-groups I get:

Do not import `@jest/globals` outside of the Jest test environment

I think it was introduced with this change in jest: https://github.com/facebook/jest/commit/e21468da33a2f3c9c2b9af0dcfba14b002737f60

You can reproduce with this test using jest 25.5+:

jest.disableAutomock()

test('fml', () => {
  expect(true).toBeTruthy()
})

If I downgrade to jest 25.4.0 or disable jest-runner-groups the tests run as expected.

I have no idea what’s going on here to offer PR sorry.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rhysawilliams2010commented, Jun 1, 2020

Hi @eugene-manuilov thank you for checking this for me. I set up a minimal repo to try and repo the error, but I could not reproduce the error. I tried upgrading my original project again and everything works absolutely fine. I am very sorry to have wasted your time.

0reactions
eugene-manuilovcommented, Jul 28, 2020

@thinkjson can you create a test repo which reproduces the issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest failing to run tests when importing globals - Stack Overflow
I just found out what the problem was: I was importing the @jest/globals package in a helper file which isn't a test file....
Read more >
Do not import `@jest/globals` outside of the Jest test ... - GitHub
I have some tests that are testing against Typescript classes and modules, not Vue components, and I'm trying to use jest.mock() there and...
Read more >
Do not import `@jest/globals` outside of the Jest test ... - Reddit
Good afternoon guys, does someone know how to fix this error? Do not import @jest/globals outside of the Jest test environment. my file...
Read more >
Globals - Jest
In your test files, Jest puts each of these methods and objects into the global environment. You don't have to require or import...
Read more >
Do not import `@jest/globals` outside of the Jest test ...
Do not import `@jest/globals` outside of the Jest test environment ... One solution is to downgrade to babel-jest@24.9.0, not cool. Some more ...
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