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 #6166

Closed
mfulton26 opened this issue May 10, 2018 · 6 comments
Closed

beforeAll: not skipped within describe.skip #6166

mfulton26 opened this issue May 10, 2018 · 6 comments

Comments

@mfulton26
Copy link

🐛 Bug Report

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

To Reproduce

  1. Define a describe.skip block.
  2. Define a beforeAll inside the describe.skip block.
  3. 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.

Link to repl or repo (highly encouraged)

https://repl.it/repls/UsableBurlyJavascript

Run npx envinfo --preset jest

Paste the results here:

  �[4mSystem:�[0m
    OS: Windows 10
    CPU: x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
  �[4mBinaries:�[0m
    Yarn: 1.2.1 - ~AppData\Roaming\npm\yarn.CMD
    npm: 6.0.0 - C:\Program Files\nodejs\npm.CMD
@harryttd
Copy link

This happens with afterAll as well. beforeEach and afterEach do not have this problem.

@niieani
Copy link
Contributor

niieani commented May 16, 2018

This should be easy to fix.
beforeAll and afterAll are executed here:

https://github.com/facebook/jest/blob/7f74710e7faa089f663935c13d7a37cb7d06325b/packages/jest-jasmine2/src/tree_processor.js#L79

It seems there's currently no logic checking whether it should be executed or not.

We should probably check if enabled, although not sure how this might behave when doing forced executions (fdescribe and fit).

@SimenB
Copy link
Member

SimenB commented May 16, 2018

Older issue, which this might be a dupe of: #4820

Includes a link to Jasmine's fix of the same bug, which we were unable to port

@SimenB
Copy link
Member

SimenB commented May 30, 2018

#6234

@SimenB SimenB closed this as completed May 30, 2018
@mlopezluque
Copy link

This issue still remains when using the default jasmine2 runner.

I've made this gist with the same code as the issue's repl using the latest version from Jest.

Output

Default jasmine2 runner

 jest

 FAIL  ./test.js
  ✕ should be skipped (8ms)
  Skipped suite
    ○ skipped 1 test
    Inner
      ○ skipped 1 test

  ● should be skipped

    expect(received).toBe(expected) // Object.is equality

    Expected: true
    Received: false

      15 |
      16 | test("should be skipped", function() {
    > 17 |   expect(skipped).toBe(true);
         |                   ^
      18 | });
      19 |

      at Object.<anonymous> (test.js:17:19)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 2 skipped, 3 total
Snapshots:   0 total
Time:        1.017s
Ran all test suites.

Using jest-circus

Installing jest-circus and running the same gist with JEST_CIRCUS=1 produces the following output:

> jest

 PASS  ./test.js
  ✓ should be skipped (3ms)
  Skipped suite
    ○ skipped 1 test
    Inner
      ○ skipped 1 test

Test Suites: 1 passed, 1 total
Tests:       2 skipped, 1 passed, 3 total
Snapshots:   0 total
Time:        0.984s, estimated 1s
Ran all test suites.

@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 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants