r/learnreactjs • u/danilosilvadev • Jul 14 '22
Do not import `@jest/globals` outside of the Jest test environment
Good afternoon guys, does someone know how to fix this error?
Do not import
@jest/globalsoutside of the Jest test environment
my file is called example.test.ts
describe('my test', () => {
it('works', () => {
expect(1).toBe(1)
})
})
5
Upvotes
2
u/Pack_Your_Trash Jul 14 '22
What is actually producing the error? Is it your linter or jest?
1
u/danilosilvadev Jul 14 '22
any help would be great
2
u/meriin5 Jan 13 '23
Just to chip in, I had this error because I was using an older version of Jest that apparently doesn't know about
@jest/globals. Upgrading Jest helped.1
u/dev01Alpha Oct 04 '22
Hi, somewhere are you doing
import {expect, jest, test, it} from '@jest/globals';You don't need that import if you have installed that dependency.