Skip to content

Commit 3c65b72

Browse files
rickhanloniicpojer
authored andcommitted
Interactive Snapshot Mode improvements (#5864)
* Interactive Snapshot Mode updates * Update docs * Squash images * More squashing * Update snaps * Move arrow to a const * Add comment * Update GIF * Clarify cursorUp usage * Update snaps * Update CHANGELOG * Add AssertionLocation type
1 parent 2bd5dfd commit 3c65b72

12 files changed

+780
-137
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
([#5605](https://github.com/facebook/jest/pull/5605))
3434
* `[jest-cli]` Add `isSerial` property that runners can expose to specify that
3535
they can not run in parallel
36-
[#5706](https://github.com/facebook/jest/pull/5706)
36+
([#5706](https://github.com/facebook/jest/pull/5706))
37+
* `[jest-cli]` Interactive Snapshot Mode improvements
38+
([#5864](https://github.com/facebook/jest/pull/5864))
3739

3840
### Fixes
3941

docs/SnapshotTesting.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,18 @@ Failed snapshots can also be updated interactively in watch mode:
128128
![](/jest/img/content/interactiveSnapshot.png)
129129

130130
Once you enter Interactive Snapshot Mode, Jest will step you through the failed
131-
snapshots one test suite at a time and give you the opportunity to review the
132-
failed output.
131+
snapshots one test at a time and give you the opportunity to review the failed
132+
output.
133133

134134
From here you can choose to update that snapshot or skip to the next:
135135

136136
![](/jest/img/content/interactiveSnapshotUpdate.gif)
137137

138+
Once you're finished, Jest will give you a summary before returning back to
139+
watch mode:
140+
141+
![](/jest/img/content/interactiveSnapshotDone.png)
142+
138143
### Tests Should Be Deterministic
139144

140145
Your tests should be deterministic. That is, running the same tests multiple
Lines changed: 285 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,308 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`SnapshotInteractiveMode updateWithResults last test success, trigger end of interactive mode 1`] = `"TEST RESULTS CONTENTS"`;
3+
exports[`SnapshotInteractiveMode skip 1 test, then quit 1`] = `
4+
"[MOCK - cursorUp]
5+
[MOCK - eraseDown]
6+
7+
<bold>Interactive Snapshot Progress</>
8+
› <bold><dim>1 snapshot remaining<bold></>
9+
10+
<bold>Watch Usage</>
11+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
12+
<dim> › Press </>s<dim> to skip the current test.</>
13+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
14+
<dim> › Press </>Enter<dim> to trigger a test run.</>
15+
"
16+
`;
17+
18+
exports[`SnapshotInteractiveMode skip 1 test, then quit 2`] = `
19+
"[MOCK - eraseDown]
20+
21+
<bold>Interactive Snapshot Result</>
22+
› <bold><dim>1 snapshot reviewed<bold></>, <bold><yellow>1 snapshot skipped</></>
23+
24+
<bold>Watch Usage</>
25+
<dim> › Press </>r<dim> to restart Interactive Snapshot Mode.</>
26+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
27+
"
28+
`;
29+
30+
exports[`SnapshotInteractiveMode skip 1 test, then restart 1`] = `
31+
"[MOCK - cursorUp]
32+
[MOCK - eraseDown]
33+
34+
<bold>Interactive Snapshot Progress</>
35+
› <bold><dim>1 snapshot remaining<bold></>
36+
37+
<bold>Watch Usage</>
38+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
39+
<dim> › Press </>s<dim> to skip the current test.</>
40+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
41+
<dim> › Press </>Enter<dim> to trigger a test run.</>
42+
"
43+
`;
44+
45+
exports[`SnapshotInteractiveMode skip 1 test, then restart 2`] = `
46+
"[MOCK - eraseDown]
47+
48+
<bold>Interactive Snapshot Result</>
49+
› <bold><dim>1 snapshot reviewed<bold></>, <bold><yellow>1 snapshot skipped</></>
50+
51+
<bold>Watch Usage</>
52+
<dim> › Press </>r<dim> to restart Interactive Snapshot Mode.</>
53+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
54+
"
55+
`;
56+
57+
exports[`SnapshotInteractiveMode skip 1 test, then restart 3`] = `
58+
"[MOCK - cursorUp]
59+
[MOCK - eraseDown]
60+
61+
<bold>Interactive Snapshot Progress</>
62+
› <bold><dim>1 snapshot remaining<bold></>
63+
64+
<bold>Watch Usage</>
65+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
66+
<dim> › Press </>s<dim> to skip the current test.</>
67+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
68+
<dim> › Press </>Enter<dim> to trigger a test run.</>
69+
"
70+
`;
71+
72+
exports[`SnapshotInteractiveMode skip 1 test, update 1 test, then finish and restart 1`] = `
73+
"[MOCK - cursorUp]
74+
[MOCK - eraseDown]
75+
76+
<bold>Interactive Snapshot Progress</>
77+
› <bold><dim>2 snapshots remaining<bold></>
78+
79+
<bold>Watch Usage</>
80+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
81+
<dim> › Press </>s<dim> to skip the current test.</>
82+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
83+
<dim> › Press </>Enter<dim> to trigger a test run.</>
84+
"
85+
`;
86+
87+
exports[`SnapshotInteractiveMode skip 1 test, update 1 test, then finish and restart 2`] = `
88+
"[MOCK - cursorUp]
89+
[MOCK - eraseDown]
90+
91+
<bold>Interactive Snapshot Progress</>
92+
› <bold><dim>1 snapshot remaining<bold></>, <bold><yellow>1 snapshot skipped</></>
93+
94+
<bold>Watch Usage</>
95+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
96+
<dim> › Press </>s<dim> to skip the current test.</>
97+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
98+
<dim> › Press </>Enter<dim> to trigger a test run.</>
99+
"
100+
`;
101+
102+
exports[`SnapshotInteractiveMode skip 1 test, update 1 test, then finish and restart 3`] = `
103+
"[MOCK - eraseDown]
104+
105+
<bold>Interactive Snapshot Result</>
106+
› <bold><dim>2 snapshots reviewed<bold></>, <bold><green>1 snapshot updated</></>, <bold><yellow>1 snapshot skipped</></>
107+
108+
<bold>Watch Usage</>
109+
<dim> › Press </>r<dim> to restart Interactive Snapshot Mode.</>
110+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
111+
"
112+
`;
113+
114+
exports[`SnapshotInteractiveMode skip 1 test, update 1 test, then finish and restart 4`] = `
115+
"[MOCK - cursorUp]
116+
[MOCK - eraseDown]
117+
118+
<bold>Interactive Snapshot Progress</>
119+
› <bold><dim>1 snapshot remaining<bold></>
120+
121+
<bold>Watch Usage</>
122+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
123+
<dim> › Press </>s<dim> to skip the current test.</>
124+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
125+
<dim> › Press </>Enter<dim> to trigger a test run.</>
126+
"
127+
`;
128+
129+
exports[`SnapshotInteractiveMode skip 2 tests, then finish and restart 1`] = `
130+
"[MOCK - cursorUp]
131+
[MOCK - eraseDown]
132+
133+
<bold>Interactive Snapshot Progress</>
134+
› <bold><dim>2 snapshots remaining<bold></>
135+
136+
<bold>Watch Usage</>
137+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
138+
<dim> › Press </>s<dim> to skip the current test.</>
139+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
140+
<dim> › Press </>Enter<dim> to trigger a test run.</>
141+
"
142+
`;
143+
144+
exports[`SnapshotInteractiveMode skip 2 tests, then finish and restart 2`] = `
145+
"[MOCK - cursorUp]
146+
[MOCK - eraseDown]
147+
148+
<bold>Interactive Snapshot Progress</>
149+
› <bold><dim>1 snapshot remaining<bold></>, <bold><yellow>1 snapshot skipped</></>
150+
151+
<bold>Watch Usage</>
152+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
153+
<dim> › Press </>s<dim> to skip the current test.</>
154+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
155+
<dim> › Press </>Enter<dim> to trigger a test run.</>
156+
"
157+
`;
158+
159+
exports[`SnapshotInteractiveMode skip 2 tests, then finish and restart 3`] = `
160+
"[MOCK - eraseDown]
161+
162+
<bold>Interactive Snapshot Result</>
163+
› <bold><dim>2 snapshots reviewed<bold></>, <bold><yellow>2 snapshots skipped</></>
4164

5-
exports[`SnapshotInteractiveMode updateWithResults overlay handle progress UI 1`] = `
6-
"TEST RESULTS CONTENTS
7-
[MOCK - cursorUp]
165+
<bold>Watch Usage</>
166+
<dim> › Press </>r<dim> to restart Interactive Snapshot Mode.</>
167+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
168+
"
169+
`;
170+
171+
exports[`SnapshotInteractiveMode skip 2 tests, then finish and restart 4`] = `
172+
"[MOCK - cursorUp]
8173
[MOCK - eraseDown]
9174

10175
<bold>Interactive Snapshot Progress</>
11-
› <bold><red>2 suites failed</></>, <bold><green>1 suite passed</></>
176+
› <bold><dim>2 snapshots remaining<bold></>
12177

13178
<bold>Watch Usage</>
14179
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
15-
<dim> › Press </>s<dim> to skip the current test suite.</>
16-
<dim> › Press </>q<dim> to quit Interactive Snapshot Update Mode.</>
180+
<dim> › Press </>s<dim> to skip the current test.</>
181+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
17182
<dim> › Press </>Enter<dim> to trigger a test run.</>
18183
"
19184
`;
20185

21-
exports[`SnapshotInteractiveMode updateWithResults with a test failure simply update UI 1`] = `
22-
"TEST RESULTS CONTENTS
23-
[MOCK - cursorUp]
186+
exports[`SnapshotInteractiveMode update 1 test, skip 1 test, then finish and restart 1`] = `
187+
"[MOCK - cursorUp]
24188
[MOCK - eraseDown]
25189

26190
<bold>Interactive Snapshot Progress</>
27-
› <bold><red>1 suite failed</></>
191+
› <bold><dim>2 snapshots remaining<bold></>
28192

29193
<bold>Watch Usage</>
30194
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
31-
<dim> › Press </>q<dim> to quit Interactive Snapshot Update Mode.</>
195+
<dim> › Press </>s<dim> to skip the current test.</>
196+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
32197
<dim> › Press </>Enter<dim> to trigger a test run.</>
33198
"
34199
`;
35200

36-
exports[`SnapshotInteractiveMode updateWithResults with a test success, call the next test 1`] = `"TEST RESULTS CONTENTS"`;
201+
exports[`SnapshotInteractiveMode update 1 test, skip 1 test, then finish and restart 2`] = `
202+
"[MOCK - cursorUp]
203+
[MOCK - eraseDown]
204+
205+
<bold>Interactive Snapshot Progress</>
206+
› <bold><dim>1 snapshot remaining<bold></>, <bold><green>1 snapshot updated</></>
207+
208+
<bold>Watch Usage</>
209+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
210+
<dim> › Press </>s<dim> to skip the current test.</>
211+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
212+
<dim> › Press </>Enter<dim> to trigger a test run.</>
213+
"
214+
`;
215+
216+
exports[`SnapshotInteractiveMode update 1 test, skip 1 test, then finish and restart 3`] = `
217+
"[MOCK - eraseDown]
218+
219+
<bold>Interactive Snapshot Result</>
220+
› <bold><dim>2 snapshots reviewed<bold></>, <bold><green>1 snapshot updated</></>, <bold><yellow>1 snapshot skipped</></>
221+
222+
<bold>Watch Usage</>
223+
<dim> › Press </>r<dim> to restart Interactive Snapshot Mode.</>
224+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
225+
"
226+
`;
227+
228+
exports[`SnapshotInteractiveMode update 1 test, skip 1 test, then finish and restart 4`] = `
229+
"[MOCK - cursorUp]
230+
[MOCK - eraseDown]
231+
232+
<bold>Interactive Snapshot Progress</>
233+
› <bold><dim>1 snapshot remaining<bold></>
234+
235+
<bold>Watch Usage</>
236+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
237+
<dim> › Press </>s<dim> to skip the current test.</>
238+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
239+
<dim> › Press </>Enter<dim> to trigger a test run.</>
240+
"
241+
`;
242+
243+
exports[`SnapshotInteractiveMode update 1 test, then finish and return 1`] = `
244+
"[MOCK - cursorUp]
245+
[MOCK - eraseDown]
246+
247+
<bold>Interactive Snapshot Progress</>
248+
› <bold><dim>1 snapshot remaining<bold></>
249+
250+
<bold>Watch Usage</>
251+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
252+
<dim> › Press </>s<dim> to skip the current test.</>
253+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
254+
<dim> › Press </>Enter<dim> to trigger a test run.</>
255+
"
256+
`;
257+
258+
exports[`SnapshotInteractiveMode update 1 test, then finish and return 2`] = `
259+
"[MOCK - eraseDown]
260+
261+
<bold>Interactive Snapshot Result</>
262+
› <bold><dim>1 snapshot reviewed<bold></>, <bold><green>1 snapshot updated</></>
263+
264+
<bold>Watch Usage</>
265+
<dim> › Press </>Enter<dim> to return to watch mode.</>
266+
"
267+
`;
268+
269+
exports[`SnapshotInteractiveMode update 2 tests, then finish and return 1`] = `
270+
"[MOCK - cursorUp]
271+
[MOCK - eraseDown]
272+
273+
<bold>Interactive Snapshot Progress</>
274+
› <bold><dim>2 snapshots remaining<bold></>
275+
276+
<bold>Watch Usage</>
277+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
278+
<dim> › Press </>s<dim> to skip the current test.</>
279+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
280+
<dim> › Press </>Enter<dim> to trigger a test run.</>
281+
"
282+
`;
283+
284+
exports[`SnapshotInteractiveMode update 2 tests, then finish and return 2`] = `
285+
"[MOCK - cursorUp]
286+
[MOCK - eraseDown]
287+
288+
<bold>Interactive Snapshot Progress</>
289+
› <bold><dim>1 snapshot remaining<bold></>, <bold><green>1 snapshot updated</></>
290+
291+
<bold>Watch Usage</>
292+
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
293+
<dim> › Press </>s<dim> to skip the current test.</>
294+
<dim> › Press </>q<dim> to quit Interactive Snapshot Mode.</>
295+
<dim> › Press </>Enter<dim> to trigger a test run.</>
296+
"
297+
`;
298+
299+
exports[`SnapshotInteractiveMode update 2 tests, then finish and return 3`] = `
300+
"[MOCK - eraseDown]
301+
302+
<bold>Interactive Snapshot Result</>
303+
› <bold><dim>2 snapshots reviewed<bold></>, <bold><green>2 snapshots updated</></>
304+
305+
<bold>Watch Usage</>
306+
<dim> › Press </>Enter<dim> to return to watch mode.</>
307+
"
308+
`;

0 commit comments

Comments
 (0)