-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document and test dontThrow for custom inline snapshot matchers (#10995)
- Loading branch information
Showing
6 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
e2e/__tests__/__snapshots__/customInlineSnapshotMatchers.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
e2e/custom-inline-snapshot-matchers/__tests__/bail.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
const {toMatchInlineSnapshot} = require('jest-snapshot'); | ||
|
||
expect.extend({ | ||
toMatchStateInlineSnapshot(...args) { | ||
this.dontThrow = () => {}; | ||
return toMatchInlineSnapshot.call(this, ...args); | ||
}, | ||
}); | ||
|
||
let state = 'initial'; | ||
function transition() { | ||
// Typo in the implementation should cause the test to fail | ||
if (state === 'INITIAL') { | ||
state = 'pending'; | ||
} else if (state === 'pending') { | ||
state = 'done'; | ||
} | ||
} | ||
|
||
it('transitions as expected', () => { | ||
expect(state).toMatchStateInlineSnapshot(`"initial"`); | ||
transition(); | ||
// Already produces a mismatch. No point in continuing the test. | ||
expect(state).toMatchStateInlineSnapshot(`"loading"`); | ||
transition(); | ||
expect(state).toMatchStateInlineSnapshot(`"done"`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters