GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing github.com — test_runner: support test plans by marco-ippolito · Pull Request #52860 · nodejs/node Conversation
Member
I picked up the work from this comment #44125 (comment) by @cjihrig to add support for test planning
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
marco-ippolito
force-pushed
the
feat/test-plan
branch
from
61be2da to
8bd4c30
Compare
climba03003
reviewed
Uh oh!
There was an error while loading. Please reload this page.
VoltrexKeyva
reviewed
Uh oh!
There was an error while loading. Please reload this page.
avivkeller
reviewed
Uh oh!
There was an error while loading. Please reload this page. Co-Authored-By: Marco Ippolito <[email protected]>
marco-ippolito
force-pushed
the
feat/test-plan
branch
6 times, most recently
from
607b2fb to
80e4079
Compare
MoLow
reviewed
Uh oh!
There was an error while loading. Please reload this page.
marco-ippolito
force-pushed
the
feat/test-plan
branch
from
80e4079 to
c875b18
Compare
MoLow
reviewed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please elaborate on the use cases of this feature?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
It makes sure that an assertion is called inside a callback, when the callback might not be invoked.
test('make sure callback is invoked', (t) => { t.plan(1) server.listen(0, (r) => { // assert something in here t.ok(true) }); }); With plan you are sure than the callback was invoked and the assertion was performed, otherwise the test would pass anyways. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I am -0.5 on adding this. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hey folks, Marco is working with me and I suggested that he works on this feature that is missing from the Node.js test runner and it's necessary in certain specific cases. The use case is fairly specific and it pertains callback-based APIs. When the callback is called and you need to make assertions there, there is no easy way to do that except telling the test that it should not end before X number of assertions have been made (bar a test timeout). Let's take this example from the Fastify docs: const tap = require('tap') const buildFastify = require('./app') tap.test('GET `/` route', t => { t.plan(4) const fastify = buildFastify() // At the end of your tests it is highly recommended to call `.close()` // to ensure that all connections to external services get closed. t.teardown(() => fastify.close()) fastify.inject({ method: 'GET', url: '/' }, (err, response) => { t.error(err) t.equal(response.statusCode, 200) t.equal(response.headers['content-type'], 'application/json; charset=utf-8') t.same(response.json(), { hello: 'world' }) }) }) Let's forget for a second that I hope this clarifies why this feature is necessary. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think this feature is needed. @marco-ippolito can you add a test that verifies what happens if there were more assertion than the plan? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
df0e137 to
54dcadf
Compare
There was an error while loading. Please reload this page.
|
This is missing a way for other assertion frameworks to tap into the test planning. If I recall correctly, the need for this was what stopped @cjihrig working on this feature. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
54dcadf to
7a6f376
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
The node:assert module contains several top level APIs that do not make sense to expose as methods on t.assert. Examples include AssertionError and CallTracker. This commit removes such APIs from t.assert. Refs: #52860 PR-URL: #53049 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
The node:assert module contains several top level APIs that do not make sense to expose as methods on t.assert. Examples include AssertionError and CallTracker. This commit removes such APIs from t.assert. Refs: #52860 PR-URL: #53049 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
t.subtest -> t.test Refs: nodejs#52860
t.subtest -> t.test Refs: #52860 PR-URL: #53140 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
When context.assert was added, no docs were added. This commit adds initial documentation for context.assert because the snapshot() function requires them. PR-URL: nodejs#53169 Refs: nodejs#52860 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Geoffrey Booth <[email protected]>
t.subtest -> t.test Refs: #52860 PR-URL: #53140 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
When context.assert was added, no docs were added. This commit adds initial documentation for context.assert because the snapshot() function requires them. PR-URL: #53169 Refs: #52860 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Geoffrey Booth <[email protected]>
Co-Authored-By: Marco Ippolito <[email protected]> PR-URL: #52860 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
Notable changes: doc: * add pimterry to collaborators (Tim Perry) #52874 inspector: * (SEMVER-MINOR) introduce the `--inspect-wait` flag (Kohei Ueno) #52734 test_runner: * (SEMVER-MINOR) support test plans (Colin Ihrig) #52860 tools: * (SEMVER-MINOR) fix get_asan_state() in tools/test.py (Joyee Cheung) #52766 * (SEMVER-MINOR) support max_virtual_memory test configuration (Joyee Cheung) #52766 * (SEMVER-MINOR) support != in test status files (Joyee Cheung) #52766 zlib: * (SEMVER-MINOR) expose zlib.crc32() (Joyee Cheung) #52692 PR-URL: #53486
Co-Authored-By: Marco Ippolito <[email protected]> PR-URL: #52860 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
Notable changes: doc: * add pimterry to collaborators (Tim Perry) #52874 inspector: * (SEMVER-MINOR) introduce the `--inspect-wait` flag (Kohei Ueno) #52734 test_runner: * (SEMVER-MINOR) support test plans (Colin Ihrig) #52860 tools: * (SEMVER-MINOR) fix get_asan_state() in tools/test.py (Joyee Cheung) #52766 * (SEMVER-MINOR) support max_virtual_memory test configuration (Joyee Cheung) #52766 * (SEMVER-MINOR) support != in test status files (Joyee Cheung) #52766 zlib: * (SEMVER-MINOR) expose zlib.crc32() (Joyee Cheung) #52692 PR-URL: #53486
Notable changes: doc: * add pimterry to collaborators (Tim Perry) #52874 inspector: * (SEMVER-MINOR) introduce the `--inspect-wait` flag (Kohei Ueno) #52734 test_runner: * (SEMVER-MINOR) support test plans (Colin Ihrig) #52860 tools: * (SEMVER-MINOR) fix get_asan_state() in tools/test.py (Joyee Cheung) #52766 * (SEMVER-MINOR) support max_virtual_memory test configuration (Joyee Cheung) #52766 * (SEMVER-MINOR) support != in test status files (Joyee Cheung) #52766 zlib: * (SEMVER-MINOR) expose zlib.crc32() (Joyee Cheung) #52692 PR-URL: #53486
Notable changes: doc: * add pimterry to collaborators (Tim Perry) #52874 inspector: * (SEMVER-MINOR) introduce the `--inspect-wait` flag (Kohei Ueno) #52734 test_runner: * (SEMVER-MINOR) support test plans (Colin Ihrig) #52860 tools: * (SEMVER-MINOR) fix get_asan_state() in tools/test.py (Joyee Cheung) #52766 * (SEMVER-MINOR) support max_virtual_memory test configuration (Joyee Cheung) #52766 * (SEMVER-MINOR) support != in test status files (Joyee Cheung) #52766 zlib: * (SEMVER-MINOR) expose zlib.crc32() (Joyee Cheung) #52692 PR-URL: #53486
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.