How can I import Jest?
The simplest solution for this is adding jest: true
to your env
configuration in ESLint, like so:
"env": {
"browser": true,
"node": true,
"jasmine": true,
"jest": true,
"es6": true
},
After I realized Jest is running in Node.js, it realized I could do this:
let { describe, it } = global;
It is not perfect, but one step closer... now I don't need to configure my linter with global variables any more.
Try the code below:
import {describe, expect, it } from '@jest/globals'
if you prefer explicit imports, you can do import {describe, expect, test} from '@jest/globals'.
Source https://jestjs.io/docs/en/api