When using test.concurrent with tests, all the scenarios run first and then the beforeEach and afterEach blocks run next.
Write a simple test suite with a beforeEach , 3 tests using test.concurrent, and afterEach.
I expect runner to execute beforeEach block, then the test, then afterEach block.
Issues without a reproduction link are likely to stall.
npx envinfo --preset jestPaste the results here:
Jest v22.1.2 node v7.4.0 linux/amd64
PASS ./concurrent-test.js
try running parallel by scenario level
✓ First Test (3ms)
✓ Second Test
✓ Third Test (1ms)
console.log concurrent-test.js:8
Test 1
console.log concurrent-test.js:12
Test 2
console.log concurrent-test.js:16
Test 3
console.log concurrent-test.js:4
BEFORE
console.log concurrent-test.js:20
AFTER
console.log concurrent-test.js:4
BEFORE
console.log concurrent-test.js:20
AFTER
console.log concurrent-test.js:4
BEFORE
console.log concurrent-test.js:20
AFTER
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 0.993s, estimated 1s
Ran all test suites.
https://github.com/facebook/jest/issues/4281 dupliacted issue
it would be very nice if jest fix it
Think this is the RCA
jest-circus
jest-jasmine
https://github.com/facebook/jest/blob/c9c8dba4dd8de34269bdb971173659399bcbfd55/packages/jest-jasmine2/src/jasmineAsyncInstall.ts#L172-L176
@SimenB It seems easy to change the workflow in jest-circus to fix this, I've made a POC. Let me know if this approach would be a good solution
But not sure if Before and After make sense for test.concurrent, if I perform a stateful operation in the hooks then the tests will be indeterministic
@Mark1626 beforeEach and afterEach might not make a ton of sense for test.concurrent, but beforeAll and afterAll would I think.
@SimenB bump
Please fix.