@jmlweb/vitest-config 1.0.5 → 1.0.7
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/CHANGELOG.md +12 -0
- package/README.md +43 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @jmlweb/vitest-config
|
|
2
2
|
|
|
3
|
+
## 1.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 30f8ffb: Add "Why Use This?" sections to package READMEs explaining configuration philosophy and design decisions
|
|
8
|
+
|
|
9
|
+
## 1.0.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 4a9ece1: Update documentation to use pnpm commands instead of npm
|
|
14
|
+
|
|
3
15
|
## 1.0.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
## 📦 Installation
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
|
|
22
|
+
pnpm add -D @jmlweb/vitest-config vitest
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
> 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
|
|
@@ -122,6 +122,38 @@ export default defineConfig({
|
|
|
122
122
|
});
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
+
## 🤔 Why Use This?
|
|
126
|
+
|
|
127
|
+
> **Philosophy**: Modern testing should be fast, have excellent DX, and enforce meaningful coverage without slowing down development.
|
|
128
|
+
|
|
129
|
+
This package provides a Vitest configuration optimized for speed and developer experience while maintaining high code quality standards. It leverages Vitest's Vite-powered architecture for extremely fast test execution and hot module replacement during test development.
|
|
130
|
+
|
|
131
|
+
### Design Decisions
|
|
132
|
+
|
|
133
|
+
**80% Coverage Thresholds**: Balanced quality enforcement
|
|
134
|
+
|
|
135
|
+
- **Why**: 80% coverage ensures most code is tested without creating unrealistic goals that lead to testing trivial code just to hit metrics. It's high enough to catch bugs but low enough to remain practical for real-world development
|
|
136
|
+
- **Trade-off**: Some projects need higher (90%+) or lower (60%) thresholds depending on criticality
|
|
137
|
+
- **When to override**: Increase for safety-critical code, decrease for rapid prototyping or legacy code being brought under test
|
|
138
|
+
|
|
139
|
+
**Global Test Functions (`globals: true`)**: Familiar testing API
|
|
140
|
+
|
|
141
|
+
- **Why**: Enables the familiar `describe`, `it`, `expect` globals without imports, matching Jest's API. This makes migration easier and reduces boilerplate in every test file. Most developers expect this API
|
|
142
|
+
- **Trade-off**: Technically pollutes global scope, but this is standard in testing and expected behavior
|
|
143
|
+
- **When to override**: If you prefer explicit imports (`import { describe, it, expect } from 'vitest'`) for stricter code style
|
|
144
|
+
|
|
145
|
+
**Thread Pool (`pool: 'threads'`)**: Parallel test execution
|
|
146
|
+
|
|
147
|
+
- **Why**: Vitest's thread pool runs tests in parallel using worker threads, dramatically speeding up large test suites. Much faster than Jest's default process-based isolation while maintaining proper isolation
|
|
148
|
+
- **Trade-off**: Minimal memory overhead from worker threads. But the speed improvement is significant
|
|
149
|
+
- **When to override**: For tests with native modules that don't work in workers - use `forks` pool instead
|
|
150
|
+
|
|
151
|
+
**V8 Coverage Provider**: Fast native coverage
|
|
152
|
+
|
|
153
|
+
- **Why**: V8's built-in coverage is significantly faster than instrumentation-based coverage (like Istanbul). For Vitest projects, it's the best choice for speed while maintaining accuracy
|
|
154
|
+
- **Trade-off**: Less configurable than Istanbul, but coverage accuracy is equivalent for modern code
|
|
155
|
+
- **When to override**: Rarely needed - V8 coverage works well for all modern JavaScript/TypeScript
|
|
156
|
+
|
|
125
157
|
## 📋 Configuration Details
|
|
126
158
|
|
|
127
159
|
### Default Settings
|
|
@@ -223,11 +255,11 @@ Add test scripts to your `package.json`:
|
|
|
223
255
|
Then run:
|
|
224
256
|
|
|
225
257
|
```bash
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
258
|
+
pnpm test # Run tests in watch mode
|
|
259
|
+
pnpm test:run # Run tests once
|
|
260
|
+
pnpm test:coverage # Run tests with coverage
|
|
261
|
+
pnpm test:ui # Open Vitest UI
|
|
262
|
+
pnpm test:typecheck # Run TypeScript type checking
|
|
231
263
|
```
|
|
232
264
|
|
|
233
265
|
### TypeScript Type Checking
|
|
@@ -236,10 +268,10 @@ Type checking is performed separately using the `vitest typecheck` command for b
|
|
|
236
268
|
|
|
237
269
|
```bash
|
|
238
270
|
# Run type checking only
|
|
239
|
-
|
|
271
|
+
pnpm test:typecheck
|
|
240
272
|
|
|
241
273
|
# Or run tests and type checking together
|
|
242
|
-
|
|
274
|
+
pnpm test && pnpm test:typecheck
|
|
243
275
|
```
|
|
244
276
|
|
|
245
277
|
## 📋 Requirements
|
|
@@ -331,10 +363,10 @@ Install the DOM environment package:
|
|
|
331
363
|
|
|
332
364
|
```bash
|
|
333
365
|
# For jsdom (more compatible, slower)
|
|
334
|
-
|
|
366
|
+
pnpm add -D jsdom
|
|
335
367
|
|
|
336
368
|
# Or for happy-dom (faster, less compatible)
|
|
337
|
-
|
|
369
|
+
pnpm add -D happy-dom
|
|
338
370
|
```
|
|
339
371
|
|
|
340
372
|
Then specify in your config if different from default:
|
|
@@ -370,7 +402,7 @@ export default defineConfig({
|
|
|
370
402
|
Install the coverage provider:
|
|
371
403
|
|
|
372
404
|
```bash
|
|
373
|
-
|
|
405
|
+
pnpm add -D @vitest/coverage-v8
|
|
374
406
|
```
|
|
375
407
|
|
|
376
408
|
Run tests with coverage flag:
|
package/package.json
CHANGED