| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ff9ef61 commit 9a469be
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -167,7 +167,7 @@ function jsToYaml(indent, name, value) { | |||
| 167 | 167 | } | |
| 168 | 168 | ||
| 169 | 169 | if (isErrorObj) { | |
| 170 | - const { kTestCodeFailure, kHookFailure } = lazyLoadTest(); | ||
| 170 | + const { kTestCodeFailure, kUnwrapErrors } = lazyLoadTest(); | ||
| 171 | 171 | const { | |
| 172 | 172 | cause, | |
| 173 | 173 | code, | |
@@ -181,7 +181,7 @@ function jsToYaml(indent, name, value) { | |||
| 181 | 181 | ||
| 182 | 182 | // If the ERR_TEST_FAILURE came from an error provided by user code, | |
| 183 | 183 | // then try to unwrap the original error message and stack. | |
| 184 | - if (code === 'ERR_TEST_FAILURE' && (failureType === kTestCodeFailure || failureType === kHookFailure)) { | ||
| 184 | + if (code === 'ERR_TEST_FAILURE' && kUnwrapErrors.has(failureType)) { | ||
| 185 | 185 | errStack = cause?.stack ?? errStack; | |
| 186 | 186 | errCode = cause?.code ?? errCode; | |
| 187 | 187 | if (failureType === kTestCodeFailure) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ const { | |||
| 13 | 13 | PromiseResolve, | |
| 14 | 14 | ReflectApply, | |
| 15 | 15 | SafeMap, | |
| 16 | + SafeSet, | ||
| 16 | 17 | SafePromiseAll, | |
| 17 | 18 | SafePromiseRace, | |
| 18 | 19 | Symbol, | |
@@ -62,6 +63,9 @@ const rootConcurrency = isTestRunner ? MathMax(cpus().length - 1, 1) : 1; | |||
| 62 | 63 | const kShouldAbort = Symbol('kShouldAbort'); | |
| 63 | 64 | const kRunHook = Symbol('kRunHook'); | |
| 64 | 65 | const kHookNames = ObjectSeal(['before', 'after', 'beforeEach', 'afterEach']); | |
| 66 | + const kUnwrapErrors = new SafeSet() | ||
| 67 | + .add(kTestCodeFailure).add(kHookFailure) | ||
| 68 | + .add('uncaughtException').add('unhandledRejection'); | ||
| 65 | 69 | ||
| 66 | 70 | ||
| 67 | 71 | function stopTest(timeout, signal) { | |
@@ -695,9 +699,9 @@ module.exports = { | |||
| 695 | 699 | ItTest, | |
| 696 | 700 | kCancelledByParent, | |
| 697 | 701 | kDefaultIndent, | |
| 698 | - kHookFailure, | ||
| 699 | 702 | kSubtestsFailed, | |
| 700 | 703 | kTestCodeFailure, | |
| 704 | + kUnwrapErrors, | ||
| 701 | 705 | Suite, | |
| 702 | 706 | Test, | |
| 703 | 707 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -418,6 +418,7 @@ not ok 49 - callback async throw | |||
| 418 | 418 | code: 'ERR_TEST_FAILURE' | |
| 419 | 419 | stack: |- | |
| 420 | 420 | * | |
| 421 | + * | ||
| 421 | 422 | ... | |
| 422 | 423 | # Subtest: callback async throw after done | |
| 423 | 424 | ok 50 - callback async throw after done | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -371,3 +371,15 @@ test('rejected thenable', () => { | |||
| 371 | 371 | }, | |
| 372 | 372 | }; | |
| 373 | 373 | }); | |
| 374 | + | ||
| 375 | + test('unfinished test with uncaughtException', async () => { | ||
| 376 | + await new Promise(() => { | ||
| 377 | + setTimeout(() => { throw new Error('foo'); }); | ||
| 378 | + }); | ||
| 379 | + }); | ||
| 380 | + | ||
| 381 | + test('unfinished test with unhandledRejection', async () => { | ||
| 382 | + await new Promise(() => { | ||
| 383 | + setTimeout(() => Promise.reject(new Error('bar'))); | ||
| 384 | + }); | ||
| 385 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -463,6 +463,7 @@ not ok 51 - callback async throw | |||
| 463 | 463 | code: 'ERR_TEST_FAILURE' | |
| 464 | 464 | stack: |- | |
| 465 | 465 | * | |
| 466 | + * | ||
| 466 | 467 | ... | |
| 467 | 468 | # Subtest: callback async throw after done | |
| 468 | 469 | ok 52 - callback async throw after done | |
@@ -601,8 +602,32 @@ not ok 62 - rejected thenable | |||
| 601 | 602 | error: 'custom error' | |
| 602 | 603 | code: 'ERR_TEST_FAILURE' | |
| 603 | 604 | ... | |
| 605 | + # Subtest: unfinished test with uncaughtException | ||
| 606 | + not ok 63 - unfinished test with uncaughtException | ||
| 607 | + --- | ||
| 608 | + duration_ms: * | ||
| 609 | + failureType: 'uncaughtException' | ||
| 610 | + error: 'foo' | ||
| 611 | + code: 'ERR_TEST_FAILURE' | ||
| 612 | + stack: |- | ||
| 613 | + * | ||
| 614 | + * | ||
| 615 | + * | ||
| 616 | + ... | ||
| 617 | + # Subtest: unfinished test with unhandledRejection | ||
| 618 | + not ok 64 - unfinished test with unhandledRejection | ||
| 619 | + --- | ||
| 620 | + duration_ms: * | ||
| 621 | + failureType: 'unhandledRejection' | ||
| 622 | + error: 'bar' | ||
| 623 | + code: 'ERR_TEST_FAILURE' | ||
| 624 | + stack: |- | ||
| 625 | + * | ||
| 626 | + * | ||
| 627 | + * | ||
| 628 | + ... | ||
| 604 | 629 | # Subtest: invalid subtest fail | |
| 605 | - not ok 63 - invalid subtest fail | ||
| 630 | + not ok 65 - invalid subtest fail | ||
| 606 | 631 | --- | |
| 607 | 632 | duration_ms: * | |
| 608 | 633 | failureType: 'parentAlreadyFinished' | |
@@ -611,16 +636,16 @@ not ok 63 - invalid subtest fail | |||
| 611 | 636 | stack: |- | |
| 612 | 637 | * | |
| 613 | 638 | ... | |
| 614 | - 1..63 | ||
| 639 | + 1..65 | ||
| 615 | 640 | # Warning: Test "unhandled rejection - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. | |
| 616 | 641 | # Warning: Test "async unhandled rejection - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. | |
| 617 | 642 | # Warning: Test "immediate throw - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event. | |
| 618 | 643 | # Warning: Test "immediate reject - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. | |
| 619 | 644 | # Warning: Test "callback called twice in different ticks" generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. | |
| 620 | 645 | # Warning: Test "callback async throw after done" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. | |
| 621 | - # tests 63 | ||
| 646 | + # tests 65 | ||
| 622 | 647 | # pass 27 | |
| 623 | - # fail 19 | ||
| 648 | + # fail 21 | ||
| 624 | 649 | # cancelled 2 | |
| 625 | 650 | # skipped 10 | |
| 626 | 651 | # todo 5 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments