question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

#5585 breaks pre-established "beforeEach" order

See original GitHub issue

When introduced #5885, the order of beforeEachs 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 beforeEachs inside its, 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:closed
  • Created 5 years ago
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
niieanicommented, Apr 16, 2018

@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.

2reactions
mjesuncommented, Apr 13, 2018

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 🙂

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found