Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow config option to be false #2749

Merged
merged 1 commit into from Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/vitest/src/node/cache/index.ts
Expand Up @@ -27,13 +27,17 @@ export class VitestCache {
static async clearCache(options: CliOptions) {
const root = resolve(options.root || process.cwd())

const configPath = options.config
? resolve(root, options.config)
: await findUp(configFiles, { cwd: root } as any)
const configPath = options.config === false
? false
: options.config
? resolve(root, options.config)
: await findUp(configFiles, { cwd: root } as any)

const config = await loadConfigFromFile({ command: 'serve', mode: 'test' }, configPath)
const config = configPath
? (await loadConfigFromFile({ command: 'serve', mode: 'test' }, configPath))?.config
: undefined

const cache = config?.config.test?.cache
const cache = config?.test?.cache

if (cache === false)
throw new Error('Cache is disabled')
Expand Down
8 changes: 5 additions & 3 deletions packages/vitest/src/node/create.ts
Expand Up @@ -11,9 +11,11 @@ export async function createVitest(mode: VitestRunMode, options: UserConfig, vit
const ctx = new Vitest(mode)
const root = resolve(options.root || process.cwd())

const configPath = options.config
? resolve(root, options.config)
: await findUp(configFiles, { cwd: root } as any)
const configPath = options.config === false
? false
: options.config
? resolve(root, options.config)
: await findUp(configFiles, { cwd: root } as any)

const config: ViteInlineConfig = {
logLevel: 'error',
Expand Down
4 changes: 3 additions & 1 deletion packages/vitest/src/types/config.ts
Expand Up @@ -554,8 +554,10 @@ export interface UserConfig extends InlineConfig {
* Path to the config file.
*
* Default resolving to `vitest.config.*`, `vite.config.*`
*
* Setting to `false` will disable config resolving.
*/
config?: string | undefined
config?: string | false | undefined

/**
* Use happy-dom
Expand Down