Skip to content

Commit

Permalink
fix(cli): don't override config by setting cli options to undefined (#…
Browse files Browse the repository at this point in the history
…2330)

This has been introduced by #2180. The change there will *always* set
argv.dir, no matter if it's been there before or not. When it's not
there, it will set it to undefined, which then will lead to vitest using
the root as fallback instead of the config set in the config file, since
CLI options override config options.

In our case, this config was essentially ignored since 0.24.4.

```js
import { defineConfig } from "vite"

export default defineConfig({
  test: {
    dir: "spec/javascript"
  }
})
```

with the only workaround of providing `dir` via CLI option.
  • Loading branch information
rmehner committed Nov 21, 2022
1 parent 4f5efdb commit 6ce3ed7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/vitest/src/node/cli.ts
Expand Up @@ -103,9 +103,15 @@ async function typecheck(cliFilters: string[] = [], options: CliOptions = {}) {
}

function normalizeOptions(argv: CliOptions): CliOptions {
argv.root = argv.root && normalize(argv.root)
argv.config = argv.config && normalize(argv.config)
argv.dir = argv.dir && normalize(argv.dir)
if (argv.root)
argv.root = normalize(argv.root)

if (argv.config)
argv.config = normalize(argv.config)

if (argv.dir)
argv.dir = normalize(argv.dir)

return argv
}

Expand Down

0 comments on commit 6ce3ed7

Please sign in to comment.