fix(jest-circus): improve test.concurrent #12748
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This change is a minor rewrite of the implementation of
test.concurrent
in jest-circus. It moves the test function invocation to a later point in time, so that it would be possible to apply proper test filtering (focused tests,testNamePattern
,describe.skip
). Previously such filtering was not applied to concurrent tests and they were always invoked.Additionally, concurrent tests are now invoked after the global (top-level)
beforeAll
hooks. Previously this was not the case.Finally,
beforeEach
andafterEach
hooks are no longer invoked for concurrent tests at all. Previously both hooks were invoked after (or during) the test.Test plan
Some existing tests for
concurrent
have been modified to verify the changes described above.An illustrative example:
jest -t "test B"
Before:
After:
Fixes #4281
Fixes #10790
Fixes #11248
Fixes #12068
Fixes #12588