Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
bakamitai456 committed Jun 15, 2023
1 parent 3037070 commit 5e58009
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion e2e/__tests__/toMatchNamedSnapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ test('first snapshot fails, second passes', () => {
const filename = 'first-snapshot-fails-second-passes.test.js';
const template = makeTemplate(`test('named snapshots', () => {
expect($1).toMatchNamedSnapshot('test-snapshot');
expect($2).toMatchNamedSnapshot('test-snapshot');
expect($2).toMatchNamedSnapshot('test-snapshot-2');
});`);

{
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-snapshot/src/__tests__/printSnapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ describe('pass false', () => {
actual: format(received),
count: 1,
expected: undefined,
key: 'specific-not-written-multi-line 1',
pass: false,
};
},
Expand Down Expand Up @@ -773,6 +774,7 @@ describe('pass false', () => {
actual: format(received),
count: 2,
expected: undefined,
key: 'specific-not-written-single-line 1',
pass: false,
};
},
Expand Down Expand Up @@ -860,6 +862,7 @@ describe('pass false', () => {
text: 'snapshot',
type,
}),
key: 'change text value 1',
pass: false,
};
},
Expand Down
5 changes: 3 additions & 2 deletions packages/jest-snapshot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,11 @@ const _toMatchSnapshot = (config: MatchSnapshotConfig) => {
});
const {actual, count, expected, key, pass} = result;

if (snapshotName && key == testNameToKey(fullTestName, 1)) {
if (snapshotName && key != testNameToKey(fullTestName, 1)) {
throw new Error(
'The specific snapshot name was duplicate with the other snapshot.\n\n' +
`Snapshot name: ${snapshotName}`,
`Snapshot name: ${fullTestName}\n` +
`Snapshot Key: ${key}`,
);
}

Expand Down

0 comments on commit 5e58009

Please sign in to comment.