You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are times when the test runners needs to run a cleanup callback manually and not tied it to the test runner lifecycle (avoid beforeEach/afterEach). A good example of this is calling the cleanup when switching tests in the Browser Mode UI.
Suggested solution
@vitest/runner can expose an onCleanup hook. Consumers of the runner can decide when to run passed down callbacks. By default, Vitest will run those callbacks after each test (when running tests in the Node.js environment). Vitest Browser Mode will also run those hooks after each test, except for the last one, so the UI is still available.
Clear and concise description of the problem
There are times when the test runners needs to run a cleanup callback manually and not tied it to the test runner lifecycle (avoid
beforeEach
/afterEach
). A good example of this is calling the cleanup when switching tests in the Browser Mode UI.Suggested solution
@vitest/runner
can expose anonCleanup
hook. Consumers of the runner can decide when to run passed down callbacks. By default, Vitest will run those callbacks after each test (when running tests in the Node.js environment). Vitest Browser Mode will also run those hooks after each test, except for the last one, so the UI is still available.Alternative
No response
Additional context
See #7141 for more details
Validations
The text was updated successfully, but these errors were encountered: