-
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:start events are not emitted correctly #51907
Comments
I looked into enqueue and dequeue a bit more. I thought I could use them and just say "the top of the queue is currently running", but it that doesn't work with a more complex case. Take a file like: describe('math', () => {
it('addition', async () => {
await new Promise((resolve) => setTimeout(resolve, 5000));
strictEqual(1 + 1, 2);
});
it(`subtraction`, async () => {
strictEqual(1 - 1, 0);
});
});
describe('math2', () => {
it('addition', async () => {
await new Promise((resolve) => setTimeout(resolve, 5000));
strictEqual(1 + 1, 2);
});
it(`subtraction`, async () => {
strictEqual(1 - 1, 0);
});
}); The order of enqueues and dequeues seems pretty inscrutable. I was hoping it would be an order of enqueues and dequeues matching how they're declared in the file, but this isn't the case. For example the test cases inside
|
Thanks for opening the issue. I'll try to take a look later this week |
@connor4312 I am not sure what is the bug here |
the timing of different events are: the reason the events are designed this way is there was originally only the tap reporter which needed things in order (and it is convenient for other reporters to not have to maintain the order themselves).
@connor4312 will these items resolve your issue? |
Ahh, I see! The dequeued events makes sense now. It looks like the order is also preserved even when tests run in parallel, so I think that would solve my use case.
This would be a nice to have just to report results more quickly to users.
This would be handy! I'll play with these some more this evening and close out the issue unless I run into any further difficulty 🙂 |
PR-URL: #51909 Fixes: #51907 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
PR-URL: nodejs#51909 Fixes: nodejs#51907 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
PR-URL: #51909 Fixes: #51907 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
Version
21.6.2
Platform
windows x64
Subsystem
test_runner
What steps will reproduce the bug?
test.js
and a reporter.js
node --test-reporter=./reporter.js test.js
How often does it reproduce? Is there a required condition?
100%
What is the expected behavior? Why is that the expected behavior?
test:start
should be fired beforemath addition
is runWhat do you see instead?
test:start
is fired only after the test finishes. Here's an example log, notice that test:started is fired only after the 5 second delay, which is in fact after the tests already finished.log.txt
Additional information
I originally requested this in #46727 which resulted in test:queued and test:dequeued events being added. (Maybe this should be titled instead a general "I (still) cannot tell when a test is started")
However these are not useful because the tests are just enqueued event when they're not running:
subtraction
is enqueued alongsideaddition
and based on the results it 'takes' 5 seconds to run, but in reality is instant.The text was updated successfully, but these errors were encountered: