You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Indicate when a test is started in test_runner #46727
When running tests in an editor (like VS Code), users want to know what test is currently being executed. This is useful, so if a test is hanging for instance, it's easy to see what it is.
What is the feature you are proposing to solve the problem?
we can emit an event on TestsStream for reporters other than TAP to handle it.
if we want to support additional events that TAP doesn't contain we will have to move from tap parsing to some sort of ipc reporter
I have been looking into the files in lib/internal/test_runner. I went through tests_stream.js, seems relevant for this issue. Am I going in the right direction?
Also to clarify, it's required to use a emit start event for reporters other than TAP i.e for dot and spec. I am finding this part confusing.
we can emit an event on TestsStream for reporters other than TAP to handle it. if we want to support additional events that TAP doesn't contain we will have to move from tap parsing to some sort of ipc reporter
I have been looking into the files in lib/internal/test_runner. I went through tests_stream.js, seems relevant for this issue. Am I going in the right direction?
yes
Also to clarify, it's required to use a emit start event for reporters other than TAP i.e for dot and spec. I am finding this part confusing.
why is it required? these reports print to stdout when the test has been completed, not when it starts
Maybe I missed something, but why does the 'test:start' event not handle this use case?
test:start is reported in order, and according to the description of this issue, the request is for an event fired immediately when the tests started and not when it is ready to be reported. @connor4312 correct me if I am wrong?
also, firing such an event without affecting the TAP output will not work with the current implementation and might require first moving to use another serialization method, as we discussed on other issues
OK that makes sense. Having two separate events makes sense, but the fact that start already means something other than "the test is starting" is a confusing API.
Thanks @MoLow. I have made a test:begin (name_to_be_decided) event in the test_streams file since test:start is already being used.
Not sure if I need to make changes in the textual output in the reporters as you mentioned "this means the event will only be usable through the run API but not via one of the existing reporters"
I was going through the docs to see how I can write the setup option (edit:i meant arguments) in the run api in order to emit events. Can someone give me an example. I tried to import the TestsStream object so that I can make a setup function with calls to emit events (if that's how it is done). But for that, I would be using internals which I am not sure a user would be doing. So I guess it's wrong.
Can you give one example on how I can setup custom events using run api.
Now I don't know how that's supposed to be. It's not clear in the docs. Perhaps some examples can be added in the docs for this => On how to use the various options provided with the run api.
Activity
cjihrig commentedon Feb 19, 2023
Printing something probably won't work in all cases - specifically when running tests in parallel.
MoLow commentedon Feb 19, 2023
we can emit an event on
TestsStreamfor reporters other than TAP to handle it.if we want to support additional events that TAP doesn't contain we will have to move from tap parsing to some sort of ipc reporter
connor4312 commentedon Feb 19, 2023
That would work fine for my use case; once #46045 is in I would like to switch to
.run()MoLow commentedon Apr 24, 2023
@connor4312 is this still needed by you?
@RafaelGSS is this a good candidate for Grace Hopper Open Source Day?
connor4312 commentedon Apr 24, 2023
This would still be quite helpful to me and, I believe, most editor integrators.
sankalp1999 commentedon Apr 30, 2023
Hi. I would like to help on this.
sankalp1999 commentedon Apr 30, 2023
I have been looking into the files in lib/internal/test_runner. I went through
tests_stream.js, seems relevant for this issue. Am I going in the right direction?Also to clarify, it's required to use a emit start event for reporters other than TAP i.e for dot and spec. I am finding this part confusing.
MoLow commentedon Apr 30, 2023
yes
why is it required? these reports print to stdout when the test has been completed, not when it starts
sankalp1999 commentedon May 1, 2023
Hello @MoLow. Thanks for the previous reply.
It's not required. My understanding was wrong back then.
I have made a single line change and attached the draft PR.
Here's the output that I am getting currently. Have added a "starting..." string. Would like to know if
this output aligns with the requirement.
4 remaining items
MoLow commentedon May 1, 2023
test:startis reported in order, and according to the description of this issue, the request is for an event fired immediately when the tests started and not when it is ready to be reported. @connor4312 correct me if I am wrong?also, firing such an event without affecting the TAP output will not work with the current implementation and might require first moving to use another serialization method, as we discussed on other issues
cjihrig commentedon May 1, 2023
OK that makes sense. Having two separate events makes sense, but the fact that
startalready means something other than "the test is starting" is a confusing API.MoLow commentedon May 1, 2023
I agree
benjamingr commentedon May 1, 2023
Let's rename it then? It's not too late and now is the time
cjihrig commentedon May 1, 2023
I believe changing the reporter API is considered breaking at this point (but changing the textual output of a reporter is not).
EDIT: Not saying we shouldn't do it though.
sankalp1999 commentedon May 2, 2023
Thanks @MoLow. I have made a test:begin (name_to_be_decided) event in the test_streams file since test:start is already being used.
Not sure if I need to make changes in the textual output in the reporters as you mentioned "this means the event will only be usable through the run API but not via one of the existing reporters"
sankalp1999 commentedon May 2, 2023
I was going through the docs to see how I can write the setup option (edit:i meant arguments) in the run api in order to emit events. Can someone give me an example. I tried to import the TestsStream object so that I can make a setup function with calls to emit events (if that's how it is done). But for that, I would be using internals which I am not sure a user would be doing. So I guess it's wrong.
Can you give one example on how I can setup custom events using run api.
Now I don't know how that's supposed to be. It's not clear in the docs. Perhaps some examples can be added in the docs for this => On how to use the various options provided with the run api.
sankalp1999 commentedon May 2, 2023
I think we should add one import/require statement atleast for run api in the docs.
const { run } = require('node:test');sankalp1999 commentedon May 2, 2023
Another candidate for doc change. It says "Emitted when a test starts." which is inconsistent based on what we discussed above.

sankalp1999 commentedon May 8, 2023
hi @MoLow . can you have look at the above comments.
MoLow commentedon May 8, 2023
@sankalp1999 the doc changes make sense indeed
test_runner: emit start event when subtest starts