Do not import `@jest/globals` outside of the Jest test environment
See original GitHub issueHello,
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:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@thinkjson can you create a test repo which reproduces the issue?