forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: Marco Ippolito <marcoippolito54@gmail.com> PR-URL: nodejs#52860 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
- Loading branch information
1 parent
2863c54
commit 0c83f80
Showing
6 changed files
with
321 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
'use strict'; | ||
const { test } = require('node:test'); | ||
const { Readable } = require('node:stream'); | ||
|
||
test('test planning basic', (t) => { | ||
t.plan(2); | ||
t.assert.ok(true); | ||
t.assert.ok(true); | ||
}); | ||
|
||
test('less assertions than planned', (t) => { | ||
t.plan(1); | ||
}); | ||
|
||
test('more assertions than planned', (t) => { | ||
t.plan(1); | ||
t.assert.ok(true); | ||
t.assert.ok(true); | ||
}); | ||
|
||
test('subtesting', (t) => { | ||
t.plan(1); | ||
t.test('subtest', () => { }); | ||
}); | ||
|
||
test('subtesting correctly', (t) => { | ||
t.plan(2); | ||
t.assert.ok(true); | ||
t.test('subtest', (st) => { | ||
st.plan(1); | ||
st.assert.ok(true); | ||
}); | ||
}); | ||
|
||
test('correctly ignoring subtesting plan', (t) => { | ||
t.plan(1); | ||
t.test('subtest', (st) => { | ||
st.plan(1); | ||
st.assert.ok(true); | ||
}); | ||
}); | ||
|
||
test('failing planning by options', { plan: 1 }, () => { | ||
}); | ||
|
||
test('not failing planning by options', { plan: 1 }, (t) => { | ||
t.assert.ok(true); | ||
}); | ||
|
||
test('subtest planning by options', (t) => { | ||
t.test('subtest', { plan: 1 }, (st) => { | ||
st.assert.ok(true); | ||
}); | ||
}); | ||
|
||
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', (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(); | ||
}); | ||
}) |
Oops, something went wrong.