DEV Community

Will Ceolin
Will Ceolin

Posted on • Edited on

4 1

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

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)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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


Follow me on Twitter

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay