From 4cc18601f1e08b8ba1ca32c513f52074ae8413a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor=20Lopes?= Date: Tue, 3 Jun 2025 03:20:59 -0300 Subject: [PATCH] docs: remove outdated section (#8066) --- docs/guide/common-errors.md | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/docs/guide/common-errors.md b/docs/guide/common-errors.md index 47f40e9fb..f6cb04acc 100644 --- a/docs/guide/common-errors.md +++ b/docs/guide/common-errors.md @@ -43,21 +43,6 @@ export default defineConfig({ }) ``` -## Cannot mock "./mocked-file.js" because it is already loaded - -This error happens when `vi.mock` method is called on a module that was already loaded. Vitest throws this error because this call has no effect since cached modules are preferred. - -Remember that `vi.mock` is always hoisted - it means that the module was loaded before the test file started executing - most likely in a setup file. To fix the error, remove the import or clear the cache at the end of a setup file - beware that setup file and your test file will reference different modules in that case. - -```ts [setupFile.js] -import { vi } from 'vitest' -import { sideEffect } from './mocked-file.js' - -sideEffect() - -vi.resetModules() -``` - ## Failed to terminate worker This error can happen when NodeJS's `fetch` is used with default [`pool: 'threads'`](/config/#threads). This issue is tracked on issue [Timeout abort can leave process(es) running in the background #3077](https://github.com/vitest-dev/vitest/issues/3077). -- 2.51.2