#5585 breaks pre-established "beforeEach" order
See original GitHub issueWhen introduced #5885, the order of beforeEach
s was inverted. Take the following test for instance:
describe('test', () => {
beforeEach(() => {
console.log('BeforeEach');
});
it('foo', () => {
console.log('It Foo');
beforeEach(() => {
console.log('BeforeEach Inline Foo');
});
});
it('bar', () => {
console.log('It Bar');
beforeEach(() => {
console.log('BeforeEach Inline Bar');
});
});
});
The order should be:
BeforeEach
It Foo
BeforeEach Inline Foo
BeforeEach
It Bar
But it is instead:
BeforeEach
It Foo
BeforeEach
BeforeEach Inline Foo
It Bar
One might argue about beforeEach
s inside it
s, but the reality is that this is supported and the current order is altered. We need to get some sort of fix or rather revert the PR.
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (13 by maintainers)
Top Results From Across the Web
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 >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 FreeTop 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
Top GitHub Comments
@mjesun Oh man, I thought testing it internally meant you’ll do it 😉 So once again we misunderstood each other. Here’s a PR: https://github.com/facebook/jest/pull/6006
Looking forward to seeing it that fixes the issue.
Oh, I was waiting for the change 😅I need to merge and create
alpha.7
, then I can test it internally. I agree it was confusing 🙂