diff --git a/src/rules/__tests__/no-large-snapshots.test.ts b/src/rules/__tests__/no-large-snapshots.test.ts index 4bb1e538c..d26ecdaab 100644 --- a/src/rules/__tests__/no-large-snapshots.test.ts +++ b/src/rules/__tests__/no-large-snapshots.test.ts @@ -217,6 +217,27 @@ ruleTester.run('no-large-snapshots', rule, { }, ], }, + { + // "should not report whitelisted large snapshots based on regexp" + filename: '/mock-component.jsx.snap', + code: [ + generateExportsSnapshotString(58, 'a big component w/ text'), + generateExportsSnapshotString(58, 'a big component 2'), + ].join('\n\n'), + options: [ + { + whitelistedSnapshots: { + '/mock-component.jsx.snap': ['a big component 2'], + }, + }, + ], + errors: [ + { + messageId: 'tooLongSnapshots', + data: { lineLimit: 50, lineCount: 58 }, + }, + ], + }, ], }); diff --git a/src/rules/no-large-snapshots.ts b/src/rules/no-large-snapshots.ts index ac4309b42..914e5bfba 100644 --- a/src/rules/no-large-snapshots.ts +++ b/src/rules/no-large-snapshots.ts @@ -58,7 +58,7 @@ const reportOnViolation = ( return name.test(snapshotName); } - return snapshotName; + return snapshotName === name; }); } }