Skip to content

Commit 624a47c

Browse files
committed
Test more *Each hooks
1 parent 8ed96f6 commit 624a47c

File tree

4 files changed

+75
-7
lines changed

4 files changed

+75
-7
lines changed

test/snapshot-order/fixtures/report-declaration-order/test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ test.before(t => {
66
t.snapshot(id(-2), 'in a before hook');
77
});
88

9+
test.beforeEach(t => {
10+
t.snapshot(id(-1.5), 'in a beforeEach hook');
11+
});
12+
913
test.afterEach(t => {
10-
t.snapshot(id(-1), 'in an after hook');
14+
t.snapshot(id(-1), 'in an afterEach hook');
15+
});
16+
17+
test.afterEach.always(t => {
18+
t.snapshot(id(-0.5), 'in an afterEachAlways hook');
1119
});
1220

1321
test('B - declare some snapshots', t => {

test/snapshot-order/fixtures/report-declaration-order/test.js.md

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,96 @@ Generated by [AVA](https://avajs.dev).
1010
1111
'index: -2'
1212

13+
## beforeEach hook for B - declare some snapshots
14+
15+
> in a beforeEach hook
16+
17+
'index: -1.5'
18+
19+
## beforeEach hook for A - declare some more snapshots
20+
21+
> in a beforeEach hook
22+
23+
'index: -1.5'
24+
25+
## beforeEach hook for C - declare some snapshots in a try()
26+
27+
> in a beforeEach hook
28+
29+
'index: -1.5'
30+
31+
## beforeEach hook for E - discard some snapshots in a try()
32+
33+
> in a beforeEach hook
34+
35+
'index: -1.5'
36+
37+
## beforeEach hook for D - more snapshots with ids
38+
39+
> in a beforeEach hook
40+
41+
'index: -1.5'
42+
1343
## afterEach hook for B - declare some snapshots
1444

15-
> in an after hook
45+
> in an afterEach hook
1646
1747
'index: -1'
1848

1949
## afterEach hook for A - declare some more snapshots
2050

21-
> in an after hook
51+
> in an afterEach hook
2252
2353
'index: -1'
2454

2555
## afterEach hook for C - declare some snapshots in a try()
2656

27-
> in an after hook
57+
> in an afterEach hook
2858
2959
'index: -1'
3060

3161
## afterEach hook for E - discard some snapshots in a try()
3262

33-
> in an after hook
63+
> in an afterEach hook
3464
3565
'index: -1'
3666

3767
## afterEach hook for D - more snapshots with ids
3868

39-
> in an after hook
69+
> in an afterEach hook
4070
4171
'index: -1'
4272

73+
## afterEach.always hook for B - declare some snapshots
74+
75+
> in an afterEachAlways hook
76+
77+
'index: -0.5'
78+
79+
## afterEach.always hook for A - declare some more snapshots
80+
81+
> in an afterEachAlways hook
82+
83+
'index: -0.5'
84+
85+
## afterEach.always hook for C - declare some snapshots in a try()
86+
87+
> in an afterEachAlways hook
88+
89+
'index: -0.5'
90+
91+
## afterEach.always hook for E - discard some snapshots in a try()
92+
93+
> in an afterEachAlways hook
94+
95+
'index: -0.5'
96+
97+
## afterEach.always hook for D - more snapshots with ids
98+
99+
> in an afterEachAlways hook
100+
101+
'index: -0.5'
102+
43103
## B - declare some snapshots
44104

45105
> Snapshot 1
Binary file not shown.

test/snapshot-order/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test('snapshot reports are sorted in declaration order', async t => {
4545
}
4646
}
4747

48-
const ids = [...matchAll(report, /'index: ([-\d]+)'/g)].map(match => Number(match[1]));
48+
const ids = [...matchAll(report, /'index: ([-.\d]+)'/g)].map(match => Number(match[1]));
4949
const sortedIds = [...ids].sort((a, b) => a - b);
5050

5151
t.deepEqual(ids, sortedIds);

0 commit comments

Comments
 (0)