Too aggressive in declaring the test "finished"
See original GitHub issueThe following works in 0.18.2
:
test(t => {
t.notThrows(new Promise(resolve => {
setTimeout(() => {
t.pass();
resolve();
}, 100);
}));
});
On master, it fails with:
Assertion passed, but test has already ended
We should wait until all pending assertions have resolved before declaring a test “finished” and throwing when new assertions show up.
Adding a call to t.plan()
causes it to behave oddly going all the way back (we even added a test solidifying this odd behavior in #360):
test(t => {
t.notThrows(new Promise(resolve => {
t.plan(2);
setTimeout(() => {
t.pass();
resolve();
}, 100);
}));
});
The above fails with:
Planned for 2 assertions, but got 1.
Similar results for as far back as I tested.
I think we should allow for added assertions, as long as we still have pending assertions. When t.plan
is used, I don’t think we should check for too few assertions until we’ve drained all pending assertions.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Joe Root century sets up aggressive declaration in Antigua
Joe Root scored his 24th Test century to go second on England's all-time list before a brave declaration left the West Indies chasing...
Read more >Dhoni's declaration leaves Bridgetown Test nicely poised | New ...
It is a matter of debate whether India should have been more aggressive with the bat on Day Four when Rahul Dravid and...
Read more >The Brilliance and Weirdness of ChatGPT - The New York Times
But there are risks to testing in public, including the risk of backlash if users deem that OpenAI is being too aggressive in...
Read more >UPDATE 2-Cricket-Test Series Bangladesh v Pakistan ...
UPDATE 2-Cricket-Test Series Bangladesh v Pakistan scoreboard ... All quotes delayed a minimum of 15 minutes. See here for a complete list of ......
Read more >TikTok's Problem Child Has 7 Million Followers and One ...
Her mom, Maria Ulacia, found it funny, too. ... in a post that generated 3 million views, declaring in a caption “these are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I already always do:
Instead of:
The former is clearer by being explicitly async. It’s easier to add stuff after the throws assertion and get expected order of execution. You can get the error without having to change things around. Simpler to document.
How would we enforce that? Can you tell a function is
async
before calling it?