Skip to content

Commit 727cbe6

Browse files
committed
fix test
1 parent e9adffc commit 727cbe6

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

test.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -485,24 +485,43 @@ it('Verify node does not support Promise.allSettled stack frames. When this test
485485
assert.doesNotMatch(results2[2].reason.stack, /\bPromise\.allSettled\b/);
486486
});
487487

488-
it('async stack frames: async, Promise.all, Promise.any'/*Promise.allSettled*/, async function() {
488+
it('async stack frames: async, Promise.all'/*Promise.allSettled*/, async function() {
489489
await compareStackTrace(createMultiLineSourceMap(), [
490490
// Add once node upgrades to v8 10.2, where this was added: https://github.com/v8/v8/commit/89ed081c176e286f9d65f3821d43f568cd56a035
491491
// 'async function foo() { return await bar(); }',
492492
// 'async function bar() { return await Promise.allSettled([baz()]) }',
493493

494-
'async function foo() { return await baz(); }',
495-
'async function baz() { await Promise.all([biff()]) }',
496-
'async function biff() { await Promise.any([larry()]); }',
497-
'async function larry() { await null; throw new Error("test"); }',
494+
'async function foo() { return await bar(); }',
495+
'async function bar() { await Promise.all([baz()]) }',
496+
'async function baz() { await null; throw new Error("test"); }',
497+
'return foo();'
498+
], [
499+
'Error: test',
500+
re`^ at baz \(${stackFramePathStartsWith()}(?:.*[/\\])?line3.js:1003:103\)$`,
501+
re`^ at async Promise\.all \(index 0\)$`,
502+
re`^ at async bar \(${stackFramePathStartsWith()}(?:.*[/\\])?line2.js:1002:102\)$`,
503+
re`^ at async foo \(${stackFramePathStartsWith()}(?:.*[/\\])?line1.js:1001:101\)$`
504+
]);
505+
});
506+
507+
it('async stack frames: Promise.any', async function() {
508+
// node 14 and older does not have Promise.any
509+
if(semver.lt(process.versions.node, '16.0.0')) return this.skip();
510+
511+
await compareStackTrace(createMultiLineSourceMap(), [
512+
// Add once node upgrades to v8 10.2, where this was added: https://github.com/v8/v8/commit/89ed081c176e286f9d65f3821d43f568cd56a035
513+
// 'async function foo() { return await bar(); }',
514+
// 'async function bar() { return await Promise.allSettled([baz()]) }',
515+
516+
'async function foo() { return await bar(); }',
517+
'async function bar() { await Promise.any([baz()]); }',
518+
'async function baz() { await null; throw new Error("test"); }',
498519
'return foo().catch(e => { throw e.errors[0] })'
499520
], [
500521
'Error: test',
501-
re`^ at larry \(${stackFramePathStartsWith()}(?:.*[/\\])?line4.js:1004:104\)$`,
522+
re`^ at baz \(${stackFramePathStartsWith()}(?:.*[/\\])?line3.js:1003:103\)$`,
502523
re`^ at async Promise\.any \(index 0\)$`,
503-
re`^ at async biff \(${stackFramePathStartsWith()}(?:.*[/\\])?line3.js:1003:103\)$`,
504-
re`^ at async Promise\.all \(index 0\)$`,
505-
re`^ at async baz \(${stackFramePathStartsWith()}(?:.*[/\\])?line2.js:1002:102\)$`,
524+
re`^ at async bar \(${stackFramePathStartsWith()}(?:.*[/\\])?line2.js:1002:102\)$`,
506525
re`^ at async foo \(${stackFramePathStartsWith()}(?:.*[/\\])?line1.js:1001:101\)$`
507526
]);
508527
});

0 commit comments

Comments
 (0)