-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug: Fix issue on Vite env not cleaning up after test (#297)
BREAKING CHANGE: This PR change default behavior for Vitest users. This major should yield no effect to other test frameworks. Throw error when running vitest with no `afterEach` global and no `VTL_SKIP_AUTO_CLEANUP` flag is set.
- Loading branch information
1 parent
015de7d
commit 88fb8cd
Showing
3 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// This test verifies that if test is running from vitest with globals - jest will not throw | ||
test('works', () => { | ||
global.afterEach = () => {} // emulate enabled globals | ||
process.env.VITEST = 'true' | ||
|
||
expect(() => require('..')).not.toThrow() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// This test verifies that if test is running from vitest without globals - jest will throw | ||
test('works', () => { | ||
delete global.afterEach // no globals in vitest by default | ||
process.env.VITEST = 'true' | ||
|
||
expect(() => require('..')).toThrowErrorMatchingInlineSnapshot(` | ||
You are using vitest without globals, this way we can't run cleanup after each test. | ||
See https://testing-library.com/docs/vue-testing-library/setup for details or set the VTL_SKIP_AUTO_CLEANUP variable to 'true' | ||
`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters