Skip to content

Commit

Permalink
docs: synchronize startVitest API with docs (#3343)
Browse files Browse the repository at this point in the history
Co-authored-by: Anjorin Damilare <damilareanjorin1@gmail.com>
  • Loading branch information
sheremet-va and dammy001 authored May 10, 2023
1 parent c816b89 commit 0f0d756
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion docs/advanced/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You can start running Vitest tests using its Node API:
```js
import { startVitest } from 'vitest/node'

const vitest = await startVitest('test', ['tests/run-only.test.ts'])
const vitest = await startVitest('test')

await vitest?.close()
```
Expand All @@ -28,6 +28,12 @@ If watch mode is not enabled, Vitest will call `close` method.
If watch mode is enabled and the terminal supports TTY, Vitest will register console shortcuts.
You can pass down a list of filters as a second argument. Vitest will run only tests that contain at least one of the passed-down strings in their file path.
Additionally, you can use the third argument to pass in CLI arguments, which will override any test config options.
Alternatively, you can pass in the complete Vite config as the fourth argument, which will take precedence over any other user-defined options.
## createVitest
You can create Vitest instance yourself using `createVitest` function. It returns the same `Vitest` instance as `startVitest`, but it doesn't start tests and doesn't validate installed packages.
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/node/cli-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export interface CliOptions extends UserConfig {
*/
export async function startVitest(
mode: VitestRunMode,
cliFilters: string[],
options: CliOptions,
cliFilters: string[] = [],
options: CliOptions = {},
viteOverrides?: ViteUserConfig,
): Promise<Vitest | undefined> {
process.env.TEST = 'true'
Expand Down

0 comments on commit 0f0d756

Please sign in to comment.