@jmlweb/vitest-config 1.0.0 → 1.0.2

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 ADDED
@@ -0,0 +1,15 @@
1
+ # @jmlweb/vitest-config
2
+
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 2208f74: Standardize repository field format to object format across all packages and configure syncpack to preserve it.
8
+
9
+ ## 1.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - d75c258: fix: update vitest peer dependency to support newer versions
14
+
15
+ Updated the vitest peer dependency from `^1.0.0` to `>=1.0.0` to support vitest 2.x, 3.x, and 4.x versions, resolving peer dependency warnings in modern projects.
package/README.md CHANGED
@@ -9,9 +9,10 @@
9
9
 
10
10
  ## ✨ Features
11
11
 
12
- - 🔧 **TypeScript Support**: Configured for TypeScript projects with type checking enabled
12
+ - 🔧 **TypeScript Support**: Configured for TypeScript projects (type checking via CLI)
13
13
  - 📊 **Coverage Configuration**: Pre-configured with v8 provider and 80% coverage thresholds
14
- - 🎯 **Sensible Defaults**: Node.js environment, globals enabled, standard reporters
14
+ - 🎯 **Sensible Defaults**: Node.js environment, globals enabled, optimized test execution
15
+ - ⚡ **Performance Optimized**: Thread pool configuration for efficient parallel test execution
15
16
  - 🚀 **Easy Extension**: Flat config format for easy customization
16
17
  - 📦 **Zero Config**: Works out of the box with minimal setup
17
18
 
@@ -123,16 +124,18 @@ export default defineConfig({
123
124
 
124
125
  ### Default Settings
125
126
 
126
- | Setting | Value | Description |
127
- | -------------------------------- | ------ | ---------------------------------------------------- |
128
- | `globals` | `true` | Enables global test functions (describe, it, expect) |
129
- | `environment` | `node` | Node.js environment by default |
130
- | `coverage.provider` | `v8` | Coverage provider |
131
- | `coverage.thresholds.lines` | `80` | Minimum line coverage |
132
- | `coverage.thresholds.functions` | `80` | Minimum function coverage |
133
- | `coverage.thresholds.branches` | `80` | Minimum branch coverage |
134
- | `coverage.thresholds.statements` | `80` | Minimum statement coverage |
135
- | `typecheck.enabled` | `true` | Enable TypeScript type checking |
127
+ | Setting | Value | Description |
128
+ | -------------------------------- | --------- | ---------------------------------------------------- |
129
+ | `globals` | `true` | Enables global test functions (describe, it, expect) |
130
+ | `environment` | `node` | Node.js environment by default |
131
+ | `testTimeout` | `5000` | Test timeout in milliseconds (5 seconds) |
132
+ | `hookTimeout` | `10000` | Hook timeout in milliseconds (10 seconds) |
133
+ | `pool` | `threads` | Use thread pool for parallel test execution |
134
+ | `coverage.provider` | `v8` | Coverage provider |
135
+ | `coverage.thresholds.lines` | `80` | Minimum line coverage |
136
+ | `coverage.thresholds.functions` | `80` | Minimum function coverage |
137
+ | `coverage.thresholds.branches` | `80` | Minimum branch coverage |
138
+ | `coverage.thresholds.statements` | `80` | Minimum statement coverage |
136
139
 
137
140
  ### Coverage Exclusions
138
141
 
@@ -156,11 +159,15 @@ Tests are automatically discovered from:
156
159
 
157
160
  ### Reporters
158
161
 
159
- Default reporters include:
162
+ **Test Reporters:**
160
163
 
161
- - `verbose` - Detailed test output
162
- - `json` - JSON format for CI/CD
163
- - `html` - HTML coverage report
164
+ - `verbose` - Detailed test output with full test names and results
165
+
166
+ **Coverage Reporters:**
167
+
168
+ - `text` - Text summary in terminal
169
+ - `json` - JSON format for CI/CD integration
170
+ - `html` - HTML coverage report (generated in `coverage/` directory)
164
171
 
165
172
  ## 🎯 When to Use
166
173
 
@@ -169,6 +176,7 @@ Use this configuration when you want:
169
176
  - ✅ Consistent testing setup across projects
170
177
  - ✅ TypeScript support out of the box
171
178
  - ✅ Coverage thresholds enforced
179
+ - ✅ Optimized test execution with thread pool
172
180
  - ✅ Sensible defaults for Node.js projects
173
181
  - ✅ Easy customization and extension
174
182
 
@@ -204,11 +212,34 @@ Add test scripts to your `package.json`:
204
212
  "test": "vitest",
205
213
  "test:run": "vitest run",
206
214
  "test:coverage": "vitest run --coverage",
207
- "test:ui": "vitest --ui"
215
+ "test:ui": "vitest --ui",
216
+ "test:typecheck": "vitest typecheck"
208
217
  }
209
218
  }
210
219
  ```
211
220
 
221
+ Then run:
222
+
223
+ ```bash
224
+ npm run test # Run tests in watch mode
225
+ npm run test:run # Run tests once
226
+ npm run test:coverage # Run tests with coverage
227
+ npm run test:ui # Open Vitest UI
228
+ npm run test:typecheck # Run TypeScript type checking
229
+ ```
230
+
231
+ ### TypeScript Type Checking
232
+
233
+ Type checking is performed separately using the `vitest typecheck` command for better performance. This allows you to run type checking independently of your test suite:
234
+
235
+ ```bash
236
+ # Run type checking only
237
+ npm run test:typecheck
238
+
239
+ # Or run tests and type checking together
240
+ npm run test && npm run test:typecheck
241
+ ```
242
+
212
243
  ## 📋 Requirements
213
244
 
214
245
  - **Node.js** >= 18.0.0
@@ -221,6 +252,13 @@ This package requires the following peer dependency:
221
252
 
222
253
  - `vitest` (^1.0.0)
223
254
 
255
+ ## 📚 Examples
256
+
257
+ See real-world usage examples:
258
+
259
+ - [`example-nodejs-typescript-api`](../../apps/example-nodejs-typescript-api) - Node.js TypeScript API with testing
260
+ - [`example-react-typescript-app`](../../apps/example-react-typescript-app) - React TypeScript app with component testing
261
+
224
262
  ## 🔗 Related Packages
225
263
 
226
264
  - [`@jmlweb/eslint-config-base`](../eslint-config-base) - ESLint config for TypeScript projects
package/dist/index.cjs CHANGED
@@ -23,12 +23,17 @@ __export(index_exports, {
23
23
  default: () => index_default
24
24
  });
25
25
  module.exports = __toCommonJS(index_exports);
26
- var config = {
26
+ var import_config = require("vitest/config");
27
+ var config = (0, import_config.defineConfig)({
27
28
  test: {
28
29
  // Enable globals for cleaner test syntax (e.g., describe, it, expect without imports)
29
30
  globals: true,
30
31
  // Use Node.js environment by default
31
32
  environment: "node",
33
+ // Test timeout (5 seconds default, can be overridden)
34
+ testTimeout: 5e3,
35
+ // Hook timeout (10 seconds for setup/teardown)
36
+ hookTimeout: 1e4,
32
37
  // Coverage configuration
33
38
  coverage: {
34
39
  // Use v8 provider for coverage (default, but explicit for clarity)
@@ -53,7 +58,7 @@ var config = {
53
58
  "**/*.test.{ts,tsx,js,jsx}",
54
59
  "**/*.spec.{ts,tsx,js,jsx}"
55
60
  ],
56
- // Coverage reporters
61
+ // Coverage reporters (HTML is valid here for coverage reports)
57
62
  reporter: ["text", "json", "html"]
58
63
  },
59
64
  // Test file patterns
@@ -66,12 +71,23 @@ var config = {
66
71
  "**/.{idea,git,cache,output,temp}/**",
67
72
  "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*"
68
73
  ],
69
- // Reporter configuration
70
- reporters: ["verbose", "json", "html"],
71
- // TypeScript configuration
72
- typecheck: {
73
- enabled: true
74
+ // Test reporter configuration (HTML is only for coverage, not test reporters)
75
+ // Use 'verbose' for detailed output, 'basic' for minimal, 'dot' for dots, 'json' for CI/CD
76
+ reporters: ["verbose"],
77
+ // Pool configuration for test execution
78
+ // threads: faster but may have issues with shared state
79
+ // forks: more isolated but slower
80
+ // Use threads by default for better performance
81
+ pool: "threads",
82
+ // Pool options for better performance
83
+ poolOptions: {
84
+ threads: {
85
+ // Use all available CPUs minus 1 to leave one for the system
86
+ minThreads: 1,
87
+ maxThreads: void 0
88
+ // Let Vitest decide based on available CPUs
89
+ }
74
90
  }
75
91
  }
76
- };
92
+ });
77
93
  var index_default = config;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { UserConfig } from 'vitest/config';
1
+ import * as vite from 'vite';
2
2
 
3
3
  /**
4
4
  * Base Vitest configuration with TypeScript support, coverage settings, and sensible defaults.
@@ -11,6 +11,10 @@ import { UserConfig } from 'vitest/config';
11
11
  * - Node.js environment by default
12
12
  * - Globals enabled for cleaner test syntax
13
13
  * - Standard reporter configuration
14
+ * - Optimized test execution settings
15
+ *
16
+ * Note: Type checking should be run separately using `vitest typecheck` command
17
+ * for better performance, rather than enabling it in the test configuration.
14
18
  *
15
19
  * @example
16
20
  * ```ts
@@ -23,6 +27,6 @@ import { UserConfig } from 'vitest/config';
23
27
  * });
24
28
  * ```
25
29
  */
26
- declare const config: UserConfig;
30
+ declare const config: vite.UserConfig;
27
31
 
28
32
  export { config as default };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UserConfig } from 'vitest/config';
1
+ import * as vite from 'vite';
2
2
 
3
3
  /**
4
4
  * Base Vitest configuration with TypeScript support, coverage settings, and sensible defaults.
@@ -11,6 +11,10 @@ import { UserConfig } from 'vitest/config';
11
11
  * - Node.js environment by default
12
12
  * - Globals enabled for cleaner test syntax
13
13
  * - Standard reporter configuration
14
+ * - Optimized test execution settings
15
+ *
16
+ * Note: Type checking should be run separately using `vitest typecheck` command
17
+ * for better performance, rather than enabling it in the test configuration.
14
18
  *
15
19
  * @example
16
20
  * ```ts
@@ -23,6 +27,6 @@ import { UserConfig } from 'vitest/config';
23
27
  * });
24
28
  * ```
25
29
  */
26
- declare const config: UserConfig;
30
+ declare const config: vite.UserConfig;
27
31
 
28
32
  export { config as default };
package/dist/index.js CHANGED
@@ -1,10 +1,15 @@
1
1
  // src/index.ts
2
- var config = {
2
+ import { defineConfig } from "vitest/config";
3
+ var config = defineConfig({
3
4
  test: {
4
5
  // Enable globals for cleaner test syntax (e.g., describe, it, expect without imports)
5
6
  globals: true,
6
7
  // Use Node.js environment by default
7
8
  environment: "node",
9
+ // Test timeout (5 seconds default, can be overridden)
10
+ testTimeout: 5e3,
11
+ // Hook timeout (10 seconds for setup/teardown)
12
+ hookTimeout: 1e4,
8
13
  // Coverage configuration
9
14
  coverage: {
10
15
  // Use v8 provider for coverage (default, but explicit for clarity)
@@ -29,7 +34,7 @@ var config = {
29
34
  "**/*.test.{ts,tsx,js,jsx}",
30
35
  "**/*.spec.{ts,tsx,js,jsx}"
31
36
  ],
32
- // Coverage reporters
37
+ // Coverage reporters (HTML is valid here for coverage reports)
33
38
  reporter: ["text", "json", "html"]
34
39
  },
35
40
  // Test file patterns
@@ -42,14 +47,25 @@ var config = {
42
47
  "**/.{idea,git,cache,output,temp}/**",
43
48
  "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*"
44
49
  ],
45
- // Reporter configuration
46
- reporters: ["verbose", "json", "html"],
47
- // TypeScript configuration
48
- typecheck: {
49
- enabled: true
50
+ // Test reporter configuration (HTML is only for coverage, not test reporters)
51
+ // Use 'verbose' for detailed output, 'basic' for minimal, 'dot' for dots, 'json' for CI/CD
52
+ reporters: ["verbose"],
53
+ // Pool configuration for test execution
54
+ // threads: faster but may have issues with shared state
55
+ // forks: more isolated but slower
56
+ // Use threads by default for better performance
57
+ pool: "threads",
58
+ // Pool options for better performance
59
+ poolOptions: {
60
+ threads: {
61
+ // Use all available CPUs minus 1 to leave one for the system
62
+ minThreads: 1,
63
+ maxThreads: void 0
64
+ // Let Vitest decide based on available CPUs
65
+ }
50
66
  }
51
67
  }
52
- };
68
+ });
53
69
  var index_default = config;
54
70
  export {
55
71
  index_default as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmlweb/vitest-config",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Base Vitest configuration for jmlweb projects with TypeScript support and coverage settings",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -8,31 +8,27 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
- "require": {
12
- "types": "./dist/index.d.cts",
13
- "default": "./dist/index.cjs"
14
- },
15
11
  "import": {
16
12
  "types": "./dist/index.d.ts",
17
13
  "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
18
  }
19
19
  }
20
20
  },
21
21
  "files": [
22
22
  "dist",
23
- "README.md"
23
+ "README.md",
24
+ "CHANGELOG.md"
24
25
  ],
25
- "scripts": {
26
- "build": "tsup",
27
- "clean": "rm -rf dist",
28
- "prepublishOnly": "pnpm build"
29
- },
30
26
  "keywords": [
31
- "vitest",
32
- "vitest-config",
33
- "testing",
27
+ "coverage",
34
28
  "test-config",
35
- "coverage"
29
+ "testing",
30
+ "vitest",
31
+ "vitest-config"
36
32
  ],
37
33
  "author": "jmlweb",
38
34
  "license": "MIT",
@@ -40,9 +36,7 @@
40
36
  "type": "git",
41
37
  "url": "https://github.com/jmlweb/tooling.git"
42
38
  },
43
- "bugs": {
44
- "url": "https://github.com/jmlweb/tooling/issues"
45
- },
39
+ "bugs": "https://github.com/jmlweb/tooling/issues",
46
40
  "homepage": "https://github.com/jmlweb/tooling/tree/main/packages/vitest-config#readme",
47
41
  "engines": {
48
42
  "node": ">=18.0.0"
@@ -51,12 +45,16 @@
51
45
  "access": "public"
52
46
  },
53
47
  "peerDependencies": {
54
- "vitest": "^1.0.0"
48
+ "vitest": ">=1.0.0"
55
49
  },
56
50
  "devDependencies": {
57
- "@jmlweb/tsconfig-internal": "workspace:*",
58
51
  "tsup": "^8.5.1",
59
52
  "typescript": "^5.9.3",
60
- "vitest": "^2.1.8"
53
+ "vitest": "^2.1.8",
54
+ "@jmlweb/tsconfig-internal": "0.0.1"
55
+ },
56
+ "scripts": {
57
+ "build": "tsup",
58
+ "clean": "rm -rf dist"
61
59
  }
62
- }
60
+ }