| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -414,7 +414,11 @@ class Test extends AsyncResource { | |||
| 414 | 414 | this.pass(); | |
| 415 | 415 | } catch (err) { | |
| 416 | 416 | if (err?.code === 'ERR_TEST_FAILURE' && kIsNodeError in err) { | |
| 417 | - this.fail(err); | ||
| 417 | + if (err.failureType === kTestTimeoutFailure) { | ||
| 418 | + this.cancel(err); | ||
| 419 | + } else { | ||
| 420 | + this.fail(err); | ||
| 421 | + } | ||
| 418 | 422 | } else { | |
| 419 | 423 | this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure)); | |
| 420 | 424 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,9 +129,9 @@ not ok 13 - async assertion fail | |||
| 129 | 129 | failureType: 'testCodeFailure' | |
| 130 | 130 | error: |- | |
| 131 | 131 | Expected values to be strictly equal: | |
| 132 | - | ||
| 132 | + | ||
| 133 | 133 | true !== false | |
| 134 | - | ||
| 134 | + | ||
| 135 | 135 | code: 'ERR_ASSERTION' | |
| 136 | 136 | stack: |- | |
| 137 | 137 | * | |
@@ -607,8 +607,8 @@ not ok 61 - invalid subtest fail | |||
| 607 | 607 | # 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. | |
| 608 | 608 | # tests 61 | |
| 609 | 609 | # pass 26 | |
| 610 | - # fail 20 | ||
| 611 | - # cancelled 0 | ||
| 610 | + # fail 18 | ||
| 611 | + # cancelled 2 | ||
| 612 | 612 | # skipped 10 | |
| 613 | 613 | # todo 5 | |
| 614 | 614 | # duration_ms * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,33 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const { spawnSync } = require('child_process'); | ||
| 5 | + const { setTimeout } = require('timers/promises'); | ||
| 6 | + | ||
| 7 | + if (process.argv[2] === 'child') { | ||
| 8 | + const test = require('node:test'); | ||
| 9 | + | ||
| 10 | + if (process.argv[3] === 'abortSignal') { | ||
| 11 | + assert.throws(() => test({ signal: {} }), { | ||
| 12 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 13 | + name: 'TypeError' | ||
| 14 | + }); | ||
| 15 | + | ||
| 16 | + let testSignal; | ||
| 17 | + test({ timeout: 10 }, common.mustCall(async ({ signal }) => { | ||
| 18 | + assert.strictEqual(signal.aborted, false); | ||
| 19 | + testSignal = signal; | ||
| 20 | + await setTimeout(50); | ||
| 21 | + })).finally(common.mustCall(() => { | ||
| 22 | + test(() => assert.strictEqual(testSignal.aborted, true)); | ||
| 23 | + })); | ||
| 24 | + } else assert.fail('unreachable'); | ||
| 25 | + } else { | ||
| 26 | + const child = spawnSync(process.execPath, [__filename, 'child', 'abortSignal']); | ||
| 27 | + const stdout = child.stdout.toString(); | ||
| 28 | + assert.match(stdout, /^# pass 1$/m); | ||
| 29 | + assert.match(stdout, /^# fail 0$/m); | ||
| 30 | + assert.match(stdout, /^# cancelled 1$/m); | ||
| 31 | + assert.strictEqual(child.status, 1); | ||
| 32 | + assert.strictEqual(child.signal, null); | ||
| 33 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments