From a90981afb5c935b90719c7c85808796caaf55f24 Mon Sep 17 00:00:00 2001 From: Koo Sangmo <60815812+rn0614@users.noreply.github.com> Date: Mon, 3 Mar 2025 21:46:37 +0900 Subject: [PATCH] docs: update vitest config to match vitest docs (#3037) * Update testing.md in vite, mergeConfig accepts only config in object form. If you have a config in callback form, you should call it before passing into mergeConfig. You can use the defineConfig helper to merge a config in callback form with another config: https://vite.dev/guide/api-javascript.html#mergeconfig * Fix formatting --------- Co-authored-by: Danilo Britto --- docs/guides/testing.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/guides/testing.md b/docs/guides/testing.md index 13a2e8c502..5638b760f1 100644 --- a/docs/guides/testing.md +++ b/docs/guides/testing.md @@ -274,15 +274,17 @@ vi.mock('zustand') // to make it work like Jest (auto-mocking) import { defineConfig, mergeConfig } from 'vitest/config' import viteConfig from './vite.config' -export default mergeConfig( - viteConfig, - defineConfig({ - test: { - globals: true, - environment: 'jsdom', - setupFiles: ['./setup-vitest.ts'], - }, - }), +export default defineConfig((configEnv) => + mergeConfig( + viteConfig(configEnv), + defineConfig({ + test: { + globals: true, + environment: 'jsdom', + setupFiles: ['./setup-vitest.ts'], + }, + }), + ), ) ```