@@ -36,6 +36,7 @@ class AssertionError extends Error {
36
36
this . assertion = opts . assertion ;
37
37
this . fixedSource = opts . fixedSource ;
38
38
this . improperUsage = opts . improperUsage || false ;
39
+ this . actualStack = opts . actualStack ;
39
40
this . operator = opts . operator ;
40
41
this . values = opts . values || [ ] ;
41
42
@@ -147,11 +148,14 @@ function assertExpectations({assertion, actual, expectations, message, prefix, s
147
148
} ) ;
148
149
}
149
150
151
+ const actualStack = actual . stack ;
152
+
150
153
if ( hasOwnProperty ( expectations , 'is' ) && actual !== expectations . is ) {
151
154
throw new AssertionError ( {
152
155
assertion,
153
156
message,
154
157
stack,
158
+ actualStack,
155
159
values : [
156
160
formatWithLabel ( `${ prefix } unexpected exception:` , actual ) ,
157
161
formatWithLabel ( 'Expected to be strictly equal to:' , expectations . is )
@@ -164,6 +168,7 @@ function assertExpectations({assertion, actual, expectations, message, prefix, s
164
168
assertion,
165
169
message,
166
170
stack,
171
+ actualStack,
167
172
values : [
168
173
formatWithLabel ( `${ prefix } unexpected exception:` , actual ) ,
169
174
formatWithLabel ( 'Expected instance of:' , expectations . instanceOf )
@@ -176,6 +181,7 @@ function assertExpectations({assertion, actual, expectations, message, prefix, s
176
181
assertion,
177
182
message,
178
183
stack,
184
+ actualStack,
179
185
values : [
180
186
formatWithLabel ( `${ prefix } unexpected exception:` , actual ) ,
181
187
formatWithLabel ( 'Expected name to equal:' , expectations . name )
@@ -188,6 +194,7 @@ function assertExpectations({assertion, actual, expectations, message, prefix, s
188
194
assertion,
189
195
message,
190
196
stack,
197
+ actualStack,
191
198
values : [
192
199
formatWithLabel ( `${ prefix } unexpected exception:` , actual ) ,
193
200
formatWithLabel ( 'Expected message to equal:' , expectations . message )
@@ -200,6 +207,7 @@ function assertExpectations({assertion, actual, expectations, message, prefix, s
200
207
assertion,
201
208
message,
202
209
stack,
210
+ actualStack,
203
211
values : [
204
212
formatWithLabel ( `${ prefix } unexpected exception:` , actual ) ,
205
213
formatWithLabel ( 'Expected message to match:' , expectations . message )
@@ -212,6 +220,7 @@ function assertExpectations({assertion, actual, expectations, message, prefix, s
212
220
assertion,
213
221
message,
214
222
stack,
223
+ actualStack,
215
224
values : [
216
225
formatWithLabel ( `${ prefix } unexpected exception:` , actual ) ,
217
226
formatWithLabel ( 'Expected code to equal:' , expectations . code )
@@ -433,6 +442,7 @@ function wrapAssertions(callbacks) {
433
442
fail ( this , new AssertionError ( {
434
443
assertion : 'throwsAsync' ,
435
444
message,
445
+ actualStack : actual . stack ,
436
446
values : [ formatWithLabel ( 'Function threw synchronously. Use `t.throws()` instead:' , actual ) ]
437
447
} ) ) ;
438
448
return Promise . resolve ( ) ;
@@ -467,6 +477,7 @@ function wrapAssertions(callbacks) {
467
477
fail ( this , new AssertionError ( {
468
478
assertion : 'notThrows' ,
469
479
message,
480
+ actualStack : error . stack ,
470
481
values : [ formatWithLabel ( 'Function threw:' , error ) ]
471
482
} ) ) ;
472
483
return ;
@@ -493,7 +504,7 @@ function wrapAssertions(callbacks) {
493
504
throw new AssertionError ( {
494
505
assertion : 'notThrowsAsync' ,
495
506
message,
496
- stack,
507
+ actualStack : stack ,
497
508
values : [ formatWithLabel ( `${ wasReturned ? 'Returned promise' : 'Promise' } rejected with:` , reason ) ]
498
509
} ) ;
499
510
} ) ;
@@ -513,6 +524,7 @@ function wrapAssertions(callbacks) {
513
524
fail ( this , new AssertionError ( {
514
525
assertion : 'notThrowsAsync' ,
515
526
message,
527
+ actualStack : error . stack ,
516
528
values : [ formatWithLabel ( 'Function threw:' , error ) ]
517
529
} ) ) ;
518
530
return Promise . resolve ( ) ;
0 commit comments