-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_runner: allow nesting test within describe #46544
test_runner: allow nesting test within describe #46544
Conversation
Review requested:
|
Maybe |
In fact... for |
describe builds the test tree before running it, to aviod the need of adding an |
That... it's a reason, maybe that detail should be clarified in the docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if the CI passes.
@@ -167,7 +167,8 @@ function getGlobalRoot() { | |||
} | |||
|
|||
function test(name, options, fn) { | |||
const subtest = getGlobalRoot().createSubtest(Test, name, options, fn); | |||
const parent = testResources.get(executionAsyncId()) || getGlobalRoot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can't we use ??
here?
@@ -309,12 +312,12 @@ describe('describe async throw fails', async () => { | |||
describe('timeouts', () => { | |||
it('timed out async test', { timeout: 5 }, async () => { | |||
return new Promise((resolve) => { | |||
setTimeout(resolve, 1000); | |||
setTimeout(resolve, 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these setTimeouts use common platform timeout machinery or are you convinced there is no/little flakiness potential here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have already changed these values in the equivalent test
recipe test
node/test/message/test_runner_output.js
Line 116 in 5092346
}, 100); |
Landed in 2787e2d |
PR-URL: nodejs#46544 Fixes: nodejs#46478 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#46544 Fixes: nodejs#46478 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#46544 Fixes: nodejs#46478 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#46544 Fixes: nodejs#46478 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs/node#46544 Fixes: nodejs/node#46478 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> (cherry picked from commit 2787e2dfc2e10c584259ff34d7aad565447a84d9)
Fixes: #46478
although initially
test
anddescribe
were not meant to be used together I see no reason why not to allow this,as the use case demonstrated in #46478 (comment) is valid.
additionally, other test runners such as playwright and mocha also support this.
another outcome of this change is that running a nested
test
withintest
will now work the same wayt.test
did previously, wich sounds reasonable to me as well