Skip to content

Commit

Permalink
feat: add function/promise forms of defineConfig() (#1324)
Browse files Browse the repository at this point in the history
Make `defineConfig()` accept a callback or promise that resolves to a config.
This matches the signature of `defineConfig()` from Vite.
  • Loading branch information
pastelmind committed May 17, 2022
1 parent 03a54e0 commit 5af545d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/vitest/src/config.ts
@@ -1,4 +1,4 @@
import type { UserConfig as ViteUserConfig } from 'vite'
import type { ConfigEnv, UserConfig as ViteUserConfig } from 'vite'

export interface UserConfig extends ViteUserConfig {
test?: ViteUserConfig['test']
Expand All @@ -7,6 +7,10 @@ export interface UserConfig extends ViteUserConfig {
// will import vitest declare test in module 'vite'
export { configDefaults } from './defaults'

export function defineConfig(config: UserConfig) {
export type { ConfigEnv }
export type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>
export type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn

export function defineConfig(config: UserConfigExport) {
return config
}

0 comments on commit 5af545d

Please sign in to comment.