Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 1.03 KB

prefer-importing-jest-globals.md

File metadata and controls

44 lines (31 loc) · 1.03 KB

Prefer importing Jest globals (prefer-importing-jest-globals)

This rule aims to enforce explicit imports from @jest/globals.

  1. This is useful for ensuring that the Jest APIs are imported the same way in the codebase.
  2. When you can't modify Jest's injectGlobals configuration property, this rule can help to ensure that the Jest globals are imported explicitly and facilitate a migration to @jest/globals.

Rule details

Examples of incorrect code for this rule

/* eslint jest/prefer-importing-jest-globals: "error" */

describe('foo', () => {
  it('accepts this input', () => {
    // ...
  });
});

Examples of correct code for this rule

/* eslint jest/prefer-importing-jest-globals: "error" */

import { describe, it } from '@jest/globals';

describe('foo', () => {
  it('accepts this input', () => {
    // ...
  });
});

Further Reading