jest/no-interpolation-in-snapshots Style
What it does
Prevents the use of string interpolations in snapshots.
Why is this bad?
Interpolation prevents snapshots from being updated. Instead, properties should be overloaded with a matcher by using property matchers.
Example
javascript
expect(something).toMatchInlineSnapshot(
`Object {
property: ${interpolated}
}`,
);
expect(something).toMatchInlineSnapshot(
{ other: expect.any(Number) },
`Object {
other: Any<Number>,
property: ${interpolated}
}`,
);
expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot(`${interpolated}`);
How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny jest/no-interpolation-in-snapshots --jest-plugin
json
{
"plugins": ["jest"],
"rules": {
"jest/no-interpolation-in-snapshots": "error"
}
}