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.

beforeAll: not skipped within describe.skip

See original GitHub issue

🐛 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:

  System:
    OS: Windows 10
    CPU: x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
  Binaries:
    Yarn: 1.2.1 - ~AppData\Roaming\npm\yarn.CMD
    npm: 6.0.0 - C:\Program Files\nodejs\npm.CMD

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mlopezluquecommented, Jul 24, 2018

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.
0reactions
github-actions[bot]commented, May 12, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

beforeAll: not skipped within describe.skip (again) · Issue #8379
Bug Report beforeAll functions are run even when defined inside of a describe.skip block. To Reproduce Define a describe.skip block.
Read more >
How to skip all tests if beforeAll failed? Using Jasmine and ...
1 Answer 1 · I've tried protractor-fail-fast but in the case when beforeAll fails - the first it in the file still marked...
Read more >
Globals - Jest
Beware that the describe block will still run. If you have some setup that also should be skipped, do it in a beforeAll...
Read more >
Setup and teardown - Pester
BeforeAll is used to share setup among all the tests in a Describe / Context including all child blocks and tests. BeforeAll runs...
Read more >
Mocha documentation — DevDocs
This will skip all it , beforeEach/afterEach , and describe blocks within the suite. before/after hooks are skipped unless they are defined at...
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