| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -561,25 +561,22 @@ class Suite extends Test { | |||
| 561 | 561 | ||
| 562 | 562 | try { | |
| 563 | 563 | const context = { signal: this.signal }; | |
| 564 | - this.buildSuite = this.runInAsyncScope(this.fn, context, [context]); | ||
| 564 | + this.buildSuite = PromisePrototypeThen( | ||
| 565 | + PromiseResolve(this.runInAsyncScope(this.fn, context, [context])), | ||
| 566 | + undefined, | ||
| 567 | + (err) => { | ||
| 568 | + this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure)); | ||
| 569 | + }); | ||
| 565 | 570 | } catch (err) { | |
| 566 | 571 | this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure)); | |
| 567 | 572 | } | |
| 568 | 573 | this.fn = () => {}; | |
| 569 | 574 | this.buildPhaseFinished = true; | |
| 570 | 575 | } | |
| 571 | 576 | ||
| 572 | - start() { | ||
| 573 | - return this.run(); | ||
| 574 | - } | ||
| 575 | - | ||
| 576 | 577 | async run() { | |
| 577 | - try { | ||
| 578 | - await this.buildSuite; | ||
| 579 | - } catch (err) { | ||
| 580 | - this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure)); | ||
| 581 | - } | ||
| 582 | 578 | this.parent.activeSubtests++; | |
| 579 | + await this.buildSuite; | ||
| 583 | 580 | this.startTime = hrtime(); | |
| 584 | 581 | ||
| 585 | 582 | if (this[kShouldAbort]()) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -149,17 +149,6 @@ describe('level 0a', { concurrency: 4 }, () => { | |||
| 149 | 149 | return p0a; | |
| 150 | 150 | }); | |
| 151 | 151 | ||
| 152 | - describe('top level', { concurrency: 2 }, () => { | ||
| 153 | - it('+long running', async () => { | ||
| 154 | - return new Promise((resolve, reject) => { | ||
| 155 | - setTimeout(resolve, 3000).unref(); | ||
| 156 | - }); | ||
| 157 | - }); | ||
| 158 | - | ||
| 159 | - describe('+short running', async () => { | ||
| 160 | - it('++short running', async () => {}); | ||
| 161 | - }); | ||
| 162 | - }); | ||
| 163 | 152 | ||
| 164 | 153 | describe('invalid subtest - pass but subtest fails', () => { | |
| 165 | 154 | setImmediate(() => { | |
@@ -339,3 +328,47 @@ describe('timeouts', () => { | |||
| 339 | 328 | setTimeout(done, 10); | |
| 340 | 329 | }); | |
| 341 | 330 | }); | |
| 331 | + | ||
| 332 | + describe('successful thenable', () => { | ||
| 333 | + it('successful thenable', () => { | ||
| 334 | + let thenCalled = false; | ||
| 335 | + return { | ||
| 336 | + get then() { | ||
| 337 | + if (thenCalled) throw new Error(); | ||
| 338 | + thenCalled = true; | ||
| 339 | + return (successHandler) => successHandler(); | ||
| 340 | + }, | ||
| 341 | + }; | ||
| 342 | + }); | ||
| 343 | + | ||
| 344 | + it('rejected thenable', () => { | ||
| 345 | + let thenCalled = false; | ||
| 346 | + return { | ||
| 347 | + get then() { | ||
| 348 | + if (thenCalled) throw new Error(); | ||
| 349 | + thenCalled = true; | ||
| 350 | + return (_, errorHandler) => errorHandler(new Error('custom error')); | ||
| 351 | + }, | ||
| 352 | + }; | ||
| 353 | + }); | ||
| 354 | + | ||
| 355 | + let thenCalled = false; | ||
| 356 | + return { | ||
| 357 | + get then() { | ||
| 358 | + if (thenCalled) throw new Error(); | ||
| 359 | + thenCalled = true; | ||
| 360 | + return (successHandler) => successHandler(); | ||
| 361 | + }, | ||
| 362 | + }; | ||
| 363 | + }); | ||
| 364 | + | ||
| 365 | + describe('rejected thenable', () => { | ||
| 366 | + let thenCalled = false; | ||
| 367 | + return { | ||
| 368 | + get then() { | ||
| 369 | + if (thenCalled) throw new Error(); | ||
| 370 | + thenCalled = true; | ||
| 371 | + return (_, errorHandler) => errorHandler(new Error('custom error')); | ||
| 372 | + }, | ||
| 373 | + }; | ||
| 374 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments