# prefer-importing-jest-globals

Rule `jest/prefer-importing-jest-globals`. Prefer importing Jest globals

- Source: jest
- Technologies: Testing
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1666 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `jest/prefer-importing-jest-globals` | no | safe | package `eslint-plugin-jest` | [docs](https://github.com/jest-community/eslint-plugin-jest/blob/v29.17.2/docs/rules/prefer-importing-jest-globals.md) |
| Oxlint | `jest/prefer-importing-jest-globals` | no | safe | plugin `jest`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/jest/prefer-importing-jest-globals.html) |
| Biome | `nursery/noTestGlobals` | no | unsafe | group nursery, since 2.6.9 | [docs](https://biomejs.dev/linter/rules/no-test-globals/) |

## Code examples

### Incorrect: the rule reports this

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

### Correct: the rule accepts this

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

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

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import jest from "eslint-plugin-jest";

export default [
  {
    plugins: { jest },
    rules: {
      "jest/prefer-importing-jest-globals": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "jest"
  ],
  "rules": {
    "jest/prefer-importing-jest-globals": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "noTestGlobals": "error"
      }
    }
  }
}
```

## Related rules

- [jest/prefer-hooks-on-top](https://lintradar.dev/rules/jest/prefer-hooks-on-top.md): Suggest having hooks before any test cases
- [jest/prefer-lowercase-title](https://lintradar.dev/rules/jest/prefer-lowercase-title.md): Enforce lowercase test names
- [jest/prefer-hooks-in-order](https://lintradar.dev/rules/jest/prefer-hooks-in-order.md): Prefer having hooks in a consistent order
- [jest/prefer-spy-on](https://lintradar.dev/rules/jest/prefer-spy-on.md): Suggest using `jest.spyOn()`
- [jest/prefer-equality-matcher](https://lintradar.dev/rules/jest/prefer-equality-matcher.md): Suggest using the built-in equality matchers
- [jest/prefer-strict-equal](https://lintradar.dev/rules/jest/prefer-strict-equal.md): Suggest using `toStrictEqual()`

---

Web page: https://lintradar.dev/rules/jest/prefer-importing-jest-globals. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
