@apitree.cz/vitest-config 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -8
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -18,20 +18,19 @@
|
|
|
18
18
|
pnpm add --save-dev @apitree.cz/vitest-config vitest
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
If you want to collect code coverage, you also need to install `v8` provider:
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```yaml
|
|
26
|
-
publicHoistPattern:
|
|
27
|
-
- '*vitest*'
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add --save-dev @vitest/coverage-v8
|
|
28
25
|
```
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
### Monorepos
|
|
28
|
+
|
|
29
|
+
Install the package in the root only, use it in multiple workspaces (see [Vitest Projects](#vitest-projects)).
|
|
31
30
|
|
|
32
31
|
## Usage
|
|
33
32
|
|
|
34
|
-
Use one of the following configurations in your `vitest.config.ts
|
|
33
|
+
Use one of the following configurations in your `vitest.config.ts`.
|
|
35
34
|
|
|
36
35
|
### Base
|
|
37
36
|
|
|
@@ -70,3 +69,39 @@ export default mergeConfig(
|
|
|
70
69
|
```
|
|
71
70
|
|
|
72
71
|
> See [Options](https://vitest.dev/config/#options) documentation for config reference.
|
|
72
|
+
|
|
73
|
+
### Vitest Projects
|
|
74
|
+
|
|
75
|
+
You can also use the configurations as a base for multiple [Vitest Projects](https://vitest.dev/guide/projects.html) in a monorepo setup.
|
|
76
|
+
|
|
77
|
+
Start by defining root `vitest.config.ts`:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { defineConfig, mergeConfig } from 'vitest/config';
|
|
81
|
+
|
|
82
|
+
export default defineConfig({
|
|
83
|
+
test: {
|
|
84
|
+
root: import.meta.dirname,
|
|
85
|
+
projects: ['apps*/', 'packages/*'],
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Then, in each project, create `vitest.config.js` defining specific preset (e.g. `apps/react-app/vitest.config.js` for an app that requires React preset):
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
import { react } from '@apitree.cz/vitest-config';
|
|
94
|
+
import { defineProject } from 'vitest/config';
|
|
95
|
+
|
|
96
|
+
export default defineProject(react);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Assuming the app is named `@apitree.cz/react-app`, you can run Vitest for this project only:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# From monorepo root
|
|
103
|
+
pnpm vitest --project @apitree.cz/react-app --run
|
|
104
|
+
|
|
105
|
+
# From apps/react-app
|
|
106
|
+
pnpm vitest --run
|
|
107
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apitree.cz/vitest-config",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"description": "Vitest configuration for ApiTree projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apitree",
|
|
@@ -46,19 +46,23 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@swc/core": "^1.15.3",
|
|
48
48
|
"@vitejs/plugin-react": "^5.1.2",
|
|
49
|
-
"@vitest/coverage-v8": "^4.0.15",
|
|
50
49
|
"unplugin-swc": "^1.5.9",
|
|
51
50
|
"vite": "^7.2.7"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
53
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
54
54
|
"jsdom": "^27.3.0",
|
|
55
55
|
"vitest": "^4.0.15"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
58
59
|
"jsdom": "^27.0.0",
|
|
59
60
|
"vitest": "^4.0.0"
|
|
60
61
|
},
|
|
61
62
|
"peerDependenciesMeta": {
|
|
63
|
+
"@vitest/coverage-v8": {
|
|
64
|
+
"optional": true
|
|
65
|
+
},
|
|
62
66
|
"jsdom": {
|
|
63
67
|
"optional": true
|
|
64
68
|
}
|