| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -360,6 +360,7 @@ class Test extends AsyncResource { | |||
| 360 | 360 | if (this.endTime < this.startTime) { | |
| 361 | 361 | this.endTime = hrtime(); | |
| 362 | 362 | } | |
| 363 | + this.startTime ??= this.endTime; | ||
| 363 | 364 | ||
| 364 | 365 | // The test has run, so recursively cancel any outstanding subtests and | |
| 365 | 366 | // mark this test as failed if any subtests failed. | |
@@ -457,7 +458,11 @@ class Suite extends Test { | |||
| 457 | 458 | constructor(options) { | |
| 458 | 459 | super(options); | |
| 459 | 460 | ||
| 460 | - this.runInAsyncScope(this.fn); | ||
| 461 | + try { | ||
| 462 | + this.buildSuite = this.runInAsyncScope(this.fn); | ||
| 463 | + } catch (err) { | ||
| 464 | + this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure)); | ||
| 465 | + } | ||
| 461 | 466 | this.fn = () => {}; | |
| 462 | 467 | this.finished = true; // Forbid adding subtests to this suite | |
| 463 | 468 | } | |
@@ -467,9 +472,14 @@ class Suite extends Test { | |||
| 467 | 472 | } | |
| 468 | 473 | ||
| 469 | 474 | async run() { | |
| 475 | + try { | ||
| 476 | + await this.buildSuite; | ||
| 477 | + } catch (err) { | ||
| 478 | + this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure)); | ||
| 479 | + } | ||
| 470 | 480 | this.parent.activeSubtests++; | |
| 471 | 481 | this.startTime = hrtime(); | |
| 472 | - const subtests = this.skipped ? [] : this.subtests; | ||
| 482 | + const subtests = this.skipped || this.error ? [] : this.subtests; | ||
| 473 | 483 | await ArrayPrototypeReduce(subtests, async (prev, subtest) => { | |
| 474 | 484 | await prev; | |
| 475 | 485 | await subtest.run(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,6 +45,11 @@ it('async throw fail', async () => { | |||
| 45 | 45 | throw new Error('thrown from async throw fail'); | |
| 46 | 46 | }); | |
| 47 | 47 | ||
| 48 | + it('async skip fail', async (t) => { | ||
| 49 | + t.skip(); | ||
| 50 | + throw new Error('thrown from async throw fail'); | ||
| 51 | + }); | ||
| 52 | + | ||
| 48 | 53 | it('async assertion fail', async () => { | |
| 49 | 54 | // Make sure the assert module is handled. | |
| 50 | 55 | assert.strictEqual(true, false); | |
@@ -301,3 +306,13 @@ describe('subtest sync throw fails', () => { | |||
| 301 | 306 | throw new Error('thrown from subtest sync throw fails at second'); | |
| 302 | 307 | }); | |
| 303 | 308 | }); | |
| 309 | + | ||
| 310 | + describe('describe sync throw fails', () => { | ||
| 311 | + it('should not run', () => {}); | ||
| 312 | + throw new Error('thrown from describe'); | ||
| 313 | + }); | ||
| 314 | + | ||
| 315 | + describe('describe async throw fails', async () => { | ||
| 316 | + it('should not run', () => {}); | ||
| 317 | + throw new Error('thrown from describe'); | ||
| 318 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments