Logo
  • DB
  • About
  • Updates
eslint-plugin-jest

ESLint rules for Jest

❯ npm i --save-dev eslint-plugin-jest
📖 README🐛 BugsGitHub LogoGitHubnpm Logonpmjest
🕵️‍♂️ Linter
  • 3 Configs
  • 52 Rules
  • 1 Processor
GitHub LogoGitHub
  • TypeScript
  • 1.1K Stars
  • 12 Watchers
npm Logonpm
  • 5.9M Wkly Downloads
  • +49% WoW
  • 27.6.1 320 kB
📋 Requirements
  • Node: ^14.15 || ^16.10 || >=18
  • @typescript-eslint...: ^5 || ^6
  • ESLint: ^7 || ^8
  • jest: *
ConfigurationRules
🌐 all51
recommended16 error • 3 warn
🎨 style3 error • 1 warn
RuleDescription🔧💡💭🗂️⚙️🌐🎨
consistent-test-it

Enforce test and it usage conventions

🔧📖⚙️🌐
expect-expect

Enforce assertion to be made in a test body

📖⚙️🌐⚠️
max-expects

Enforces a maximum number assertion calls in a test body

📖⚙️🌐
max-nested-describe

Enforces a maximum depth to nested describe calls

📖⚙️🌐
no-alias-methods

Disallow alias methods

🔧📖🌐⚠️
no-commented-out-tests

Disallow commented out tests

📖🌐⚠️
no-conditional-expect

Disallow calling expect conditionally

🌐
no-conditional-in-test

Disallow conditional logic in tests

🌐
no-deprecated-functions

Disallow use of deprecated functions

🔧📖🌐
no-disabled-tests

Disallow disabled tests

📖🌐⚠️
no-done-callback

Disallow using a callback in asynchronous tests and hooks

💡📖🌐
no-duplicate-hooks

Disallow duplicate setup and teardown hooks

📖🌐
no-export

Disallow using exports in files containing tests

📖🌐
no-focused-tests

Disallow focused tests

💡📖🌐
no-hooks

Disallow setup and teardown hooks

📖⚙️🌐
no-identical-title

Disallow identical titles

📖🌐
no-if

Disallow conditional logic

📖
no-interpolation-in-snapshots

Disallow string interpolation inside snapshots

🌐
no-jasmine-globals

Disallow Jasmine globals

🔧📖🌐
no-large-snapshots

Disallow large snapshots

📖⚙️🌐
no-mocks-import

Disallow manually importing from __mocks__

🌐
no-restricted-jest-methods

Disallow specific jest. methods

📖🌐
no-restricted-matchers

Disallow specific matchers & modifiers

📖🌐
no-standalone-expect

Disallow using expect outside of it or test blocks

📖⚙️🌐
no-test-prefixes

Require using .only and .skip over f and x

🔧📖🌐
no-test-return-statement

Disallow explicitly returning from tests

📖🌐
no-untyped-mock-factory

Disallow using jest.mock() factories without an explicit type parameter

🔧📖🌐
prefer-called-with

Suggest using toBeCalledWith() or toHaveBeenCalledWith()

📖🌐
prefer-comparison-matcher

Suggest using the built-in comparison matchers

🔧📖🌐
prefer-each

Prefer using .each rather than manual loops

📖🌐
prefer-equality-matcher

Suggest using the built-in equality matchers

💡📖🌐
prefer-expect-assertions

Suggest using expect.assertions() OR expect.hasAssertions()

💡📖⚙️🌐
prefer-expect-resolves

Prefer await expect(...).resolves over expect(await ...) syntax

🔧📖🌐
prefer-hooks-in-order

Prefer having hooks in a consistent order

📖🌐
prefer-hooks-on-top

Suggest having hooks before any test cases

📖🌐
prefer-lowercase-title

Enforce lowercase test names

🔧📖⚙️🌐
prefer-mock-promise-shorthand

Prefer mock resolved/rejected shorthands for promises

🔧📖🌐
prefer-snapshot-hint

Prefer including a hint with external snapshots

📖🌐
prefer-spy-on

Suggest using jest.spyOn()

🔧📖🌐
prefer-strict-equal

Suggest using toStrictEqual()

💡📖🌐
prefer-to-be

Suggest using toBe() for primitive literals

🔧📖🌐🎨
prefer-to-contain

Suggest using toContain()

🔧📖🌐🎨
prefer-to-have-length

Suggest using toHaveLength()

🔧📖🌐🎨
prefer-todo

Suggest using test.todo

🔧📏🌐
require-hook

Require setup and teardown code to be within a hook

📖⚙️🌐
require-to-throw-message

Require a message for toThrow()

📖🌐
require-top-level-describe

Require test cases and hooks to be inside a describe block

📖⚙️🌐
unbound-method

Enforce unbound methods are called with their expected scope

⚙️🌐
valid-describe-callback

Enforce valid describe() callback

🌐
valid-expect

Enforce valid expect() usage

📖⚙️🌐
valid-expect-in-promise

Require promises that have expectations in their chain to be valid

📖🌐
valid-title

Enforce valid titles

🔧📖⚙️🌐
© 2024 Lintbase