Skip to content

Commit 54dcadf

Browse files
fix: example with streams and when over planning
1 parent c875b18 commit 54dcadf

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

test/fixtures/test-runner/output/test-runner-plan.js

+20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const { test } = require('node:test');
3+
const { Readable } = require('stream');
34

45
test('test planning basic', (t) => {
56
t.plan(2);
@@ -52,3 +53,22 @@ test('subtest planning by options', (t) => {
5253
});
5354
});
5455

56+
test('failing more assertions than planned', (t) => {
57+
t.plan(2);
58+
t.assert.ok(true);
59+
t.assert.ok(true);
60+
t.assert.ok(true);
61+
});
62+
63+
test('planning with streams', async (t) => {
64+
function* generate() {
65+
yield 'a';
66+
yield 'b';
67+
yield 'c';
68+
}
69+
const expected = ['a', 'b', 'c'];
70+
t.plan(expected.length);
71+
for await (const chunk of Readable.from(generate())) {
72+
t.assert.strictEqual(chunk, expected.shift());
73+
}
74+
})

test/fixtures/test-runner/output/test-runner-plan.snapshot

+18-4
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,25 @@ ok 9 - subtest planning by options
8080
---
8181
duration_ms: *
8282
...
83-
1..9
84-
# tests 13
83+
# Subtest: failing more assertions than planned
84+
not ok 10 - failing more assertions than planned
85+
---
86+
duration_ms: *
87+
location: '/test/fixtures/test-runner/output/test-runner-plan.js:(LINE):1'
88+
failureType: 'testCodeFailure'
89+
error: 'plan expected 2 assertions but received 3'
90+
code: 'ERR_TEST_FAILURE'
91+
...
92+
# Subtest: planning with streams
93+
ok 11 - planning with streams
94+
---
95+
duration_ms: *
96+
...
97+
1..11
98+
# tests 15
8599
# suites 0
86-
# pass 10
87-
# fail 3
100+
# pass 11
101+
# fail 4
88102
# cancelled 0
89103
# skipped 0
90104
# todo 0

0 commit comments

Comments
 (0)