Skip to content

Commit 622a08c

Browse files
authored
fix(no-large-snapshots): actually compare allowed name strings to name (#625)
1 parent b269e88 commit 622a08c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/rules/__tests__/no-large-snapshots.test.ts

+21
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,27 @@ ruleTester.run('no-large-snapshots', rule, {
217217
},
218218
],
219219
},
220+
{
221+
// "should not report whitelisted large snapshots based on regexp"
222+
filename: '/mock-component.jsx.snap',
223+
code: [
224+
generateExportsSnapshotString(58, 'a big component w/ text'),
225+
generateExportsSnapshotString(58, 'a big component 2'),
226+
].join('\n\n'),
227+
options: [
228+
{
229+
whitelistedSnapshots: {
230+
'/mock-component.jsx.snap': ['a big component 2'],
231+
},
232+
},
233+
],
234+
errors: [
235+
{
236+
messageId: 'tooLongSnapshots',
237+
data: { lineLimit: 50, lineCount: 58 },
238+
},
239+
],
240+
},
220241
],
221242
});
222243

src/rules/no-large-snapshots.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const reportOnViolation = (
5858
return name.test(snapshotName);
5959
}
6060

61-
return snapshotName;
61+
return snapshotName === name;
6262
});
6363
}
6464
}

0 commit comments

Comments
 (0)