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

test state is in "pending" when beforeAll failed #4820

Closed
6 tasks done
hi-ogawa opened this issue Dec 29, 2023 · 3 comments · Fixed by #6524
Closed
6 tasks done

test state is in "pending" when beforeAll failed #4820

hi-ogawa opened this issue Dec 29, 2023 · 3 comments · Fixed by #6524
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Dec 29, 2023

Describe the bug

I'm creating a dedicated issue based on the discussion in #4799 (comment)

Current behavior seems to be that the test state is kept in "pending" when beforeAll failed, but the desired behavior might be to mark those tests as "skipped".

Here is a repro and a screenshot of Vitest UI:

https://stackblitz.com/edit/vitest-dev-vitest-yr2mrp?file=test%2Frepro.test.ts

Show screenshot

image

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-yr2mrp?file=test%2Frepro.test.ts

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.10.5 - /usr/local/bin/pnpm
  npmPackages:
    @vitest/ui: latest => 1.1.0 
    vite: latest => 5.0.10 
    vitest: latest => 1.1.0

Used Package Manager

npm

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Jan 3, 2024

That is an interesting dilemma. I decided to look into what other runners do (https://github.com/sheremet-va/test-before):

  1. @playwright/test fails the first test and marks all subsequent tests as "skipped"
  2. jest fails every test that doesn't have "skip" modifier - every test has errors populated (even skipped ones), but the test status stays "pending"
  3. mocha doesn't even register any tests, only failures (looking at json output) - it does show "before all" hook for "<name of the first test>" in the terminal
  4. tap is similar to mocha - only the first test (named assert) is marked as failed, all others are not even collected
  5. node:test marks every test as a failed one if an error is thrown inside before (it has a special "cancelled" state that is shown as a failing test) - output is similar to jest (every test shows an error "test did not finish before its parent and was cancelled" even if it has { skip: true }, but it's counted as skipped

@AlexPaven
Copy link

Was there ever a decision on this? I'm guessing no, since I still see tests in pending state when beforeAll fails. I'm thinking of switching to fixtures which seem to have better behavior and feel, but it's not exactly equivalent to beforeAll, since they get reinitialized for every test - am I right in saying that?

@sheremet-va sheremet-va added the p2-to-be-discussed Enhancement under consideration (priority) label Aug 15, 2024
@sheremet-va sheremet-va moved this to P2 - 3 in Team Board Sep 6, 2024
@sheremet-va sheremet-va moved this from P2 - 3 to Approved in Team Board Sep 12, 2024
@sheremet-va sheremet-va added p3-minor-bug An edge case that only affects very specific usage (priority) and removed discussion p2-to-be-discussed Enhancement under consideration (priority) labels Sep 12, 2024
@sheremet-va
Copy link
Member

since they get reinitialized for every test - am I right in saying that?

Yes


We decided to mark tests in the suite as skipped if beforeAll fails

@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants