From 622a08c86a37aa9490af20b488bd23246b8be752 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sun, 26 Jul 2020 17:39:54 +1200 Subject: [PATCH] fix(no-large-snapshots): actually compare allowed name strings to name (#625) --- .../__tests__/no-large-snapshots.test.ts | 21 +++++++++++++++++++ src/rules/no-large-snapshots.ts | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) 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; }); } }