Repository URL to install this package:
|
Version:
0.6.0 ▾
|
gateway-proxy
/
usr
/
share
/
gateway-proxy
/
app
/
node_modules
/
eslint-plugin-jest
/
docs
/
rules
/
no-interpolation-in-snapshots.md
|
|---|
no-interpolation-in-snapshots)💼 This rule is enabled in the following
configs:
all, recommended.
Prevents the use of string interpolations in snapshots.
Interpolation prevents snapshots from being updated. Instead, properties should be overloaded with a matcher by using property matchers.
Examples of incorrect code for this rule:
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:
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`, );
Don't use this rule on non-jest test files.