File tree 2 files changed +22
-2
lines changed
2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -298,7 +298,9 @@ class AssertionError extends Error {
298
298
const {
299
299
message,
300
300
operator,
301
- stackStartFn
301
+ stackStartFn,
302
+ // Compatibility with older versions.
303
+ stackStartFunction
302
304
} = options ;
303
305
let {
304
306
actual,
@@ -418,7 +420,7 @@ class AssertionError extends Error {
418
420
this . expected = expected ;
419
421
this . operator = operator ;
420
422
// eslint-disable-next-line no-restricted-syntax
421
- Error . captureStackTrace ( this , stackStartFn ) ;
423
+ Error . captureStackTrace ( this , stackStartFn || stackStartFunction ) ;
422
424
// Create error message including the error code in the name.
423
425
this . stack ;
424
426
// Reset the name.
Original file line number Diff line number Diff line change @@ -1203,3 +1203,21 @@ assert.throws(
1203
1203
( ) => a . deepStrictEqual ( ) ,
1204
1204
{ code : 'ERR_MISSING_ARGS' }
1205
1205
) ;
1206
+
1207
+ // Verify that `stackStartFunction` works as alternative to `stackStartFn`.
1208
+ {
1209
+ ( function hidden ( ) {
1210
+ const err = new assert . AssertionError ( {
1211
+ actual : 'foo' ,
1212
+ operator : 'strictEqual' ,
1213
+ stackStartFunction : hidden
1214
+ } ) ;
1215
+ const err2 = new assert . AssertionError ( {
1216
+ actual : 'foo' ,
1217
+ operator : 'strictEqual' ,
1218
+ stackStartFn : hidden
1219
+ } ) ;
1220
+ assert ( ! err . stack . includes ( 'hidden' ) ) ;
1221
+ assert ( ! err2 . stack . includes ( 'hidden' ) ) ;
1222
+ } ) ( ) ;
1223
+ }
You can’t perform that action at this time.
0 commit comments