@abelspithost/vitest-config 0.1.0 → 0.2.0

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 CHANGED
@@ -11,7 +11,7 @@ aliases.
11
11
 
12
12
  ## Requirements
13
13
 
14
- - Node.js 24 or newer
14
+ - Node.js 26 or newer
15
15
  - Vitest 5.0.0 or newer
16
16
 
17
17
  ## Installation
@@ -35,6 +35,22 @@ export default createVitestConfig();
35
35
  The configuration resolves the `@` alias to your project's `src` directory.
36
36
  For example, `@/utils/format` resolves to `src/utils/format`.
37
37
 
38
+ Pass a Vitest configuration object to customize the defaults:
39
+
40
+ ```ts
41
+ export default createVitestConfig({
42
+ test: {
43
+ pool: 'forks',
44
+ globals: false,
45
+ },
46
+ });
47
+ ```
48
+
49
+ The function merges your options with the preset using Vite's `mergeConfig`.
50
+ Nested objects merge, consumer values override scalar defaults, and arrays
51
+ concatenate. For example, a custom `test.include` pattern adds to the default
52
+ `**/*.spec.ts` pattern rather than replacing it.
53
+
38
54
  ## Defaults
39
55
 
40
56
  `createVitestConfig` applies these settings:
@@ -47,7 +63,7 @@ For example, `@/utils/format` resolves to `src/utils/format`.
47
63
  | Globals | Enabled |
48
64
  | Pool | `threads` |
49
65
  | Mock clearing | Enabled |
50
- | Coverage reporters | `json-summary`, `json` |
66
+ | Coverage reporters | `json-summary`, `json`, `lcov` |
51
67
  | Coverage on failure | Enabled |
52
68
  | Coverage exclusion | `**/constants/**` |
53
69
  | Branch threshold | 90% |
package/dist/index.d.ts CHANGED
@@ -1,2 +1,11 @@
1
- export declare function createVitestConfig(): import("vite").UserConfig;
1
+ import { type ViteUserConfig } from 'vitest/config';
2
+ /**
3
+ * Creates a Vitest configuration with shared test and coverage defaults.
4
+ *
5
+ * @param overrides - Vitest options to merge with the preset defaults
6
+ * @returns A configuration that resolves `@` to the project's `src` directory
7
+ * and sets the test environment, discovery patterns, mock handling, and
8
+ * coverage thresholds.
9
+ */
10
+ export declare function createVitestConfig(overrides?: ViteUserConfig): ViteUserConfig;
2
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,8BA+BjC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAEvB;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,GAAE,cAAmB,GAAG,cAAc,CAqCjF"}
package/dist/index.js CHANGED
@@ -1,7 +1,15 @@
1
1
  import { join } from 'node:path';
2
- import { defineConfig } from 'vitest/config';
3
- export function createVitestConfig() {
4
- return defineConfig({
2
+ import { defineConfig, mergeConfig, } from 'vitest/config';
3
+ /**
4
+ * Creates a Vitest configuration with shared test and coverage defaults.
5
+ *
6
+ * @param overrides - Vitest options to merge with the preset defaults
7
+ * @returns A configuration that resolves `@` to the project's `src` directory
8
+ * and sets the test environment, discovery patterns, mock handling, and
9
+ * coverage thresholds.
10
+ */
11
+ export function createVitestConfig(overrides = {}) {
12
+ const defaultConfig = defineConfig({
5
13
  resolve: {
6
14
  alias: {
7
15
  '@': join(process.cwd(), './src'),
@@ -10,7 +18,11 @@ export function createVitestConfig() {
10
18
  test: {
11
19
  clearMocks: true,
12
20
  coverage: {
13
- reporter: ['json-summary', 'json', 'lcov'],
21
+ reporter: [
22
+ 'json-summary',
23
+ 'json',
24
+ 'lcov',
25
+ ],
14
26
  reportOnFailure: true,
15
27
  exclude: ['**/constants/**'],
16
28
  thresholds: {
@@ -26,5 +38,6 @@ export function createVitestConfig() {
26
38
  pool: 'threads',
27
39
  },
28
40
  });
41
+ return mergeConfig(defaultConfig, overrides);
29
42
  }
30
43
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,UAAU,kBAAkB;IAChC,OAAO,YAAY,CAAC;QAClB,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC;aAClC;SACF;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,IAAI;YAEhB,QAAQ,EAAE;gBACR,QAAQ,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC;gBAC1C,eAAe,EAAE,IAAI;gBACrB,OAAO,EAAE,CAAC,iBAAiB,CAAC;gBAC5B,UAAU,EAAE;oBACV,QAAQ,EAAE,EAAE;oBACZ,SAAS,EAAE,EAAE;oBACb,KAAK,EAAE,EAAE;iBACV;aACF;YAED,WAAW,EAAE,MAAM;YAEnB,OAAO,EAAE,CAAC,cAAc,CAAC;YACzB,OAAO,EAAE,CAAC,MAAM,EAAC,cAAc,CAAC;YAEhC,OAAO,EAAE,IAAI;YAEb,IAAI,EAAE,SAAS;SAChB;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACgB,YAAY,EAAE,WAAW,GAC/C,MAAM,eAAe,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,YAA4B,EAAE;IAC/D,MAAM,aAAa,GAAG,YAAY,CAAC;QACjC,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC;aAClC;SACF;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,IAAI;YAEhB,QAAQ,EAAE;gBACR,QAAQ,EAAE;oBACR,cAAc;oBACd,MAAM;oBACN,MAAM;iBACP;gBACD,eAAe,EAAE,IAAI;gBACrB,OAAO,EAAE,CAAC,iBAAiB,CAAC;gBAC5B,UAAU,EAAE;oBACV,QAAQ,EAAE,EAAE;oBACZ,SAAS,EAAE,EAAE;oBACb,KAAK,EAAE,EAAE;iBACV;aACF;YAED,WAAW,EAAE,MAAM;YAEnB,OAAO,EAAE,CAAC,cAAc,CAAC;YACzB,OAAO,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC;YAEjC,OAAO,EAAE,IAAI;YAEb,IAAI,EAAE,SAAS;SAChB;KACF,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;AAC/C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abelspithost/vitest-config",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Shared Vitest configuration preset for TypeScript projects",
5
5
  "keywords": [
6
6
  "vitest",
@@ -29,7 +29,7 @@
29
29
  "dist"
30
30
  ],
31
31
  "engines": {
32
- "node": ">=24"
32
+ "node": ">=26"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "npm run clean && tsc -p tsconfig.build.json && npm run deps:check",
@@ -46,17 +46,17 @@
46
46
  "vitest": ">=5.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@abelspithost/commitlint": "^0.1.7",
50
- "@abelspithost/eslint-config-ts": "^2.0.0",
51
- "@abelspithost/tsconfig-node": "^0.1.1",
52
- "@commitlint/cli": "^21.2.3",
53
- "@types/node": "^24.19.1",
54
- "commitlint": "^21.2.3",
55
- "eslint": "^10.11.0",
49
+ "@abelspithost/commitlint": "^0.2.0",
50
+ "@abelspithost/eslint-config-ts": "^3.2.0",
51
+ "@abelspithost/tsconfig-node": "^0.1.2",
52
+ "@commitlint/cli": "^21.2.4",
53
+ "@types/node": "^26.6.6",
54
+ "commitlint": "^21.2.4",
55
+ "eslint": "^10.14.0",
56
56
  "husky": "^9.1.7",
57
57
  "jiti": "^2.7.0",
58
- "rimraf": "^6.1.3",
58
+ "rimraf": "^6.1.4",
59
59
  "typescript": "^6.0.3",
60
- "vitest": "^5.0.3"
60
+ "vitest": "^5.1.0"
61
61
  }
62
- }
62
+ }