# no-standalone-expect

Rule `jest/no-standalone-expect`. Disallow using `expect` outside of `it` or `test` blocks

- Source: jest
- Technologies: Testing
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 16.7M weekly downloads of presets that enable it
- Trend: +10.1% last quarter
- Rank: #657 by reach, #1464 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `jest/no-standalone-expect` | yes | no | package `eslint-plugin-jest` | [docs](https://github.com/jest-community/eslint-plugin-jest/blob/v29.17.2/docs/rules/no-standalone-expect.md) |
| Oxlint | `jest/no-standalone-expect` | no | no | plugin `jest`, category correctness | [docs](https://oxc.rs/docs/guide/usage/linter/rules/jest/no-standalone-expect.html) |
| Biome | `suspicious/noMisplacedAssertion` | no | no | group suspicious, since 1.8.0 | [docs](https://biomejs.dev/linter/rules/no-misplaced-assertion/) |

## Code examples

### Incorrect: the rule reports this

```js
// in describe
describe('a test', () => {
  expect(1).toBe(1);
});

// below other tests
describe('a test', () => {
  it('an it', () => {
    expect(1).toBe(1);
  });

  expect(1).toBe(1);
});
```

### Correct: the rule accepts this

```js
// in it block
describe('a test', () => {
  it('an it', () => {
    expect(1).toBe(1);
  });
});

// in helper function
describe('a test', () => {
  const helper = () => {
    expect(1).toBe(1);
  };

  it('an it', () => {
    helper();
  });
});

describe('a test', () => {
  beforeEach(() => {
    expect.hasAssertions();
  });
});
```

Examples from the ESLint documentation.

## Enable it

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

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

export default [
  {
    plugins: { jest },
    rules: {
      "jest/no-standalone-expect": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "jest"
  ],
  "rules": {
    "jest/no-standalone-expect": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "suspicious": {
        "noMisplacedAssertion": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Jest recommended](https://lintradar.dev/presets/jest-recommended.md) | ESLint | `eslint-plugin-jest` | 19 | 16.7M | +10.1% |

## Related rules

- [vitest/no-standalone-expect](https://lintradar.dev/rules/vitest/no-standalone-expect.md): Disallow using `expect` outside of `it` or `test` blocks
- [jest/no-jasmine-globals](https://lintradar.dev/rules/jest/no-jasmine-globals.md): Disallow Jasmine globals
- [jest/valid-title](https://lintradar.dev/rules/jest/valid-title.md): Enforce valid titles
- [jest/no-done-callback](https://lintradar.dev/rules/jest/no-done-callback.md): Disallow using a callback in asynchronous tests and hooks
- [jest/no-alias-methods](https://lintradar.dev/rules/jest/no-alias-methods.md): Disallow alias methods
- [jest/no-conditional-expect](https://lintradar.dev/rules/jest/no-conditional-expect.md): Disallow calling `expect` conditionally

---

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