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

docs: synchronize startVitest API with docs #3343

Merged
merged 2 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 passed down strings in their filepath.
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved

The third argument is CLI arguments that will override any other test config options.
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved

You can also pass down whole Vite config as the forth argument that will override any other user options.
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved

## 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