From 1bbeeb404fcf461120548d7a9ae6817f3f184a73 Mon Sep 17 00:00:00 2001 From: Isaiah Thomason <47364027+ITenthusiasm@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:38:57 -0500 Subject: [PATCH] fix: Revert Errors Regarding Missing Global Hooks (#310) Please bear in mind that after 8.0.1, v7 and v8 share the same behavior as the main difference between versions has been erased. So everyone should be able to jump from v7 to v8 without experiencing any difference. --- src/__tests__/auto-cleanup-vitest-globals.js | 7 ------- src/__tests__/auto-cleanup-vitest.js | 10 ---------- src/index.js | 5 ----- 3 files changed, 22 deletions(-) delete mode 100644 src/__tests__/auto-cleanup-vitest-globals.js delete mode 100644 src/__tests__/auto-cleanup-vitest.js diff --git a/src/__tests__/auto-cleanup-vitest-globals.js b/src/__tests__/auto-cleanup-vitest-globals.js deleted file mode 100644 index 8d320ea..0000000 --- a/src/__tests__/auto-cleanup-vitest-globals.js +++ /dev/null @@ -1,7 +0,0 @@ -// 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() -}) diff --git a/src/__tests__/auto-cleanup-vitest.js b/src/__tests__/auto-cleanup-vitest.js deleted file mode 100644 index ef0a5a1..0000000 --- a/src/__tests__/auto-cleanup-vitest.js +++ /dev/null @@ -1,10 +0,0 @@ -// 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' - `) -}) diff --git a/src/index.js b/src/index.js index 99a01b7..b9f4dc4 100644 --- a/src/index.js +++ b/src/index.js @@ -8,11 +8,6 @@ if (typeof afterEach === 'function' && !process.env.VTL_SKIP_AUTO_CLEANUP) { afterEach(() => { cleanup() }) -} else if (process.env.VITEST === 'true') { - throw new Error( - "You are using vitest without globals, this way we can't run cleanup after each test.\n" + - "See https://testing-library.com/docs/vue-testing-library/setup for details or set the VTL_SKIP_AUTO_CLEANUP variable to 'true'", - ) } export * from '@testing-library/dom'