# no-interpolation-in-snapshots

Rule `vitest/no-interpolation-in-snapshots`. Disallow string interpolation in snapshots

- Source: vitest
- Technologies: Testing
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 5.9M weekly downloads of presets that enable it
- Trend: +61.5% last quarter
- Rank: #1396 by reach, #697 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `vitest/no-interpolation-in-snapshots` | yes | safe | package `@vitest/eslint-plugin` | [docs](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md) |
| Oxlint | `vitest/no-interpolation-in-snapshots` | no | no | plugin `vitest`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-interpolation-in-snapshots.html) |

## Code examples

### Incorrect: the rule reports this

```ts
expect('foo').toMatchSnapshot(`${bar}`)
expect('foo').toMatchSnapshot(`foo ${bar}`)
```

### Correct: the rule accepts this

```ts
expect('foo').toMatchSnapshot()
expect('foo').toMatchSnapshot('foo')
expect('foo').toMatchSnapshot(bar)
```

Examples from the ESLint documentation.

## Enable it

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

```js
import vitest from "@vitest/eslint-plugin";

export default [
  {
    plugins: { vitest },
    rules: {
      "vitest/no-interpolation-in-snapshots": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "vitest"
  ],
  "rules": {
    "vitest/no-interpolation-in-snapshots": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Vitest recommended](https://lintradar.dev/presets/vitest-recommended.md) | ESLint | `@vitest/eslint-plugin` | 17 | 5.9M | +61.5% |

## Related rules

- [jest/no-interpolation-in-snapshots](https://lintradar.dev/rules/jest/no-interpolation-in-snapshots.md): Disallow string interpolation inside snapshots
- [vitest/no-commented-out-tests](https://lintradar.dev/rules/vitest/no-commented-out-tests.md): Disallow commented out tests
- [vitest/no-mocks-import](https://lintradar.dev/rules/vitest/no-mocks-import.md): Disallow importing from __mocks__ directory
- [vitest/valid-title](https://lintradar.dev/rules/vitest/valid-title.md): Enforce valid titles
- [vitest/no-unneeded-async-expect-function](https://lintradar.dev/rules/vitest/no-unneeded-async-expect-function.md): Disallow unnecessary async function wrapper for expected promises
- [vitest/no-standalone-expect](https://lintradar.dev/rules/vitest/no-standalone-expect.md): Disallow using `expect` outside of `it` or `test` blocks

---

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