Skip to content

Commit 23d8053

Browse files
committed
update tip on snapshot testing document
1 parent 58acde3 commit 23d8053

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/SnapshotTesting.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ More information on how snapshot testing works and why we built it can be found
5252

5353
:::
5454

55+
:::tip
56+
57+
The `toMatchSnapshot` matcher infers the name based on the test function context when the snapshot is evaluated. This can cause snapshots in tests that are run concurrently to have different names on each test run. If you want to guarantee consistent names, you can use the `toMatchNamedSnapshot` matcher.
58+
59+
:::
60+
5561
### Updating Snapshots
5662

5763
It's straightforward to spot when a snapshot test fails after a bug has been introduced. When that happens, go ahead and fix the issue and make sure your snapshot tests are passing again. Now, let's talk about the case when a snapshot test is failing due to an intentional implementation change.
@@ -264,10 +270,6 @@ Now, every time the snapshot test case runs, `Date.now()` will return `148236336
264270

265271
Always strive to use descriptive test and/or snapshot names for snapshots. The best names describe the expected snapshot content. This makes it easier for reviewers to verify the snapshots during review, and for anyone to know whether or not an outdated snapshot is the correct behavior before updating.
266272

267-
:::tip
268-
269-
The `toMatchSnapshot` matcher infers the name based on the test function context when the snapshot is evaluated. This can cause snapshots in tests that are run concurrently to have different names on each test run. If you want to guarantee consistent names, you can use the `toMatchNamedSnapshot` matcher.
270-
271273
:::
272274

273275
For example, compare:

0 commit comments

Comments
 (0)