Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bd8de10
Add toMatchNamedSnapshot
bakamitai456 Mar 31, 2023
c5fe519
add to match named snapshot to expect
bakamitai456 Mar 31, 2023
35bbdeb
add test
bakamitai456 Mar 31, 2023
6841acf
add e2e testing
bakamitai456 Apr 3, 2023
7dfe361
add to throw error matching named snapshot with e2e
bakamitai456 Apr 4, 2023
b684d88
add unit test named snapshot
bakamitai456 Apr 4, 2023
9445a2f
add e2e toMatchNamedSnapshot with retries
bakamitai456 Apr 4, 2023
6fb5b85
add snapshot file
bakamitai456 Apr 5, 2023
f28f669
add types test
bakamitai456 Apr 5, 2023
14cf63d
add e2e concurrent testing
bakamitai456 Apr 5, 2023
ab462ea
add document
bakamitai456 Apr 7, 2023
c76bf56
fix lint
bakamitai456 Apr 9, 2023
c6ca50e
fixes changelog
bakamitai456 Apr 9, 2023
198fe2e
fixes code style
bakamitai456 Apr 10, 2023
79d3d7d
required snapshot name
bakamitai456 Apr 10, 2023
6b1a6ed
fixes properties
bakamitai456 Apr 10, 2023
735e503
edit e2e testing
bakamitai456 Apr 10, 2023
ed4e605
add e2e type test
bakamitai456 Apr 10, 2023
e3dc8fc
add more e2e type test
bakamitai456 Apr 10, 2023
7e7527a
remove unused overload
bakamitai456 Apr 10, 2023
cbbec0a
add validation on snapshot name
bakamitai456 Apr 10, 2023
77ae436
support array in properties matcher
bakamitai456 Apr 10, 2023
b7b81a1
remove unused function
bakamitai456 Apr 10, 2023
6327019
Apply suggestions from code review
bakamitai456 Apr 10, 2023
58acde3
remove fromPromise type
bakamitai456 Apr 11, 2023
23d8053
update tip on snapshot testing document
bakamitai456 Apr 16, 2023
78ddf16
Fixes alphabetic order
bakamitai456 Apr 16, 2023
435bdc8
Fixes docs
bakamitai456 Apr 16, 2023
9fccf7d
Update docs/SnapshotTesting.md
bakamitai456 Apr 16, 2023
3037070
Throw error when duplicate snapshot name
bakamitai456 Jun 14, 2023
5e58009
fix test
bakamitai456 Jun 15, 2023
acb42b0
fix the test
bakamitai456 Jun 16, 2023
f397e96
Merge branch 'main' into add-match-named-snapshot
SimenB Jun 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
bakamitai456 committed Jun 15, 2023
commit 5e5800958fd6bad1edb33110fe8b2050a7b67a76
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