-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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: differentiate test types in enqueue dequeue events #54049
base: main
Are you sure you want to change the base?
test_runner: differentiate test types in enqueue dequeue events #54049
Conversation
Review requested:
|
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.
Thanks for opening a PR! Can you please add a unit test?
Sure, I added one. |
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
doc/api/test.md
Outdated
@@ -2850,6 +2850,7 @@ The corresponding declaration ordered events are `'test:pass'` and `'test:fail'` | |||
`undefined` if the test was run through the REPL. | |||
* `name` {string} The test name. | |||
* `nesting` {number} The nesting level of the test. | |||
* `type` {string} The test type. |
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 don't think these docs are currently descriptive enough. Since there are only two possible values, maybe we should list them out.
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 updated the docs, but I had some trouble thinking of how to phrase it.
lib/internal/test_runner/test.js
Outdated
@@ -570,7 +570,8 @@ class Test extends AsyncResource { | |||
while (this.pendingSubtests.length > 0 && this.hasConcurrency()) { | |||
const deferred = ArrayPrototypeShift(this.pendingSubtests); | |||
const test = deferred.test; | |||
test.reporter.dequeue(test.nesting, test.loc, test.name); | |||
const type = test.reportedType ?? 'test'; |
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 think we should make reportedType
a property on Test
like it is on Suite
and drop this.
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.
Do you think we should also a reported type on the TestHook
class since it extends Test
? I don't think it'll cause any issues, but could lead to future confusion.
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 set reportedType
on TestHook
to 'hook'
.
test/parallel/test-runner-run.mjs
Outdated
|
||
stream.on('test:enqueue', common.mustCall((data) => { | ||
if (data.name === 'this is a suite') { | ||
assert.strictEqual(data.type, 'suite'); |
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.
There is no guarantee that any of these assertions will run, even with the common.mustCall()
(for example, if the test fixture was changed in the future). I would suggest adding a test plan.
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.
Sounds good, but I'm not familiar with what a test plan is. Is there an example I could reference?
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.
Oh, you meant this: https://nodejs.org/api/test.html#contextplancount
Good call. I added a plan and it uncovered two of the assertions weren't working due to a leading space in the name.
This PR seems like it may have stagnated. Is there anything needed to get it merged? |
Hey @EddieAbbondanzio, I noticed this PR has been stale since August and some files now have conflicts. |
Hey @pmarchini, I can work on bring it back but do you know why it went stale? Was there something else I needed to do to get it merged after all the approvals it got back in July? |
Hey @EddieAbbondanzio, honestly, I can't see any reason why this PR should remain stalled. |
32c6955
to
56c63e1
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #54049 +/- ##
==========================================
- Coverage 88.54% 88.54% -0.01%
==========================================
Files 657 657
Lines 190742 190746 +4
Branches 36606 36603 -3
==========================================
- Hits 168901 168888 -13
- Misses 15027 15039 +12
- Partials 6814 6819 +5
|
Hey @pmarchini, is there anything on my end I need to do to merge this? I'm still new to contributing to Node and don't have permissions to add the merge-queue label (seems like that's what this PR needs based on the docs) but I'm also not 100% certain why some of the CI jobs are intermittently failing. Appreciate your help! |
Hey @EddieAbbondanzio, you can't do anything else on your side atm 😁 As soon as the CI is green, and if @cjihrig and @MoLow are still okay with this change, we will land it 🚀 Thank you very much for your patience and your support to Node 🚀 |
The
test:enqueue
andtest:dequeue
events now include atype
indetails
to allow reporters to distinguish if it was a suite or test.Fixes #51235