Skip to content

Commit 385eb73

Browse files
authored
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
1 parent 979ce7d commit 385eb73

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

docs/guides/testing.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,17 @@ vi.mock('zustand') // to make it work like Jest (auto-mocking)
274274
import { defineConfig, mergeConfig } from 'vitest/config'
275275
import viteConfig from './vite.config'
276276

277-
export default mergeConfig(
278-
viteConfig,
279-
defineConfig({
280-
test: {
281-
globals: true,
282-
environment: 'jsdom',
283-
setupFiles: ['./setup-vitest.ts'],
284-
},
285-
}),
277+
export default defineConfig((configEnv) =>
278+
mergeConfig(
279+
viteConfig(configEnv),
280+
defineConfig({
281+
test: {
282+
globals: true,
283+
environment: 'jsdom',
284+
setupFiles: ['./setup-vitest.ts'],
285+
},
286+
})
287+
)
286288
)
287289
```
288290

0 commit comments

Comments
 (0)