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

Custom fixture teardown isn't called #4251

Closed
6 tasks done
ben-styling opened this issue Oct 5, 2023 · 3 comments · Fixed by #4250
Closed
6 tasks done

Custom fixture teardown isn't called #4251

ben-styling opened this issue Oct 5, 2023 · 3 comments · Fixed by #4250
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@ben-styling
Copy link

Describe the bug

The docs suggest using text.extend will allow setup and teardown within the fixture.

https://github.com/vitest-dev/vitest/blob/main/docs/guide/test-context.md#usage

I may have set this up incorrectly, but the teardown doesn't seem to fire after the test finishes.

Reproduction

Stackblitz reproduction, instructions to see error in README.md

https://stackblitz.com/edit/node-3ln3ly?file=.stackblitzrc,example.test.ts,package.json,todos.json,README.md

System Info

System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 107.80 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 20.5.0 - ~/.nvm/versions/node/v20.5.0/bin/node
    npm: 10.1.0 - ~/node_modules/.bin/npm
    pnpm: 8.8.0 - ~/Library/pnpm/pnpm
    Watchman: 2023.08.28.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 117.0.5938.88
    Safari: 16.3
  npmPackages:
    vite: ^4.4.11 => 4.4.11 
    vitest: ^0.34.6 => 0.34.6

Used Package Manager

pnpm

Validations

@sheremet-va
Copy link
Member

This looks like a bug! @Dunqing 👀

@sheremet-va sheremet-va added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Oct 5, 2023
@ben-styling
Copy link
Author

After a bit of digging, it looks like it might be related to this change #4168 as this works in the last patch.

I would have expected this test to catch this bug! https://github.com/vitest-dev/vitest/blob/ec2e80406555d1eaceefc261d7a50675c2363882/test/core/test/test-extend.test.ts#L303C21-L303C21

@Dunqing
Copy link
Member

Dunqing commented Oct 5, 2023

This is a bug and will fixed in #4250. I added a test case about this issue. Also, there is a workaround for you can write a test inside describe will work

@github-actions github-actions bot locked and limited conversation to collaborators Oct 21, 2023
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
None yet
Development

Successfully merging a pull request may close this issue.

3 participants