From d28ef6ad490e35f167cd03a6d3a636a0fde2b312 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Mon, 24 Feb 2025 09:36:30 +0100 Subject: [PATCH 1/7] test: test runner run plan --- test/fixtures/test-runner/plan/less.mjs | 7 ++ test/fixtures/test-runner/plan/match.mjs | 7 ++ test/fixtures/test-runner/plan/more.mjs | 7 ++ .../test-runner/plan/nested-subtests.mjs | 14 +++ .../test-runner/plan/plan-via-options.mjs | 9 ++ test/fixtures/test-runner/plan/streaming.mjs | 20 ++++ test/fixtures/test-runner/plan/subtest.mjs | 9 ++ test/parallel/test-runner-run-plan.mjs | 92 +++++++++++++++++++ 8 files changed, 165 insertions(+) create mode 100644 test/fixtures/test-runner/plan/less.mjs create mode 100644 test/fixtures/test-runner/plan/match.mjs create mode 100644 test/fixtures/test-runner/plan/more.mjs create mode 100644 test/fixtures/test-runner/plan/nested-subtests.mjs create mode 100644 test/fixtures/test-runner/plan/plan-via-options.mjs create mode 100644 test/fixtures/test-runner/plan/streaming.mjs create mode 100644 test/fixtures/test-runner/plan/subtest.mjs create mode 100644 test/parallel/test-runner-run-plan.mjs diff --git a/test/fixtures/test-runner/plan/less.mjs b/test/fixtures/test-runner/plan/less.mjs new file mode 100644 index 00000000000000..5f482d019428de --- /dev/null +++ b/test/fixtures/test-runner/plan/less.mjs @@ -0,0 +1,7 @@ +import test from 'node:test'; + +test('less assertions than planned', (t) => { + t.plan(2); + t.assert.ok(true, 'only one assertion'); + // Missing second assertion +}); diff --git a/test/fixtures/test-runner/plan/match.mjs b/test/fixtures/test-runner/plan/match.mjs new file mode 100644 index 00000000000000..eb7e64fa68be16 --- /dev/null +++ b/test/fixtures/test-runner/plan/match.mjs @@ -0,0 +1,7 @@ +import test from 'node:test'; + +test('matching assertions', (t) => { + t.plan(2); + t.assert.ok(true, 'first assertion'); + t.assert.ok(true, 'second assertion'); +}); diff --git a/test/fixtures/test-runner/plan/more.mjs b/test/fixtures/test-runner/plan/more.mjs new file mode 100644 index 00000000000000..deb4fb7f9ec4b9 --- /dev/null +++ b/test/fixtures/test-runner/plan/more.mjs @@ -0,0 +1,7 @@ +import test from 'node:test'; + +test('more assertions than planned', (t) => { + t.plan(1); + t.assert.ok(true, 'first assertion'); + t.assert.ok(true, 'extra assertion'); // This should cause failure +}); diff --git a/test/fixtures/test-runner/plan/nested-subtests.mjs b/test/fixtures/test-runner/plan/nested-subtests.mjs new file mode 100644 index 00000000000000..61fc11b6278243 --- /dev/null +++ b/test/fixtures/test-runner/plan/nested-subtests.mjs @@ -0,0 +1,14 @@ +import test from 'node:test'; + +test('deeply nested tests', async (t) => { + t.plan(1); + + await t.test('level 1', async (t) => { + t.plan(1); + + await t.test('level 2', (t) => { + t.plan(1); + t.assert.ok(true, 'deepest assertion'); + }); + }); +}); diff --git a/test/fixtures/test-runner/plan/plan-via-options.mjs b/test/fixtures/test-runner/plan/plan-via-options.mjs new file mode 100644 index 00000000000000..fd27f75bd166c6 --- /dev/null +++ b/test/fixtures/test-runner/plan/plan-via-options.mjs @@ -0,0 +1,9 @@ +import test from 'node:test'; + +test('failing planning by options', { plan: 1 }, () => { + // Should fail - no assertions +}); + +test('passing planning by options', { plan: 1 }, (t) => { + t.assert.ok(true); +}); diff --git a/test/fixtures/test-runner/plan/streaming.mjs b/test/fixtures/test-runner/plan/streaming.mjs new file mode 100644 index 00000000000000..4a6625af8afc7e --- /dev/null +++ b/test/fixtures/test-runner/plan/streaming.mjs @@ -0,0 +1,20 @@ +import test from 'node:test'; +import { Readable } from 'node:stream'; + +test('planning with streams', (t, done) => { + function* generate() { + yield 'a'; + yield 'b'; + yield 'c'; + } + const expected = ['a', 'b', 'c']; + t.plan(expected.length); + const stream = Readable.from(generate()); + stream.on('data', (chunk) => { + t.assert.strictEqual(chunk, expected.shift()); + }); + + stream.on('end', () => { + done(); + }); +}); diff --git a/test/fixtures/test-runner/plan/subtest.mjs b/test/fixtures/test-runner/plan/subtest.mjs new file mode 100644 index 00000000000000..e87757029829f5 --- /dev/null +++ b/test/fixtures/test-runner/plan/subtest.mjs @@ -0,0 +1,9 @@ +import test from 'node:test'; + +test('parent test', async (t) => { + t.plan(1); + await t.test('child test', (t) => { + t.plan(1); + t.assert.ok(true, 'child assertion'); + }); +}); diff --git a/test/parallel/test-runner-run-plan.mjs b/test/parallel/test-runner-run-plan.mjs new file mode 100644 index 00000000000000..710c34f99cdd11 --- /dev/null +++ b/test/parallel/test-runner-run-plan.mjs @@ -0,0 +1,92 @@ +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { describe, it, run } from 'node:test'; +import { join } from 'node:path'; + +const testFixtures = fixtures.path('test-runner'); + +describe('test planning', () => { + it('should pass when assertions match plan', async () => { + const stream = run({ + files: [join(testFixtures, 'plan', 'match.mjs')] + }); + + stream.on('test:fail', common.mustNotCall()); + stream.on('test:pass', common.mustCall(1)); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should fail when less assertions than planned', async () => { + const stream = run({ + files: [join(testFixtures, 'plan', 'less.mjs')] + }); + + stream.on('test:fail', common.mustCall(1)); + stream.on('test:pass', common.mustNotCall()); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should fail when more assertions than planned', async () => { + const stream = run({ + files: [join(testFixtures, 'plan', 'more.mjs')] + }); + + stream.on('test:fail', common.mustCall(1)); + stream.on('test:pass', common.mustNotCall()); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should handle plan with subtests correctly', async () => { + const stream = run({ + files: [join(testFixtures, 'plan', 'subtest.mjs')] + }); + + stream.on('test:fail', common.mustNotCall()); + stream.on('test:pass', common.mustCall(2)); // Parent + child test + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should handle plan via options', async () => { + const stream = run({ + files: [join(testFixtures, 'plan', 'plan-via-options.mjs')] + }); + + stream.on('test:fail', common.mustCall(1)); + stream.on('test:pass', common.mustCall(1)); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should handle streaming with plan', async () => { + const stream = run({ + files: [join(testFixtures, 'plan', 'streaming.mjs')] + }); + + stream.on('test:fail', common.mustNotCall()); + stream.on('test:pass', common.mustCall(1)); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should handle nested subtests with plan', async () => { + const stream = run({ + files: [join(testFixtures, 'plan', 'nested-subtests.mjs')] + }); + + stream.on('test:fail', common.mustNotCall()); + stream.on('test:pass', common.mustCall(3)); // Parent + 2 levels of nesting + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); +}); From 245ad8bc80e2fef5fa24ece6c8d6bfc5496cef94 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Mon, 3 Mar 2025 11:41:47 +0100 Subject: [PATCH 2/7] test: add timeout tests for t.plan --- .../test-runner/plan/timeout-basic.mjs | 15 +++ .../test-runner/plan/timeout-expired.mjs | 8 ++ .../test-runner/plan/timeout-options.mjs | 16 ++++ .../test-runner/plan/timeout-wait-false.mjs | 11 +++ .../test-runner/plan/timeout-wait-true.mjs | 17 ++++ test/parallel/test-runner-run-plan.mjs | 92 ++++++++++++++++--- 6 files changed, 146 insertions(+), 13 deletions(-) create mode 100644 test/fixtures/test-runner/plan/timeout-basic.mjs create mode 100644 test/fixtures/test-runner/plan/timeout-expired.mjs create mode 100644 test/fixtures/test-runner/plan/timeout-options.mjs create mode 100644 test/fixtures/test-runner/plan/timeout-wait-false.mjs create mode 100644 test/fixtures/test-runner/plan/timeout-wait-true.mjs diff --git a/test/fixtures/test-runner/plan/timeout-basic.mjs b/test/fixtures/test-runner/plan/timeout-basic.mjs new file mode 100644 index 00000000000000..ab9c5cf92d1cf8 --- /dev/null +++ b/test/fixtures/test-runner/plan/timeout-basic.mjs @@ -0,0 +1,15 @@ +import test from 'node:test'; + +test('planning with wait should PASS within timeout', async (t) => { + t.plan(1, { wait: 5000 }); + setTimeout(() => { + t.assert.ok(true); + }, 250); +}); + +test('planning with wait should FAIL within timeout', async (t) => { + t.plan(1, { wait: 5000 }); + setTimeout(() => { + t.assert.ok(false); + }, 250); +}); diff --git a/test/fixtures/test-runner/plan/timeout-expired.mjs b/test/fixtures/test-runner/plan/timeout-expired.mjs new file mode 100644 index 00000000000000..99450b7159ed48 --- /dev/null +++ b/test/fixtures/test-runner/plan/timeout-expired.mjs @@ -0,0 +1,8 @@ +import test from 'node:test'; + +test('planning should FAIL when wait time expires before plan is met', (t) => { + t.plan(2, { wait: 500 }); + setTimeout(() => { + t.assert.ok(true); + }, 50_000_000); +}); diff --git a/test/fixtures/test-runner/plan/timeout-options.mjs b/test/fixtures/test-runner/plan/timeout-options.mjs new file mode 100644 index 00000000000000..cdce1d5aab4112 --- /dev/null +++ b/test/fixtures/test-runner/plan/timeout-options.mjs @@ -0,0 +1,16 @@ +import test from 'node:test'; +import * as common from '../../../common/index.mjs'; + +test('with wait:true should PASS', (t) => { + t.plan(1, { wait: true }); + setTimeout(() => { + t.assert.ok(true); + }, common.platformTimeout(500)); +}); + +test('with wait:false should NOT wait for assertions', (t) => { + t.plan(1, { wait: false }); + setTimeout(() => { + t.assert.ok(true); + }, common.platformTimeout(30_000)); +}); diff --git a/test/fixtures/test-runner/plan/timeout-wait-false.mjs b/test/fixtures/test-runner/plan/timeout-wait-false.mjs new file mode 100644 index 00000000000000..f2a254b001bb61 --- /dev/null +++ b/test/fixtures/test-runner/plan/timeout-wait-false.mjs @@ -0,0 +1,11 @@ +import test from 'node:test'; + +test('should not wait for assertions and fail immediately', async (t) => { + t.plan(1, { wait: false }); + + // Set up an async operation that won't complete before the test finishes + // Since wait:false, the test should fail immediately without waiting + setTimeout(() => { + t.assert.ok(true); + }, 1000); +}); diff --git a/test/fixtures/test-runner/plan/timeout-wait-true.mjs b/test/fixtures/test-runner/plan/timeout-wait-true.mjs new file mode 100644 index 00000000000000..590a610bc6f5a7 --- /dev/null +++ b/test/fixtures/test-runner/plan/timeout-wait-true.mjs @@ -0,0 +1,17 @@ +import test from 'node:test'; + +test('should pass when assertions are eventually met', async (t) => { + t.plan(1, { wait: true }); + + setTimeout(() => { + t.assert.ok(true); + }, 250); +}); + +test('should fail when assertions fail', async (t) => { + t.plan(1, { wait: true }); + + setTimeout(() => { + t.assert.ok(false); + }, 250); +}); diff --git a/test/parallel/test-runner-run-plan.mjs b/test/parallel/test-runner-run-plan.mjs index 710c34f99cdd11..be2aa9468209a7 100644 --- a/test/parallel/test-runner-run-plan.mjs +++ b/test/parallel/test-runner-run-plan.mjs @@ -10,10 +10,10 @@ describe('test planning', () => { const stream = run({ files: [join(testFixtures, 'plan', 'match.mjs')] }); - + stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(1)); - + // eslint-disable-next-line no-unused-vars for await (const _ of stream); }); @@ -22,10 +22,10 @@ describe('test planning', () => { const stream = run({ files: [join(testFixtures, 'plan', 'less.mjs')] }); - + stream.on('test:fail', common.mustCall(1)); stream.on('test:pass', common.mustNotCall()); - + // eslint-disable-next-line no-unused-vars for await (const _ of stream); }); @@ -34,10 +34,10 @@ describe('test planning', () => { const stream = run({ files: [join(testFixtures, 'plan', 'more.mjs')] }); - + stream.on('test:fail', common.mustCall(1)); stream.on('test:pass', common.mustNotCall()); - + // eslint-disable-next-line no-unused-vars for await (const _ of stream); }); @@ -46,10 +46,10 @@ describe('test planning', () => { const stream = run({ files: [join(testFixtures, 'plan', 'subtest.mjs')] }); - + stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(2)); // Parent + child test - + // eslint-disable-next-line no-unused-vars for await (const _ of stream); }); @@ -58,10 +58,10 @@ describe('test planning', () => { const stream = run({ files: [join(testFixtures, 'plan', 'plan-via-options.mjs')] }); - + stream.on('test:fail', common.mustCall(1)); stream.on('test:pass', common.mustCall(1)); - + // eslint-disable-next-line no-unused-vars for await (const _ of stream); }); @@ -70,10 +70,10 @@ describe('test planning', () => { const stream = run({ files: [join(testFixtures, 'plan', 'streaming.mjs')] }); - + stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(1)); - + // eslint-disable-next-line no-unused-vars for await (const _ of stream); }); @@ -82,11 +82,77 @@ describe('test planning', () => { const stream = run({ files: [join(testFixtures, 'plan', 'nested-subtests.mjs')] }); - + stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(3)); // Parent + 2 levels of nesting // eslint-disable-next-line no-unused-vars for await (const _ of stream); }); + + describe('with timeout', () => { + it('should handle basic timeout scenarios', async () => { + const stream = run({ + files: [join(testFixtures, 'plan', 'timeout-basic.mjs')] + }); + + stream.on('test:fail', common.mustCall(1)); + stream.on('test:pass', common.mustCall(1)); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should fail when timeout expires before plan is met', async (t) => { + const stream = run({ + files: [join(testFixtures, 'plan', 'timeout-expired.mjs')], + forceExit: true + }); + + stream.on('test:fail', common.mustCall(1)); + stream.on('test:pass', common.mustNotCall()); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should handle wait options in plan', async () => { + const stream = run({ + files: [join(testFixtures, 'plan', 'timeout-options.mjs')], + forceExit: true + }); + + stream.on('test:fail', common.mustCall(1)); + stream.on('test:pass', common.mustCall(1)); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should handle wait:true option specifically', async () => { + const stream = run({ + files: [join(testFixtures, 'plan', 'timeout-wait-true.mjs')], + forceExit: true + }); + + stream.on('test:fail', common.mustCall(1)); + stream.on('test:pass', common.mustCall(1)); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should handle wait:false option (should not wait)', async () => { + const stream = run({ + files: [join(testFixtures, 'plan', 'timeout-wait-false.mjs')], + forceExit: true + }); + + stream.on('test:fail', common.mustCall(1)); // Fails because plan is not met immediately + stream.on('test:pass', common.mustNotCall()); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + }); }); From e9ea9185e662581acba3dccc7c3fce625743ffae Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Mon, 3 Mar 2025 12:01:27 +0100 Subject: [PATCH 3/7] test: add input validation --- test/parallel/test-runner-run-plan.mjs | 31 +++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-runner-run-plan.mjs b/test/parallel/test-runner-run-plan.mjs index be2aa9468209a7..677f5ef46a6502 100644 --- a/test/parallel/test-runner-run-plan.mjs +++ b/test/parallel/test-runner-run-plan.mjs @@ -5,6 +5,35 @@ import { join } from 'node:path'; const testFixtures = fixtures.path('test-runner'); +describe('input validation', () => { + it('throws if options is not an object', (t) => { + t.assert.throws(() => { + t.plan(1, null); + }, { + code: 'ERR_INVALID_ARG_TYPE', + message: /The "options" argument must be of type object/, + }); + }); + + it('throws if options.wait is not a number or a boolean', (t) => { + t.assert.throws(() => { + t.plan(1, { wait: 'foo' }); + }, { + code: 'ERR_INVALID_ARG_TYPE', + message: /The "options\.wait" property must be one of type boolean or number\. Received type string/, + }); + }); + + it('throws if count is not a number', (t) => { + t.assert.throws(() => { + t.plan('foo'); + }, { + code: 'ERR_INVALID_ARG_TYPE', + message: /The "count" argument must be of type number/, + }); + }); +}); + describe('test planning', () => { it('should pass when assertions match plan', async () => { const stream = run({ @@ -85,7 +114,7 @@ describe('test planning', () => { stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(3)); // Parent + 2 levels of nesting - + // eslint-disable-next-line no-unused-vars for await (const _ of stream); }); From dab9a7fe8db7bc2076e4b29abc62b5fdd67f1c39 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Mon, 3 Mar 2025 12:01:45 +0100 Subject: [PATCH 4/7] test_runner: replace test-runner-run-plan with test-runner-plan --- test/parallel/{test-runner-run-plan.mjs => test-runner-plan.mjs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/parallel/{test-runner-run-plan.mjs => test-runner-plan.mjs} (100%) diff --git a/test/parallel/test-runner-run-plan.mjs b/test/parallel/test-runner-plan.mjs similarity index 100% rename from test/parallel/test-runner-run-plan.mjs rename to test/parallel/test-runner-plan.mjs From 48c5c4f84dabd7e47fced739adce6e30b2f2c5f3 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Tue, 4 Mar 2025 09:27:34 +0100 Subject: [PATCH 5/7] test_runner: remove duplicate tests --- .../test-runner/plan/timeout-options.mjs | 16 ---------------- test/parallel/test-runner-plan.mjs | 13 ------------- 2 files changed, 29 deletions(-) delete mode 100644 test/fixtures/test-runner/plan/timeout-options.mjs diff --git a/test/fixtures/test-runner/plan/timeout-options.mjs b/test/fixtures/test-runner/plan/timeout-options.mjs deleted file mode 100644 index cdce1d5aab4112..00000000000000 --- a/test/fixtures/test-runner/plan/timeout-options.mjs +++ /dev/null @@ -1,16 +0,0 @@ -import test from 'node:test'; -import * as common from '../../../common/index.mjs'; - -test('with wait:true should PASS', (t) => { - t.plan(1, { wait: true }); - setTimeout(() => { - t.assert.ok(true); - }, common.platformTimeout(500)); -}); - -test('with wait:false should NOT wait for assertions', (t) => { - t.plan(1, { wait: false }); - setTimeout(() => { - t.assert.ok(true); - }, common.platformTimeout(30_000)); -}); diff --git a/test/parallel/test-runner-plan.mjs b/test/parallel/test-runner-plan.mjs index 677f5ef46a6502..30353eb9ceff02 100644 --- a/test/parallel/test-runner-plan.mjs +++ b/test/parallel/test-runner-plan.mjs @@ -145,19 +145,6 @@ describe('test planning', () => { for await (const _ of stream); }); - it('should handle wait options in plan', async () => { - const stream = run({ - files: [join(testFixtures, 'plan', 'timeout-options.mjs')], - forceExit: true - }); - - stream.on('test:fail', common.mustCall(1)); - stream.on('test:pass', common.mustCall(1)); - - // eslint-disable-next-line no-unused-vars - for await (const _ of stream); - }); - it('should handle wait:true option specifically', async () => { const stream = run({ files: [join(testFixtures, 'plan', 'timeout-wait-true.mjs')], From ad45621d66868a5d00803e42550c7b3b8a832063 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Tue, 4 Mar 2025 22:02:55 +0100 Subject: [PATCH 6/7] test: remove forceExit option in test runner plans --- test/fixtures/test-runner/plan/timeout-expired.mjs | 2 +- test/fixtures/test-runner/plan/timeout-wait-false.mjs | 2 +- test/fixtures/test-runner/plan/timeout-wait-true.mjs | 2 +- test/parallel/test-runner-plan.mjs | 9 +++------ 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/test/fixtures/test-runner/plan/timeout-expired.mjs b/test/fixtures/test-runner/plan/timeout-expired.mjs index 99450b7159ed48..3d96df79498425 100644 --- a/test/fixtures/test-runner/plan/timeout-expired.mjs +++ b/test/fixtures/test-runner/plan/timeout-expired.mjs @@ -4,5 +4,5 @@ test('planning should FAIL when wait time expires before plan is met', (t) => { t.plan(2, { wait: 500 }); setTimeout(() => { t.assert.ok(true); - }, 50_000_000); + }, 30_000).unref(); }); diff --git a/test/fixtures/test-runner/plan/timeout-wait-false.mjs b/test/fixtures/test-runner/plan/timeout-wait-false.mjs index f2a254b001bb61..b9830ca8286d0c 100644 --- a/test/fixtures/test-runner/plan/timeout-wait-false.mjs +++ b/test/fixtures/test-runner/plan/timeout-wait-false.mjs @@ -7,5 +7,5 @@ test('should not wait for assertions and fail immediately', async (t) => { // Since wait:false, the test should fail immediately without waiting setTimeout(() => { t.assert.ok(true); - }, 1000); + }, 1000).unref(); }); diff --git a/test/fixtures/test-runner/plan/timeout-wait-true.mjs b/test/fixtures/test-runner/plan/timeout-wait-true.mjs index 590a610bc6f5a7..cc0dd8d8ab0d67 100644 --- a/test/fixtures/test-runner/plan/timeout-wait-true.mjs +++ b/test/fixtures/test-runner/plan/timeout-wait-true.mjs @@ -13,5 +13,5 @@ test('should fail when assertions fail', async (t) => { setTimeout(() => { t.assert.ok(false); - }, 250); + }, 250).unref(); }); diff --git a/test/parallel/test-runner-plan.mjs b/test/parallel/test-runner-plan.mjs index 30353eb9ceff02..1b5acb1d3aa115 100644 --- a/test/parallel/test-runner-plan.mjs +++ b/test/parallel/test-runner-plan.mjs @@ -134,8 +134,7 @@ describe('test planning', () => { it('should fail when timeout expires before plan is met', async (t) => { const stream = run({ - files: [join(testFixtures, 'plan', 'timeout-expired.mjs')], - forceExit: true + files: [join(testFixtures, 'plan', 'timeout-expired.mjs')] }); stream.on('test:fail', common.mustCall(1)); @@ -147,8 +146,7 @@ describe('test planning', () => { it('should handle wait:true option specifically', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'timeout-wait-true.mjs')], - forceExit: true + files: [join(testFixtures, 'plan', 'timeout-wait-true.mjs')] }); stream.on('test:fail', common.mustCall(1)); @@ -160,8 +158,7 @@ describe('test planning', () => { it('should handle wait:false option (should not wait)', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'timeout-wait-false.mjs')], - forceExit: true + files: [join(testFixtures, 'plan', 'timeout-wait-false.mjs')] }); stream.on('test:fail', common.mustCall(1)); // Fails because plan is not met immediately From 97f1057b933f4dbf8905a34316c547fc2e0e14c0 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Tue, 4 Mar 2025 22:22:18 +0100 Subject: [PATCH 7/7] test: update testFixtures path --- test/parallel/test-runner-plan.mjs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-runner-plan.mjs b/test/parallel/test-runner-plan.mjs index 1b5acb1d3aa115..85f8f570453c0c 100644 --- a/test/parallel/test-runner-plan.mjs +++ b/test/parallel/test-runner-plan.mjs @@ -3,7 +3,7 @@ import * as fixtures from '../common/fixtures.mjs'; import { describe, it, run } from 'node:test'; import { join } from 'node:path'; -const testFixtures = fixtures.path('test-runner'); +const testFixtures = fixtures.path('test-runner', 'plan'); describe('input validation', () => { it('throws if options is not an object', (t) => { @@ -37,7 +37,7 @@ describe('input validation', () => { describe('test planning', () => { it('should pass when assertions match plan', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'match.mjs')] + files: [join(testFixtures, 'match.mjs')] }); stream.on('test:fail', common.mustNotCall()); @@ -49,7 +49,7 @@ describe('test planning', () => { it('should fail when less assertions than planned', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'less.mjs')] + files: [join(testFixtures, 'less.mjs')] }); stream.on('test:fail', common.mustCall(1)); @@ -61,7 +61,7 @@ describe('test planning', () => { it('should fail when more assertions than planned', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'more.mjs')] + files: [join(testFixtures, 'more.mjs')] }); stream.on('test:fail', common.mustCall(1)); @@ -73,7 +73,7 @@ describe('test planning', () => { it('should handle plan with subtests correctly', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'subtest.mjs')] + files: [join(testFixtures, 'subtest.mjs')] }); stream.on('test:fail', common.mustNotCall()); @@ -85,7 +85,7 @@ describe('test planning', () => { it('should handle plan via options', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'plan-via-options.mjs')] + files: [join(testFixtures, 'plan-via-options.mjs')] }); stream.on('test:fail', common.mustCall(1)); @@ -97,7 +97,7 @@ describe('test planning', () => { it('should handle streaming with plan', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'streaming.mjs')] + files: [join(testFixtures, 'streaming.mjs')] }); stream.on('test:fail', common.mustNotCall()); @@ -109,7 +109,7 @@ describe('test planning', () => { it('should handle nested subtests with plan', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'nested-subtests.mjs')] + files: [join(testFixtures, 'nested-subtests.mjs')] }); stream.on('test:fail', common.mustNotCall()); @@ -122,7 +122,7 @@ describe('test planning', () => { describe('with timeout', () => { it('should handle basic timeout scenarios', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'timeout-basic.mjs')] + files: [join(testFixtures, 'timeout-basic.mjs')] }); stream.on('test:fail', common.mustCall(1)); @@ -134,7 +134,7 @@ describe('test planning', () => { it('should fail when timeout expires before plan is met', async (t) => { const stream = run({ - files: [join(testFixtures, 'plan', 'timeout-expired.mjs')] + files: [join(testFixtures, 'timeout-expired.mjs')] }); stream.on('test:fail', common.mustCall(1)); @@ -146,7 +146,7 @@ describe('test planning', () => { it('should handle wait:true option specifically', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'timeout-wait-true.mjs')] + files: [join(testFixtures, 'timeout-wait-true.mjs')] }); stream.on('test:fail', common.mustCall(1)); @@ -158,7 +158,7 @@ describe('test planning', () => { it('should handle wait:false option (should not wait)', async () => { const stream = run({ - files: [join(testFixtures, 'plan', 'timeout-wait-false.mjs')] + files: [join(testFixtures, 'timeout-wait-false.mjs')] }); stream.on('test:fail', common.mustCall(1)); // Fails because plan is not met immediately