Conversation
✅ Deploy Preview for h-test ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
- Maintain proper sequencing when hooks (`beforeEach`/`afterEach`, `beforeAll`/`afterAll`) are used - Fall back to parallel execution (using `Promise.all`) when no hooks exist
0e781ba to
bb421d6
Compare
LeaVerou
left a comment
There was a problem hiding this comment.
The way I see it, we can still do parallel execution with these, as long as:
- For each test, beforeEach is always executed before run and afterEach after run
- beforeAll and afterAll are executed before and after all tests (regardless of their order)
You are absolutely right. Previously, I was confused seeing |
c74c65c to
ef3fef1
Compare
LeaVerou
left a comment
There was a problem hiding this comment.
This looks a bit too complicated and I have some reservations about whether the complexity is necessary, but I may be missing some of the nuances of this part of the code.
allFinishedis added dynamically, which means it could not be present when awaited from another part of the code- if
runAll()resolves when all tests have ran, why do we needallFinished? Can't we justPromise.allSettled()its result? - Remember that in theory, tests can be run in isolation, without running the whole group. At first glance it seems to me that this wouldn't run beforeAll/afterAll, but I didn't look too closely.
What an excellent feedback (as always)! Thank you. I tried to address it:
I'll be grateful if you could find some time to review this PR one more time. |
beforeEach/afterEach,beforeAll/afterAll) are usedPromise.all) when no hooks existNow, we might end up (I already was bit by this bug) calling
afterAllbeforeafterEachfor some tests. In most cases,beforeEachfor all tests is called before the first test runs. There are probably some more issues we haven't encountered yet. This PR should fix those bugs.