Skip to content

Commit bcf53ef

Browse files
committed
cr: add tests
1 parent 35602f9 commit bcf53ef

File tree

3 files changed

+136
-57
lines changed

3 files changed

+136
-57
lines changed

lib/internal/test_runner/test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ class Test extends AsyncResource {
360360
if (this.endTime < this.startTime) {
361361
this.endTime = hrtime();
362362
}
363+
if (this.startTime === null) {
364+
this.startTime = this.endTime;
365+
}
363366

364367
// The test has run, so recursively cancel any outstanding subtests and
365368
// mark this test as failed if any subtests failed.
@@ -458,7 +461,7 @@ class Suite extends Test {
458461
super(options);
459462

460463
try {
461-
this.runInAsyncScope(this.fn);
464+
this.buildSuite = this.runInAsyncScope(this.fn);
462465
} catch (err) {
463466
this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure));
464467
}
@@ -471,6 +474,11 @@ class Suite extends Test {
471474
}
472475

473476
async run() {
477+
try {
478+
await this.buildSuite;
479+
} catch (err) {
480+
this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure));
481+
}
474482
this.parent.activeSubtests++;
475483
this.startTime = hrtime();
476484
const subtests = this.skipped || this.error ? [] : this.subtests;

test/message/test_runner_desctibe_it.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ it('async throw fail', async () => {
4545
throw new Error('thrown from async throw fail');
4646
});
4747

48+
it('async skip fail', async (t) => {
49+
t.skip();
50+
throw new Error('thrown from async throw fail');
51+
});
52+
4853
it('async assertion fail', async () => {
4954
// Make sure the assert module is handled.
5055
assert.strictEqual(true, false);
@@ -301,3 +306,13 @@ describe('subtest sync throw fails', () => {
301306
throw new Error('thrown from subtest sync throw fails at second');
302307
});
303308
});
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+
});

0 commit comments

Comments
 (0)