@@ -11,7 +11,7 @@ describe('describe hooks', () => {
11
11
before ( function ( ) {
12
12
testArr . push ( 'before ' + this . name ) ;
13
13
} ) ;
14
- after ( function ( ) {
14
+ after ( common . mustCall ( function ( ) {
15
15
testArr . push ( 'after ' + this . name ) ;
16
16
assert . deepStrictEqual ( testArr , [
17
17
'before describe hooks' ,
@@ -23,7 +23,7 @@ describe('describe hooks', () => {
23
23
'after nested' ,
24
24
'after describe hooks' ,
25
25
] ) ;
26
- } ) ;
26
+ } ) ) ;
27
27
beforeEach ( function ( ) {
28
28
testArr . push ( 'beforeEach ' + this . name ) ;
29
29
} ) ;
@@ -52,18 +52,43 @@ describe('describe hooks', () => {
52
52
} ) ;
53
53
} ) ;
54
54
55
+ describe ( 'describe hooks - no subtests' , ( ) => {
56
+ const testArr = [ ] ;
57
+ before ( function ( ) {
58
+ testArr . push ( 'before ' + this . name ) ;
59
+ } ) ;
60
+ after ( common . mustCall ( function ( ) {
61
+ testArr . push ( 'after ' + this . name ) ;
62
+ assert . deepStrictEqual ( testArr , [
63
+ 'before describe hooks - no subtests' ,
64
+ 'after describe hooks - no subtests' ,
65
+ ] ) ;
66
+ } ) ) ;
67
+ beforeEach ( common . mustNotCall ( ) ) ;
68
+ afterEach ( common . mustNotCall ( ) ) ;
69
+ } ) ;
70
+
55
71
describe ( 'before throws' , ( ) => {
56
72
before ( ( ) => { throw new Error ( 'before' ) ; } ) ;
57
73
it ( '1' , ( ) => { } ) ;
58
74
test ( '2' , ( ) => { } ) ;
59
75
} ) ;
60
76
77
+ describe ( 'before throws - no subtests' , ( ) => {
78
+ before ( ( ) => { throw new Error ( 'before' ) ; } ) ;
79
+ after ( common . mustCall ( ) ) ;
80
+ } ) ;
81
+
61
82
describe ( 'after throws' , ( ) => {
62
83
after ( ( ) => { throw new Error ( 'after' ) ; } ) ;
63
84
it ( '1' , ( ) => { } ) ;
64
85
test ( '2' , ( ) => { } ) ;
65
86
} ) ;
66
87
88
+ describe ( 'after throws - no subtests' , ( ) => {
89
+ after ( ( ) => { throw new Error ( 'after' ) ; } ) ;
90
+ } ) ;
91
+
67
92
describe ( 'beforeEach throws' , ( ) => {
68
93
beforeEach ( ( ) => { throw new Error ( 'beforeEach' ) ; } ) ;
69
94
it ( '1' , ( ) => { } ) ;
@@ -123,13 +148,48 @@ test('test hooks', async (t) => {
123
148
} ) ) ;
124
149
} ) ;
125
150
151
+
152
+ test ( 'test hooks - no subtests' , async ( t ) => {
153
+ const testArr = [ ] ;
154
+
155
+ t . before ( ( t ) => testArr . push ( 'before ' + t . name ) ) ;
156
+ t . after ( common . mustCall ( ( t ) => testArr . push ( 'after ' + t . name ) ) ) ;
157
+ t . beforeEach ( common . mustNotCall ( ) ) ;
158
+ t . afterEach ( common . mustNotCall ( ) ) ;
159
+
160
+ t . after ( common . mustCall ( ( ) => {
161
+ assert . deepStrictEqual ( testArr , [
162
+ 'before test hooks - no subtests' ,
163
+ 'after test hooks - no subtests' ,
164
+ ] ) ;
165
+ } ) ) ;
166
+ } ) ;
167
+
126
168
test ( 't.before throws' , async ( t ) => {
127
169
t . after ( common . mustCall ( ) ) ;
128
170
t . before ( ( ) => { throw new Error ( 'before' ) ; } ) ;
129
171
await t . test ( '1' , ( ) => { } ) ;
130
172
await t . test ( '2' , ( ) => { } ) ;
131
173
} ) ;
132
174
175
+ test ( 't.before throws - no subtests' , async ( t ) => {
176
+ t . after ( common . mustCall ( ) ) ;
177
+ t . before ( ( ) => { throw new Error ( 'before' ) ; } ) ;
178
+ } ) ;
179
+
180
+ test ( 't.after throws' , async ( t ) => {
181
+ t . before ( common . mustCall ( ) ) ;
182
+ t . after ( ( ) => { throw new Error ( 'after' ) ; } ) ;
183
+ await t . test ( '1' , ( ) => { } ) ;
184
+ await t . test ( '2' , ( ) => { } ) ;
185
+ } ) ;
186
+
187
+ test ( 't.after throws - no subtests' , async ( t ) => {
188
+ t . before ( common . mustCall ( ) ) ;
189
+ t . after ( ( ) => { throw new Error ( 'after' ) ; } ) ;
190
+ } ) ;
191
+
192
+
133
193
test ( 't.beforeEach throws' , async ( t ) => {
134
194
t . after ( common . mustCall ( ) ) ;
135
195
t . beforeEach ( ( ) => { throw new Error ( 'beforeEach' ) ; } ) ;
0 commit comments