DEV Community

loading...

'spyOn' is not defined.eslint(no-undef)

Will Ceolin
Some of the things I care about: Education | Holacracy | Remote Work | Coding | Global citizen | Postcapitalism | Open source | Collaboration | Clean energy | Diversity | AI | UBI | Kindness.
・1 min read

When testing Typescript files, ESLint might complain about some Jest/Jasmine functions (e.g. describe, test, it, onSpy, etc.):

'describe' is not defined.eslint(no-undef)

That happens even after installing the @types/jest package.

ESLint needs you to specify which environments your script will run:

// .eslintrc.yml
env:
  - jasmine: true
  - jest: true

Now, Jasmine and Jest types will be set as global variables and your linting will work again. :)

Discussion (0)