jest: #5585 breaks pre-established "beforeEach" order
When 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.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (14 by maintainers)
Commits related to this issue
- fix(treeProcessor): revert a small change from the #5585 refactoring fixes #5964 moves the `wrapChildren` into higher scope to restore undocumented execution order — committed to niieani/jest by niieani 6 years ago
- fix(treeProcessor): revert a small change from the #5585 refactoring (#6006) fixes #5964 moves the `wrapChildren` into higher scope to restore undocumented execution order — committed to jestjs/jest by niieani 6 years ago
- feat(jest-jasmine2): introduce legacyExecutionOrder flag to enable undocumented execution order We do not set the currentDeclarationSuite upon node start in order to keep a legacy, undocumented order... — committed to niieani/jest by niieani 6 years ago
- feat(jest-jasmine2): introduce legacyExecutionOrder flag to enable undocumented execution order We do not set the currentDeclarationSuite upon node start in order to keep a legacy, undocumented order... — committed to niieani/jest by niieani 6 years ago
- feat(jest-jasmine2): introduce legacyExecutionOrder flag to enable undocumented execution order We do not set the currentDeclarationSuite upon node start in order to keep a legacy, undocumented order... — committed to niieani/jest by niieani 6 years ago
@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 🙂I’m OK with moving the
wrapChildren
to the outer scope; I can also perform a quick test with your change internally and see if everything results in the expected behavior. 🙂No, you are right, whatever the behavior is, it should always be the same.
@rickhanlonii this is in the latest alpha only.