Skip to content

Commit

Permalink
docs: some clarifications
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Aug 2, 2024
1 parent 20f15c4 commit cbd1b1c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/guide/browser/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ export default defineConfig({

If you need to run some tests using Node-based runner, you can define a [workspace](/guide/workspace) file with separate configurations for different testing strategies:

{#workspace-config}

```ts
// vitest.workspace.ts
import { defineWorkspace } from 'vitest/config'
Expand Down
6 changes: 6 additions & 0 deletions docs/guide/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ When using `jsdom` or `happy-dom` environments, Vitest follows the same rules th
Since Vitest 2.0.4 the `require` of CSS and assets inside the external dependencies are resolved automatically.
:::

::: warning
"Environments" exist only when running tests in Node.js.

`browser` is not considered an environment in Vitest. If you wish to run part of your tests using [Browser Mode](/guide/browser), you can create a [workspace project](/guide/browser/#workspace-config).
:::

## Environments for Specific Files

When setting `environment` option in your config, it will apply to all the test files in your project. To have more fine-grained control, you can use control comments to specify environment for specific files. Control comments are comments that start with `@vitest-environment` and are followed by the environment name:
Expand Down
25 changes: 23 additions & 2 deletions docs/guide/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,37 @@ bun test

If you need to run tests only inside a single project, use the `--project` CLI option:

```bash
::: code-group
```bash [npm]
npm run test --project e2e
```
```bash [yarn]
yarn test --project e2e
```
```bash [pnpm]
pnpm run test --project e2e
```
```bash [bun]
bun test --project e2e
```
:::

::: tip
CLI option `--project` can be used multiple times to filter out several projects:

```bash
::: code-group
```bash [npm]
npm run test --project e2e --project unit
```
```bash [yarn]
yarn test --project e2e --project unit
```
```bash [pnpm]
pnpm run test --project e2e --project unit
```
```bash [bun]
bun test --project e2e --project unit
```
:::

## Configuration
Expand Down

0 comments on commit cbd1b1c

Please sign in to comment.