Skip to content

Commit

Permalink
docs: update vitest config to match vitest docs (#3037)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
rn0614 and dbritto-dev authored Mar 3, 2025
1 parent 979ce7d commit a90981a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions docs/guides/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
},
}),
),
)
```

Expand Down

0 comments on commit a90981a

Please sign in to comment.