GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: test runner run plan · nodejs/node@b866755

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • fixtures/test-runner/plan
      • less.mjs
      • match.mjs
      • more.mjs
      • nested-subtests.mjs
      • plan-via-options.mjs
      • streaming.mjs
      • subtest.mjs
      • timeout-basic.mjs
      • timeout-expired.mjs
      • timeout-wait-false.mjs
      • timeout-wait-true.mjs
    • parallel
      • test-runner-plan.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/fixtures/test-runner/plan/less.mjs‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import test from 'node:test';
2+
3+
test('less assertions than planned', (t) => {
4+
t.plan(2);
5+
t.assert.ok(true, 'only one assertion');
6+
// Missing second assertion
7+
});
Collapse file

‎test/fixtures/test-runner/plan/match.mjs‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import test from 'node:test';
2+
3+
test('matching assertions', (t) => {
4+
t.plan(2);
5+
t.assert.ok(true, 'first assertion');
6+
t.assert.ok(true, 'second assertion');
7+
});
Collapse file

‎test/fixtures/test-runner/plan/more.mjs‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import test from 'node:test';
2+
3+
test('more assertions than planned', (t) => {
4+
t.plan(1);
5+
t.assert.ok(true, 'first assertion');
6+
t.assert.ok(true, 'extra assertion'); // This should cause failure
7+
});
Collapse file

‎test/fixtures/test-runner/plan/nested-subtests.mjs‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import test from 'node:test';
2+
3+
test('deeply nested tests', async (t) => {
4+
t.plan(1);
5+
6+
await t.test('level 1', async (t) => {
7+
t.plan(1);
8+
9+
await t.test('level 2', (t) => {
10+
t.plan(1);
11+
t.assert.ok(true, 'deepest assertion');
12+
});
13+
});
14+
});
Collapse file

‎test/fixtures/test-runner/plan/plan-via-options.mjs‎

Copy file name to clipboard
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import test from 'node:test';
2+
3+
test('failing planning by options', { plan: 1 }, () => {
4+
// Should fail - no assertions
5+
});
6+
7+
test('passing planning by options', { plan: 1 }, (t) => {
8+
t.assert.ok(true);
9+
});
Collapse file

‎test/fixtures/test-runner/plan/streaming.mjs‎

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import test from 'node:test';
2+
import { Readable } from 'node:stream';
3+
4+
test('planning with streams', (t, done) => {
5+
function* generate() {
6+
yield 'a';
7+
yield 'b';
8+
yield 'c';
9+
}
10+
const expected = ['a', 'b', 'c'];
11+
t.plan(expected.length);
12+
const stream = Readable.from(generate());
13+
stream.on('data', (chunk) => {
14+
t.assert.strictEqual(chunk, expected.shift());
15+
});
16+
17+
stream.on('end', () => {
18+
done();
19+
});
20+
});
Collapse file

‎test/fixtures/test-runner/plan/subtest.mjs‎

Copy file name to clipboard
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import test from 'node:test';
2+
3+
test('parent test', async (t) => {
4+
t.plan(1);
5+
await t.test('child test', (t) => {
6+
t.plan(1);
7+
t.assert.ok(true, 'child assertion');
8+
});
9+
});
Collapse file

‎test/fixtures/test-runner/plan/timeout-basic.mjs‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import test from 'node:test';
2+
3+
test('planning with wait should PASS within timeout', async (t) => {
4+
t.plan(1, { wait: 5000 });
5+
setTimeout(() => {
6+
t.assert.ok(true);
7+
}, 250);
8+
});
9+
10+
test('planning with wait should FAIL within timeout', async (t) => {
11+
t.plan(1, { wait: 5000 });
12+
setTimeout(() => {
13+
t.assert.ok(false);
14+
}, 250);
15+
});
Collapse file

‎test/fixtures/test-runner/plan/timeout-expired.mjs‎

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import test from 'node:test';
2+
3+
test('planning should FAIL when wait time expires before plan is met', (t) => {
4+
t.plan(2, { wait: 500 });
5+
setTimeout(() => {
6+
t.assert.ok(true);
7+
}, 30_000).unref();
8+
});
Collapse file

‎test/fixtures/test-runner/plan/timeout-wait-false.mjs‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import test from 'node:test';
2+
3+
test('should not wait for assertions and fail immediately', async (t) => {
4+
t.plan(1, { wait: false });
5+
6+
// Set up an async operation that won't complete before the test finishes
7+
// Since wait:false, the test should fail immediately without waiting
8+
setTimeout(() => {
9+
t.assert.ok(true);
10+
}, 1000).unref();
11+
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.