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 block runs even if it is inside a describe.skip block

See original GitHub issue

🐛 Bug Report

image

To Reproduce

describe.skip('CommentsSummaryEmail', () => {
  beforeAll(async () => {
    console.log('WTF are you doing jest')
  })
  it('should whatever', async () => {
    expect(0).toBe(0)
  })
  it.todo(
    `it whateves`
  )
})

Expected behavior

none of the block inside describe.skip run

Link to repl or repo (highly encouraged)

envinfo

  System:
    OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
  Binaries:
    Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v12.14.1/bin/npm
  npmPackages:
    jest: ^26.4.2 => 26.4.2 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sarathps93commented, Nov 10, 2020

Thanks @SimenB . I have done the fixes and will raise a PR after adding few unit tests. I have addressed the below issues in both jest-circus & jest-jasmine2

  1. beforeAll block runs even if it is inside a describe.skip block when the it block contains tests marked as todo or only
  2. it tests run even if it is inside a describe.skip when the it tests are marked as todo or only
1reaction
cdoublevcommented, Nov 3, 2020

Side note: beforeEach also runs (when nested in a describe.skip).

EDIT: beforeEach is skipped as expected, sorry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to control order of execution of beforeAll blocks in ...
I have a main test with sub-tests which follows the following structure: describe('main test', () => { describe('happy path', ...
Read more >
Setup and Teardown - Jest
By default, the beforeAll and afterAll blocks apply to every test in a file. You can also group tests together using a describe...
Read more >
BeforeAll - Pester
BeforeAll is used to share setup among all the tests in a container, Describe or Context including all child blocks and tests. BeforeAll...
Read more >
API Reference | Vitest
Use describe.skip in a suite to avoid running a particular describe block. ts
Read more >
Globals - Jest 中文文档
If beforeEach is inside a describe block, it runs for each test in the describe block. If you only need to run some...
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