Skip to content

Conversation

@sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Mar 19, 2025

Description

Closes #6157

Test plan:

  1. the file fixture is provided as a primitive value and is accessible by tests
  2. the file fixture is provided as a factory and is initialised once in all suites, teardown is called once
  3. the file fixture is provided as a factory and is initialised once per file when isolation is disabled, teardown is called once per file
  4. the worker fixture is provided as a primitive and is accessible by tests
  5. the worker fixture is provided as a factory and is initialised once in all suites, teardown is called once by default
  6. the worker fixture is provided as a factory and initialised once per worker when isolation is disabled, teardown is called once per file in threads
  7. the worker fixture is provided as a factory and initialised once per file when isolation is disabled in vmThreads, teardown is called by the same rules
  8. worker fixture cannot import from the file or test fixture except static
  9. file fixture cannot import from test fixture except static
  10. file fixture with auto is initialised always on the first test
  11. worker fixture with auto is initialised always on the first test
  12. file and worker fixtures are available in beforeEach and afterEach

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@sheremet-va sheremet-va marked this pull request as draft March 19, 2025 15:46
@netlify
Copy link

netlify bot commented Mar 19, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit f903811
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/683ac16e8a96d00008cd4b2c
😎 Deploy Preview https://deploy-preview-7704--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sheremet-va sheremet-va added the p2-nice-to-have Not breaking anything but nice to have (priority) label Mar 24, 2025
@sheremet-va sheremet-va moved this to P2 - 4 in Team Board Mar 31, 2025
@sheremet-va sheremet-va added this to the 3.2.0 milestone May 5, 2025
@sheremet-va
Copy link
Member Author

@AriPerkkio can you help me with the worker teardown? I cannot make it work at all. beforeExit is not called, and calling cleanup before recycleWorkers kills Vitest process 🤔

Copy link
Member

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beforeExit is not called, and calling cleanup before recycleWorkers kills Vitest process 🤔

Is there a test that can be used to reproduce this?

@sheremet-va
Copy link
Member Author

sheremet-va commented May 15, 2025

beforeExit is not called, and calling cleanup before recycleWorkers kills Vitest process 🤔

Is there a test that can be used to reproduce this?

Here is a test file:

https://github.com/vitest-dev/vitest/blob/2cc955786cb5f14530314849d894849de83364b6/test/cli/test/scoped-fixtures.test.ts

test.skip are for worker scoped tests. There is also a TODO // TODO: worker teardown is not called

@sheremet-va sheremet-va marked this pull request as ready for review May 31, 2025 08:56
@sheremet-va sheremet-va requested a review from AriPerkkio May 31, 2025 09:13
@sheremet-va sheremet-va merged commit 9cbfc23 into vitest-dev:main May 31, 2025
21 of 22 checks passed
@sheremet-va sheremet-va deleted the feat/per-scope-fixtures branch May 31, 2025 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-nice-to-have Not breaking anything but nice to have (priority)

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Scoped Fixtures

2 participants