-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
Revert https://github.com/nodejs/node/pull/56664 #58282
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
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
Hey @romainmenke , thanks for your contribution! Regarding the content of the PR: I think that, as the behaviour has already been implemented, it would be reasonable to try to make this behaviour configurable via a flag. |
I think it is also reasonable to consider a straight up revert :) As I said in the pull request message, I don't think the change was sufficiently argued for.
Happy to look at this, but unsure how to proceed. |
Sorry, I only just noticed that the original PR landed without a squash commit!
I'd like to collect some feedback from @MoLow, @cjihrig, @jakecastelli, and @atlowChemi too! |
Could you give an example of something that no longer works with the new behavior in #51292, with a link to this PR? That should give everyone who participated in that issue a notification so they can participate in this discussion |
See: #51292 (comment) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #58282 +/- ##
=======================================
Coverage 90.18% 90.18%
=======================================
Files 631 631
Lines 186689 186665 -24
Branches 36663 36665 +2
=======================================
- Hits 168359 168343 -16
+ Misses 11128 11118 -10
- Partials 7202 7204 +2
🚀 New features to boost your workflow:
|
I think we should avoid reverting this feature and instead explore an idea that aligns with the current direction: the addition of a Here’s an example, based on what you shared in the other issue, of what it could look like using steps: import { test } from 'node:test';
import assert from 'node:assert';
test('outer', async (t1) => {
let a = 1;
let b = 1;
// Run a first sub test
t1.test('inner 1', async (t2) => {
await new Promise((resolve) => setTimeout(resolve, 1000));
assert.equal(a, b);
t2.after(async () => {
await new Promise((resolve) => {
b = 2;
resolve();
});
});
});
// Do some async workload in between sub tests
t1.step('async workload', async () => new Promise((resolve) => {
b = 2;
resolve();
}));
// Run a second sub test
t1.test('inner 2', async () => {
// Run some extra asserts
assert.equal(b, 2);
});
}); Something like this could potentially address the issue while avoiding the reintroduction of the discrepancy between |
Such new API doesn't really help when we still support a wide range of node versions. I also honestly do not understand how this change got through in the first place. Before the change made in #56664 it was possible to intuitively and organically add sub tests in between existing code. Or to add some non-test code in between sub tests After #56664 you have to be very careful that in a given test you either have only sub tests or only non-sub test code. You can no longer interleave these without race conditions. This is clearly bad, right? I really liked that |
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
I concur on a quick revert. |
@romainmenke can you please amend the other tests that are failing? |
Tests are failing on GHA, I don't think it makes sense to run Jenkins CI now |
As far as I can tell, it seems that #57672 is the origin of the failing tests (cc @jakecastelli). You can do it via Unfortunately, I just tried and it seems that the behavior introduced by #57672 is broken after the revert. |
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.
I agree the previous behavior was more sane
Being able to
await
sub tests and orchestrate the order of sub tests and other async functions was no longer possible after #56664I think this was an obvious mistake.
As far as I understand from #51292 the original issue was that sometimes people get linter nags.
No one actually sufficiently argued that the previous behavior was either wrong or not a useful capability.
I suggest the changes are reverted to restore the previous capabilities.
Being able to await sub tests was a really useful feature.
The linter concerns should be secondary to the capabilities of
node:test