Skip to content

Commit

Permalink
fix: example with streams and when over planning
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed May 7, 2024
1 parent c875b18 commit 54dcadf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
20 changes: 20 additions & 0 deletions test/fixtures/test-runner/output/test-runner-plan.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
const { test } = require('node:test');
const { Readable } = require('stream');

test('test planning basic', (t) => {
t.plan(2);
Expand Down Expand Up @@ -52,3 +53,22 @@ test('subtest planning by options', (t) => {
});
});

test('failing more assertions than planned', (t) => {
t.plan(2);
t.assert.ok(true);
t.assert.ok(true);
t.assert.ok(true);
});

test('planning with streams', async (t) => {
function* generate() {
yield 'a';
yield 'b';
yield 'c';
}
const expected = ['a', 'b', 'c'];
t.plan(expected.length);
for await (const chunk of Readable.from(generate())) {
t.assert.strictEqual(chunk, expected.shift());
}
})
22 changes: 18 additions & 4 deletions test/fixtures/test-runner/output/test-runner-plan.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,25 @@ ok 9 - subtest planning by options
---
duration_ms: *
...
1..9
# tests 13
# Subtest: failing more assertions than planned
not ok 10 - failing more assertions than planned
---
duration_ms: *
location: '/test/fixtures/test-runner/output/test-runner-plan.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'plan expected 2 assertions but received 3'
code: 'ERR_TEST_FAILURE'
...
# Subtest: planning with streams
ok 11 - planning with streams
---
duration_ms: *
...
1..11
# tests 15
# suites 0
# pass 10
# fail 3
# pass 11
# fail 4
# cancelled 0
# skipped 0
# todo 0
Expand Down

0 comments on commit 54dcadf

Please sign in to comment.