Skip to content

Commit

Permalink
feat: add description for vitest workspaces (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
zirkelc authored Aug 7, 2023
1 parent ae43106 commit 50b6e0b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,27 @@ the report would look like this:
![Coverage Threshold Report](./docs/coverage-report-threshold.png)

If there are no thresholds defined, the status will be '🔵'.

### Workspaces

If you are using a monorepo with [Vitest Workspaces](https://vitest.dev/guide/workspace.html) and you run Vitest from the root of your project, Vitest will ignore the `coverage`-property of the individual project-level `vite.config.js`-files. This is because some of the [configuration options](https://vitest.dev/guide/workspace.html#configuration) are not allowed in a project config, for example coverage is done for the whole workspace.

In this case, you can create a `vite.config.js`-file in the root of your project next to your `vitest.workspace.js`-file to configure coverage for the whole workspace:

```js
import { defineConfig } from 'vite';
export default defineConfig({
test: {
coverage: {
// you can include other reporters, but 'json-summary' is required, json is recommended
reporter: ['text', 'json-summary', 'json'],
}
}
});
```

Alternatively, you can provide [coverage options](https://vitest.dev/config/#coverage) to CLI with dot notation:
```sh
npx vitest --coverage.enabled --coverage.provider=v8 --coverage.reporter=json-summary --coverage.reporter=json
```

0 comments on commit 50b6e0b

Please sign in to comment.