Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beforeAll: not skipped within describe.skip (again) #8379

Closed
Rendez opened this issue Apr 25, 2019 · 14 comments · Fixed by #9931
Closed

beforeAll: not skipped within describe.skip (again) #8379

Rendez opened this issue Apr 25, 2019 · 14 comments · Fixed by #9931

Comments

@Rendez
Copy link

Rendez commented Apr 25, 2019

🐛 Bug Report

beforeAll functions are run even when defined inside of a describe.skip block.

To Reproduce

  • Define a describe.skip block.
  • Define a beforeAll inside the describe.skip block.
    Do something within the beforeAll function to confirm that it does or does not get run (e.g. add a console.log statement, set some flag, etc.).

Expected behavior

The function registered by the beforeAll is never executed.

This bug was reported in #6166 and fixed in #6234, but it reappeared.

Link to repl or repo (highly encouraged)

https://codesandbox.io/s/74xr2vrpnj (use the Tests tab)

Jest runs via react-scripts at this version: https://github.com/facebook/create-react-app/blob/v2.1.8/package.json#L28

@weworkwithzoh
Copy link

I too am seeing this.

@holograph
Copy link

Yep, experiencing this too, it's pretty consistent (full disclosure: I work with @weworkwithzoh)

@EKoetsjarjan
Copy link

beforeAll() , always runs
$ jest -v
24.8.0
upvote please

@EKoetsjarjan
Copy link

Hi, I have created this workaround, by adding a additioinal flag

is it possible to get the skipped flag from the jest context?

describe.skip('Testing confirmations', () => {
   var skip = false //bug beforeAll is always run even when skipped, do it this way  
   beforeAll(async () => {
             if(skip)return
       ....
       });

  test('Testing ', () => {
        /////.....
  });

});

@WestonThayer
Copy link

This is especially painful when using Jest for functional tests that do some heavy lifting in beforeAll. For example, writing some Selenium tests that work with a service like Browserstack. In beforeAll, you'd usually create a new WebDriver that's connected to their service, which takes a while. I'm forced to comment out tests I don't wan to run, otherwise they slow down my workflow significantly.

@WestonThayer
Copy link

If anyone is looking for an easy substitute for .skip, just create a new dummy function at the top of your file, like:

const describeSkip = () => {}

Then append Skip instead of .skip.

@ihorfito
Copy link

up

@rogeliog
Copy link
Contributor

rogeliog commented Dec 2, 2019

Quick question, does running it with jest-circus fixes the issue?

@holograph
Copy link

holograph commented Dec 2, 2019 via email

@cotispear
Copy link

If anyone is looking for an easy substitute for .skip, just create a new dummy function at the top of your file, like:

const describeSkip = () => {}

Then append Skip instead of .skip.

Unfortunately we have an entire test suite that we want to be conditionally skipped. This "works", but Jest fails with:

Your test suite must contain at least one test

So we have to include a dummy describe(). 😢

@enriqu3l
Copy link

enriqu3l commented Feb 5, 2020

Any update here?

As far as I know, this was a previous bug that appeared again.

Currently I am using the workaround of adding if(skip)return inside of beforeAll.

@EKoetsjarjan
Copy link

Any update here?

As far as I know, this was a previous bug that appeared again.

Currently I am using the workaround of adding if(skip)return inside of beforeAll.

me too

@brianseeders
Copy link

+1 seeing the same issue on 25.1.0, MacOS, node 12.16.1.

Started seeing failed tests in CI in our junit reports for skipped tests, and it turned out to be this issue.

tylersmalley pushed a commit to tylersmalley/kibana that referenced this issue Mar 2, 2020
Jest will run the hooks regardless of if they are skipped.

Tests skipped in
elastic@61c9dc4
and
elastic@420ded8
were still resulting in build failures due to the beforeEach failing.

jestjs/jest#8379

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants