@jmlweb/jest-config 0.1.2 → 0.1.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @jmlweb/jest-config
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 4a9ece1: Update documentation to use pnpm commands instead of npm
8
+
3
9
  ## 0.1.2
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -20,7 +20,7 @@
20
20
  ## 📦 Installation
21
21
 
22
22
  ```bash
23
- npm install --save-dev @jmlweb/jest-config jest ts-jest @types/jest
23
+ pnpm add -D @jmlweb/jest-config jest ts-jest @types/jest
24
24
  ```
25
25
 
26
26
  > 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
@@ -123,6 +123,38 @@ export default createJestConfig({
123
123
  });
124
124
  ```
125
125
 
126
+ ## 🤔 Why Use This?
127
+
128
+ > **Philosophy**: Tests should run reliably with meaningful coverage metrics that enforce code quality without being overly strict.
129
+
130
+ This package provides a Jest configuration optimized for TypeScript projects with sensible coverage thresholds and test isolation. It balances strictness with practicality, enforcing coverage standards while keeping tests fast and maintainable.
131
+
132
+ ### Design Decisions
133
+
134
+ **80% Coverage Thresholds**: Requires 80% coverage across all metrics
135
+
136
+ - **Why**: 80% coverage strikes a good balance - it's high enough to ensure most code paths are tested but not so high that you waste time testing trivial code or struggle to reach unrealistic goals. It catches most bugs while allowing flexibility for edge cases that are hard to test
137
+ - **Trade-off**: Some projects may want higher coverage (90%+) or lower (60%). This is easily adjustable per project
138
+ - **When to override**: Increase for critical systems (financial, healthcare), decrease for experimental projects or when initially adding tests to legacy code
139
+
140
+ **Automatic Mock Clearing (`clearMocks: true, restoreMocks: true`)**: Resets mocks between tests
141
+
142
+ - **Why**: Test isolation is crucial for reliable tests. Automatically clearing and restoring mocks prevents test interdependence and the dreaded "works in isolation but fails in suite" problem. This eliminates an entire class of flaky tests
143
+ - **Trade-off**: Can't rely on mock state persisting between tests. But tests shouldn't share state anyway
144
+ - **When to override**: Rarely needed - test isolation is a best practice
145
+
146
+ **Node Environment by Default (`testEnvironment: 'node'`)**: Server-side testing environment
147
+
148
+ - **Why**: Most TypeScript projects tested with Jest are Node.js backends or libraries. The Node environment is lighter and faster than jsdom. For React/browser code, developers can override to jsdom per project
149
+ - **Trade-off**: Need to explicitly set jsdom for browser/React testing
150
+ - **When to override**: For React components or browser-specific code - set `testEnvironment: 'jsdom'` in your project config
151
+
152
+ **5 Second Test Timeout**: Reasonable default for most tests
153
+
154
+ - **Why**: Most unit tests should complete in milliseconds. 5 seconds is generous for integration tests while preventing truly hung tests from blocking CI indefinitely. It catches accidentally synchronous code or missing mocks
155
+ - **Trade-off**: Some integration tests with real databases might need longer timeouts
156
+ - **When to override**: For slow integration tests - increase per test suite or project-wide
157
+
126
158
  ## 📋 Configuration Details
127
159
 
128
160
  ### Default Settings
@@ -222,10 +254,10 @@ Add test scripts to your `package.json`:
222
254
  Then run:
223
255
 
224
256
  ```bash
225
- npm run test # Run tests once
226
- npm run test:watch # Run tests in watch mode
227
- npm run test:coverage # Run tests with coverage
228
- npm run test:ci # Run tests in CI mode
257
+ pnpm test # Run tests once
258
+ pnpm test:watch # Run tests in watch mode
259
+ pnpm test:coverage # Run tests with coverage
260
+ pnpm test:ci # Run tests in CI mode
229
261
  ```
230
262
 
231
263
  ### TypeScript Configuration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmlweb/jest-config",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Base Jest configuration for jmlweb projects with TypeScript support and coverage settings",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",