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

fix: remove undefined values in options #2281

Merged
merged 5 commits into from Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 9 additions & 1 deletion packages/vitest/src/node/plugins/index.ts
Expand Up @@ -12,6 +12,14 @@ import { MocksPlugin } from './mock'
import { CSSEnablerPlugin } from './cssEnabler'
import { CoverageTransform } from './coverageTransform'

function removeUndefinedValues(obj: Record<string, any>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this to utils/base.ts file

for (const key in obj) {
if (obj[key] === undefined)
delete obj[key]
}
return obj
}

export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest('test')): Promise<VitePlugin[]> {
const getRoot = () => ctx.config?.root || options.root || process.cwd()

Expand All @@ -36,7 +44,7 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest('t
// preliminary merge of options to be able to create server options for vite
// however to allow vitest plugins to modify vitest config values
// this is repeated in configResolved where the config is final
const preOptions = deepMerge({}, configDefaults, options, viteConfig.test ?? {})
const preOptions = deepMerge({}, configDefaults, options, removeUndefinedValues(viteConfig.test) ?? {})
preOptions.api = resolveApiConfig(preOptions)

if (viteConfig.define) {
Expand Down
12 changes: 10 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.