> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-interpolation-in-snapshots

[Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0)
## Configuration

| Preset                           | Configured Value |
| -------------------------------- | ---------------- |
| ✅ jestPlugin.configs.all         | `"error"`        |
| ✅ jestPlugin.configs.recommended | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, jestPlugin } from '@rslint/core';

export default defineConfig([
  jestPlugin.configs.recommended,
  {
    rules: {
      'jest/no-interpolation-in-snapshots': 'error',
    },
  },
]);
```

## Rule Details

Disallow string interpolation inside inline snapshots. Interpolation prevents Jest from updating snapshots; instead, overload dynamic properties with a matcher via [property matchers](https://jestjs.io/docs/snapshot-testing#property-matchers).

Examples of **incorrect** code for this rule:

```javascript
expect(something).toMatchInlineSnapshot(
  `Object {
    property: ${interpolated}
  }`,
);

expect(something).toMatchInlineSnapshot(
  { other: expect.any(Number) },
  `Object {
    other: Any<Number>,
    property: ${interpolated}
  }`,
);

expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot(
  `${interpolated}`,
);
```

Examples of **correct** code for this rule:

```javascript
expect(something).toMatchInlineSnapshot();

expect(something).toMatchInlineSnapshot(
  `Object {
    property: 1
  }`,
);

expect(something).toMatchInlineSnapshot(
  { property: expect.any(Date) },
  `Object {
    property: Any<Date>
  }`,
);

expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot();

expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot(
  `Error Message`,
);
```

## Original Documentation

- [eslint-plugin-jest: no-interpolation-in-snapshots](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-interpolation-in-snapshots.md)
- [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-interpolation-in-snapshots.ts)
