@jmlweb/jest-config 0.1.1 → 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.
Files changed (3) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +64 -5
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
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
+
9
+ ## 0.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 6b73301: Add changelog section with link to CHANGELOG.md in package READMEs
14
+
3
15
  ## 0.1.1
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -20,9 +20,11 @@
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
+ > 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
27
+
26
28
  ## 🚀 Quick Start
27
29
 
28
30
  Create a `jest.config.ts` file in your project root:
@@ -121,6 +123,38 @@ export default createJestConfig({
121
123
  });
122
124
  ```
123
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
+
124
158
  ## 📋 Configuration Details
125
159
 
126
160
  ### Default Settings
@@ -220,10 +254,10 @@ Add test scripts to your `package.json`:
220
254
  Then run:
221
255
 
222
256
  ```bash
223
- npm run test # Run tests once
224
- npm run test:watch # Run tests in watch mode
225
- npm run test:coverage # Run tests with coverage
226
- 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
227
261
  ```
228
262
 
229
263
  ### TypeScript Configuration
@@ -253,11 +287,36 @@ This package requires the following peer dependencies:
253
287
 
254
288
  ## 🔗 Related Packages
255
289
 
290
+ ### Internal Packages
291
+
256
292
  - [`@jmlweb/vitest-config`](../vitest-config) - Vitest configuration for modern testing
257
293
  - [`@jmlweb/eslint-config-base`](../eslint-config-base) - ESLint config for TypeScript projects
258
294
  - [`@jmlweb/prettier-config-base`](../prettier-config-base) - Prettier config for consistent formatting
259
295
  - [`@jmlweb/tsconfig-base`](../tsconfig-base) - TypeScript configuration
260
296
 
297
+ ### External Tools
298
+
299
+ - [Jest](https://jestjs.io/) - Delightful JavaScript testing framework
300
+ - [ts-jest](https://kulshekhar.github.io/ts-jest/) - TypeScript preprocessor for Jest
301
+ - [@testing-library/jest-dom](https://testing-library.com/docs/ecosystem-jest-dom/) - Custom Jest matchers for the DOM
302
+ - [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/) - React testing utilities (for React projects)
303
+
304
+ ## 🔄 Migration Guide
305
+
306
+ ### Upgrading to a New Version
307
+
308
+ > **Note:** If no breaking changes were introduced in a version, it's safe to upgrade without additional steps.
309
+
310
+ **No breaking changes have been introduced yet.** This package follows semantic versioning. When breaking changes are introduced, detailed migration instructions will be provided here.
311
+
312
+ For version history, see the [Changelog](./CHANGELOG.md).
313
+
314
+ **Need Help?** If you encounter issues during migration, please [open an issue](https://github.com/jmlweb/tooling/issues/new).
315
+
316
+ ## 📜 Changelog
317
+
318
+ See [CHANGELOG.md](./CHANGELOG.md) for version history and release notes.
319
+
261
320
  ## 📄 License
262
321
 
263
322
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmlweb/jest-config",
3
- "version": "0.1.1",
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",