execution order difference between jest-jasmine2 and jest-circus
See original GitHub issue🐛 Bug Report
https://jestjs.io/docs/en/setup-teardown#order-of-execution-of-describe-and-test-blocks manual says execution order of describe and test blocks should be
describe('outer', () => {
console.log('describe outer-a');
describe('describe inner 1', () => {
console.log('describe inner 1');
test('test 1', () => {
console.log('test for describe inner 1');
expect(true).toEqual(true);
});
});
console.log('describe outer-b');
test('test 1', () => {
console.log('test for describe outer');
expect(true).toEqual(true);
});
describe('describe inner 2', () => {
console.log('describe inner 2');
test('test for describe inner 2', () => {
console.log('test for describe inner 2');
expect(false).toEqual(false);
});
});
console.log('describe outer-c');
});
// describe outer-a
// describe inner 1
// describe outer-b
// describe inner 2
// describe outer-c
// test for describe inner 1
// test for describe outer
// test for describe inner 2
while this is true for jest-jasmine2 In jest-circus, it is not work as expected
PASS test.js
outer
✓ test 1 (16ms)
describe inner 1
✓ test 1 (3ms)
describe inner 2
✓ test for describe inner 2 (6ms)
console.log test.js:2
describe outer-a
console.log test.js:5
describe inner 1
console.log test.js:12
describe outer-b
console.log test.js:20
describe inner 2
console.log test.js:27
describe outer-c
console.log test.js:15
test for describe outer
console.log test.js:7
test for describe inner 1
console.log test.js:22
test for describe inner 2
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 2.371s
To Reproduce
Just use same source in manual with jest-jasmine2 or jest-circus
Expected behavior
execution order must be same
Link to repl or repo (highly encouraged)
none
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Jest 27: New Defaults for Jest, 2021 edition
There may be minor differences in execution order and strictness, but we expect no major upgrade difficulties other than for code relying on ......
Read more >Jest/Jasmine: Weird Execution Order Of beforeEach()
[This answer is relevant for both Jest and Jasmine!] The error in the example above is a misunderstanding of how nesting describe ,...
Read more >jest-repl: Versions | Openbase
[expect] [BREAKING] Differentiate between MatcherContext MatcherUtils and MatcherState types (#13141); [jest-circus] Add support for test.failing.each ...
Read more >Jest Setup Guide | Detox
The former runner, jest-jasmine2 , is deprecated due to specific bugs in the ... are relevant for jest@^27.0.0 (and jest@^26.0.1 + jest-circus@^26.0.1 )....
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

Currently implementing this, slightly scared by the fact that there seems to be no existing test failing because of it 😄 But maybe it makes sense nobody has written this, we’re probably so used to writing order-independent tests that we don’t even think of any execution order as a requirement.
I would prefer the behavior of jasmine2. In my use case I use
describeto organize larger tests that can be split, while the order still matters.E.g.:
#fordescribeand*fortest.