@rexezuge/tooling 1.2.0 → 1.4.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 +66 -10
- package/dist/eslint-boundaries.d.ts +31 -7
- package/dist/eslint-boundaries.d.ts.map +1 -1
- package/dist/eslint-boundaries.js +1 -138
- package/dist/eslint-boundaries.js.map +7 -1
- package/dist/eslint-rules.js +1 -273
- package/dist/eslint-rules.js.map +7 -1
- package/dist/eslint.d.ts +12 -7
- package/dist/eslint.d.ts.map +1 -1
- package/dist/eslint.js +1 -189
- package/dist/eslint.js.map +7 -1
- package/dist/functions/pages-proxy.d.ts.map +1 -1
- package/dist/functions/pages-proxy.js +1 -131
- package/dist/functions/pages-proxy.js.map +7 -1
- package/dist/index.d.ts +20 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -28
- package/dist/index.js.map +7 -1
- package/dist/scripts/backup/d1-target.d.ts +15 -5
- package/dist/scripts/backup/d1-target.d.ts.map +1 -1
- package/dist/scripts/backup/d1-target.js +1 -31
- package/dist/scripts/backup/d1-target.js.map +7 -1
- package/dist/scripts/backup/destination-config.d.ts +24 -8
- package/dist/scripts/backup/destination-config.d.ts.map +1 -1
- package/dist/scripts/backup/destination-config.js +1 -57
- package/dist/scripts/backup/destination-config.js.map +7 -1
- package/dist/scripts/backup/encrypt-backup.js +2 -97
- package/dist/scripts/backup/encrypt-backup.js.map +7 -1
- package/dist/scripts/backup/naming.d.ts +3 -1
- package/dist/scripts/backup/naming.d.ts.map +1 -1
- package/dist/scripts/backup/naming.js +1 -58
- package/dist/scripts/backup/naming.js.map +7 -1
- package/dist/scripts/check-god-files.d.ts +40 -14
- package/dist/scripts/check-god-files.d.ts.map +1 -1
- package/dist/scripts/check-god-files.js +2 -271
- package/dist/scripts/check-god-files.js.map +7 -1
- package/dist/scripts/ensure-spa-shell-stub.js +1 -29
- package/dist/scripts/ensure-spa-shell-stub.js.map +7 -1
- package/dist/scripts/init-secrets.d.ts +0 -16
- package/dist/scripts/init-secrets.d.ts.map +1 -1
- package/dist/scripts/init-secrets.js +2 -239
- package/dist/scripts/init-secrets.js.map +7 -1
- package/dist/scripts/lib/cli-args.d.ts.map +1 -1
- package/dist/scripts/lib/cli-args.js +1 -116
- package/dist/scripts/lib/cli-args.js.map +7 -1
- package/dist/scripts/lib/github-actions.js +3 -38
- package/dist/scripts/lib/github-actions.js.map +7 -1
- package/dist/scripts/lib/wrangler-table.d.ts.map +1 -1
- package/dist/scripts/lib/wrangler-table.js +2 -99
- package/dist/scripts/lib/wrangler-table.js.map +7 -1
- package/dist/scripts/migrations-lock.js +1 -44
- package/dist/scripts/migrations-lock.js.map +7 -1
- package/dist/scripts/prepare-wrangler-config.js +1 -49
- package/dist/scripts/prepare-wrangler-config.js.map +7 -1
- package/dist/scripts/spa-shell.d.ts +12 -4
- package/dist/scripts/spa-shell.d.ts.map +1 -1
- package/dist/scripts/spa-shell.js +3 -160
- package/dist/scripts/spa-shell.js.map +7 -1
- package/dist/scripts/validate-locales.d.ts +13 -5
- package/dist/scripts/validate-locales.d.ts.map +1 -1
- package/dist/scripts/validate-locales.js +4 -350
- package/dist/scripts/validate-locales.js.map +7 -1
- package/dist/scripts/verify-migrations.d.ts +27 -9
- package/dist/scripts/verify-migrations.d.ts.map +1 -1
- package/dist/scripts/verify-migrations.js +2 -312
- package/dist/scripts/verify-migrations.js.map +7 -1
- package/dist/scripts/verify-spa-shell.js +1 -52
- package/dist/scripts/verify-spa-shell.js.map +7 -1
- package/dist/scripts/wrangler-config/cli.js +3 -51
- package/dist/scripts/wrangler-config/cli.js.map +7 -1
- package/dist/scripts/wrangler-config/patches.d.ts +10 -4
- package/dist/scripts/wrangler-config/patches.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/patches.js +4 -141
- package/dist/scripts/wrangler-config/patches.js.map +7 -1
- package/dist/scripts/wrangler-config/resources.d.ts +19 -7
- package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/resources.js +1 -290
- package/dist/scripts/wrangler-config/resources.js.map +7 -1
- package/dist/scripts/wrangler-config/types.d.ts +24 -8
- package/dist/scripts/wrangler-config/types.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/types.js +1 -49
- package/dist/scripts/wrangler-config/types.js.map +7 -1
- package/dist/test/integration-migrations.d.ts +29 -12
- package/dist/test/integration-migrations.d.ts.map +1 -1
- package/dist/test/integration-migrations.js +2 -171
- package/dist/test/integration-migrations.js.map +7 -1
- package/dist/test/mocks/cloudflare-workers.js +1 -90
- package/dist/test/mocks/cloudflare-workers.js.map +7 -1
- package/dist/vite.d.ts +5 -3
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +3 -125
- package/dist/vite.js.map +7 -1
- package/dist/vitest-aliases.d.ts +90 -0
- package/dist/vitest-aliases.d.ts.map +1 -0
- package/dist/vitest-aliases.js +1 -0
- package/dist/vitest-aliases.js.map +7 -0
- package/dist/vitest-integration.d.ts +96 -0
- package/dist/vitest-integration.d.ts.map +1 -0
- package/dist/vitest-integration.js +1 -0
- package/dist/vitest-integration.js.map +7 -0
- package/dist/vitest-repo.d.ts +154 -0
- package/dist/vitest-repo.d.ts.map +1 -0
- package/dist/vitest-repo.js +1 -0
- package/dist/vitest-repo.js.map +7 -0
- package/dist/vitest-web.d.ts +76 -19
- package/dist/vitest-web.d.ts.map +1 -1
- package/dist/vitest-web.js +1 -72
- package/dist/vitest-web.js.map +7 -1
- package/dist/vitest.d.ts +70 -19
- package/dist/vitest.d.ts.map +1 -1
- package/dist/vitest.js +1 -128
- package/dist/vitest.js.map +7 -1
- package/package.json +9 -3
- package/src/eslint-boundaries.ts +112 -11
- package/src/eslint.test.ts +40 -9
- package/src/eslint.ts +14 -9
- package/src/functions/pages-proxy.test.ts +3 -3
- package/src/functions/pages-proxy.ts +4 -2
- package/src/index.ts +23 -14
- package/src/scripts/backup/backup-rules.test.ts +4 -4
- package/src/scripts/backup/d1-target.ts +16 -6
- package/src/scripts/backup/destination-config.ts +27 -9
- package/src/scripts/backup/encrypt-backup.ts +12 -10
- package/src/scripts/backup/naming.ts +3 -1
- package/src/scripts/check-god-files.test.ts +19 -19
- package/src/scripts/check-god-files.ts +62 -33
- package/src/scripts/ensure-spa-shell-stub.ts +1 -1
- package/src/scripts/init-secrets.ts +20 -10
- package/src/scripts/lib/cli-args.ts +6 -3
- package/src/scripts/lib/wrangler-table.ts +5 -3
- package/src/scripts/migrations-lock.ts +2 -2
- package/src/scripts/prepare-wrangler-config.ts +3 -3
- package/src/scripts/spa-shell.test.ts +18 -18
- package/src/scripts/spa-shell.ts +26 -14
- package/src/scripts/validate-locales.test.ts +18 -18
- package/src/scripts/validate-locales.ts +43 -25
- package/src/scripts/verify-migrations.test.ts +8 -8
- package/src/scripts/verify-migrations.ts +47 -24
- package/src/scripts/verify-spa-shell.ts +1 -1
- package/src/scripts/wrangler-config/patches.ts +13 -5
- package/src/scripts/wrangler-config/resources.ts +34 -18
- package/src/scripts/wrangler-config/types.ts +24 -8
- package/src/test/integration-migrations.test.ts +7 -7
- package/src/test/integration-migrations.ts +33 -14
- package/src/vite.test.ts +25 -14
- package/src/vite.ts +5 -5
- package/src/vitest-aliases.test.ts +53 -0
- package/src/vitest-aliases.ts +125 -0
- package/src/vitest-factories.test.ts +127 -0
- package/src/vitest-integration.ts +118 -0
- package/src/vitest-repo.ts +269 -0
- package/src/vitest-web.ts +110 -28
- package/src/vitest.ts +96 -47
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single-file `projects` composition: backend (`node`) plus SPA (DOM).
|
|
3
|
+
*
|
|
4
|
+
* Provenance: AWS-AccessBridge (split by `.ts`/`.tsx` extension),
|
|
5
|
+
* Mail-Meow (split by `test/web/**` directory, with per-project `setupFiles`
|
|
6
|
+
* and the React plugin on the web project), CalDAV-Bridge (split by directory
|
|
7
|
+
* with `happy-dom`). The two-file repos (Durable-DAV-Router, Mail-Otter) keep
|
|
8
|
+
* `defineUnitVitestConfig()` + `defineWebVitestConfig()`; this factory is the
|
|
9
|
+
* same two halves as `projects` entries in one file, sharing one root coverage
|
|
10
|
+
* gate.
|
|
11
|
+
*
|
|
12
|
+
* Canonical decisions (all three sources agree):
|
|
13
|
+
*
|
|
14
|
+
* 1. **Coverage lives at the root**, not per project: one floor for the whole
|
|
15
|
+
* unit suite. (Durable-DAV-Router's warning about a shared floor stands for
|
|
16
|
+
* the two-file split; within one file the three sources all gate once.)
|
|
17
|
+
* 2. **Each project repeats the alias table.** Vitest projects do not inherit
|
|
18
|
+
* the root `resolve` (Mail-Meow), so a suite resolving `@scope/*`
|
|
19
|
+
* differently from its sibling fails like a product bug. Both entries carry
|
|
20
|
+
* the full table — backend with `@/` → API, web with `@/` + `~/` → SPA.
|
|
21
|
+
* 3. **The web project keeps `pool: 'threads'`** and its DOM from
|
|
22
|
+
* `defineWebVitestConfig()`; the backend project keeps `environment:
|
|
23
|
+
* 'node'` and `server.deps.inline` from `defineUnitVitestConfig()`.
|
|
24
|
+
*/
|
|
25
|
+
import { defineConfig, type Plugin } from 'vitest/config';
|
|
26
|
+
import type { VitestAlias } from './vitest-aliases.ts';
|
|
27
|
+
import type { CoverageThresholds } from './vitest.ts';
|
|
28
|
+
/**
|
|
29
|
+
* The backend half of the `projects` pair.
|
|
30
|
+
*/
|
|
31
|
+
export interface RepoBackendOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Which suites to collect. Defaults to the whole unit suite minus SPA and
|
|
34
|
+
* integration shapes.
|
|
35
|
+
*/
|
|
36
|
+
readonly include?: readonly string[];
|
|
37
|
+
/**
|
|
38
|
+
* Suite paths to skip, replacing the default.
|
|
39
|
+
*/
|
|
40
|
+
readonly exclude?: readonly string[];
|
|
41
|
+
/**
|
|
42
|
+
* Setup files run before each backend test file.
|
|
43
|
+
*/
|
|
44
|
+
readonly setupFiles?: readonly string[];
|
|
45
|
+
/**
|
|
46
|
+
* `node_modules` specifiers to inline through Vite. Defaults to `['dofs']`.
|
|
47
|
+
*/
|
|
48
|
+
readonly serverDepsInline?: readonly string[];
|
|
49
|
+
/**
|
|
50
|
+
* Extra resolver entries for the backend project only.
|
|
51
|
+
*/
|
|
52
|
+
readonly aliases?: readonly VitestAlias[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The SPA half of the `projects` pair.
|
|
56
|
+
*/
|
|
57
|
+
export interface RepoWebOptions {
|
|
58
|
+
/**
|
|
59
|
+
* The DOM implementation. `jsdom` is the family default; `happy-dom` is
|
|
60
|
+
* CalDAV-Bridge's.
|
|
61
|
+
*/
|
|
62
|
+
readonly environment?: 'jsdom' | 'happy-dom';
|
|
63
|
+
/**
|
|
64
|
+
* Which suites to collect. Defaults to every SPA shape the family uses.
|
|
65
|
+
*/
|
|
66
|
+
readonly include?: readonly string[];
|
|
67
|
+
/**
|
|
68
|
+
* Suite paths to skip, replacing the default.
|
|
69
|
+
*/
|
|
70
|
+
readonly exclude?: readonly string[];
|
|
71
|
+
/**
|
|
72
|
+
* Setup files run before each SPA test file.
|
|
73
|
+
*/
|
|
74
|
+
readonly setupFiles?: readonly string[];
|
|
75
|
+
/**
|
|
76
|
+
* Vite plugins the SPA needs (`react()` for JSX).
|
|
77
|
+
*/
|
|
78
|
+
readonly plugins?: readonly Plugin[];
|
|
79
|
+
/**
|
|
80
|
+
* Extra resolver entries for the web project only.
|
|
81
|
+
*/
|
|
82
|
+
readonly aliases?: readonly VitestAlias[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* What `defineRepoVitestConfig` accepts.
|
|
86
|
+
*/
|
|
87
|
+
export interface RepoVitestConfigOptions {
|
|
88
|
+
/**
|
|
89
|
+
* The consuming repo's npm scope, e.g. `'@myapp'`.
|
|
90
|
+
*/
|
|
91
|
+
readonly scope: string;
|
|
92
|
+
/**
|
|
93
|
+
* Workspace package directory names. Defaults to the family superset.
|
|
94
|
+
*/
|
|
95
|
+
readonly packages?: readonly string[];
|
|
96
|
+
/**
|
|
97
|
+
* Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.
|
|
98
|
+
*/
|
|
99
|
+
readonly mocks?: readonly string[];
|
|
100
|
+
/**
|
|
101
|
+
* The repo root, as a file URL.
|
|
102
|
+
*/
|
|
103
|
+
readonly root?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Extra resolver entries applied to *both* projects (e.g. the `hono`
|
|
106
|
+
* dedupe). Per-project extras go on `backend.aliases` / `web.aliases`.
|
|
107
|
+
*/
|
|
108
|
+
readonly aliases?: readonly VitestAlias[];
|
|
109
|
+
/**
|
|
110
|
+
* Resolver `noExternal` patterns, merged after {@link KIT_NO_EXTERNAL}.
|
|
111
|
+
*/
|
|
112
|
+
readonly noExternal?: readonly (string | RegExp)[];
|
|
113
|
+
/**
|
|
114
|
+
* The backend half. Omitted fields take the `defineUnitVitestConfig`
|
|
115
|
+
* defaults.
|
|
116
|
+
*/
|
|
117
|
+
readonly backend?: RepoBackendOptions;
|
|
118
|
+
/**
|
|
119
|
+
* The SPA half. Omitted fields take the `defineWebVitestConfig` defaults.
|
|
120
|
+
*/
|
|
121
|
+
readonly web?: RepoWebOptions;
|
|
122
|
+
/**
|
|
123
|
+
* Coverage `include` globs. Defaults to the worker, the SPA and every
|
|
124
|
+
* workspace package's `src`.
|
|
125
|
+
*/
|
|
126
|
+
readonly coverageInclude?: readonly string[];
|
|
127
|
+
/**
|
|
128
|
+
* Coverage `exclude` globs, merged with the canonical set.
|
|
129
|
+
*/
|
|
130
|
+
readonly coverageExclude?: readonly string[];
|
|
131
|
+
/**
|
|
132
|
+
* Coverage floors. Omitted by default; a repo that wants them sets them.
|
|
133
|
+
*/
|
|
134
|
+
readonly thresholds?: CoverageThresholds;
|
|
135
|
+
/**
|
|
136
|
+
* Where the coverage report is written.
|
|
137
|
+
*/
|
|
138
|
+
readonly reportsDirectory?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Build the single-file `projects` config.
|
|
142
|
+
*
|
|
143
|
+
* ```ts
|
|
144
|
+
* // vitest.config.mts
|
|
145
|
+
* import { defineRepoVitestConfig } from '@rexezuge/tooling/vitest-repo';
|
|
146
|
+
* export default defineRepoVitestConfig({
|
|
147
|
+
* scope: '@myapp',
|
|
148
|
+
* web: { environment: 'happy-dom' },
|
|
149
|
+
* thresholds: { statements: 87, branches: 77, functions: 88, lines: 90 },
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare function defineRepoVitestConfig(options: RepoVitestConfigOptions): ReturnType<typeof defineConfig>;
|
|
154
|
+
//# sourceMappingURL=vitest-repo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest-repo.d.ts","sourceRoot":"","sources":["../src/vitest-repo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,GA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,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAsCD;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAyExG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineConfig as u}from"vitest/config";import{fileURLToPath as m}from"node:url";import{DEFAULT_CLOUDFLARE_MOCKS as b,DEFAULT_WORKSPACE_PACKAGES as f,KIT_NO_EXTERNAL as E,workspaceAliases as d}from"./vitest-aliases.js";const g=["**/node_modules/**","**/dist/**","test/integration/**","test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],x=["test/web/**/*.test.{ts,tsx}","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],v=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/types.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"];function L(e){const r=e.root??new URL(".",import.meta.url).href,n=e.packages??f,c=e.mocks??b,l=[...E,...e.noExternal??[]],t=e.backend??{},s=e.web??{},i=[...d({scope:e.scope,root:r,packages:n,mocks:c}),...e.aliases??[],...t.aliases??[]],a=m(new URL("apps/web/src",r)),o=[{find:/^@\//,replacement:`${a}/`},{find:/^~\//,replacement:`${a}/`},...d({scope:e.scope,root:r,packages:n,mocks:c}).filter(p=>typeof p.find=="string"),...e.aliases??[],...s.aliases??[]];return u({test:{projects:[{resolve:{alias:i,noExternal:l},test:{name:"backend",globals:!0,environment:"node",include:[...t.include??["test/**/*.test.{ts,tsx}"]],exclude:[...t.exclude??g],...t.setupFiles!==void 0&&{setupFiles:[...t.setupFiles]},server:{deps:{inline:[...t.serverDepsInline??["dofs"]]}}}},{...s.plugins!==void 0&&{plugins:[...s.plugins]},resolve:{alias:o,noExternal:l},test:{name:"web",globals:!0,environment:s.environment??"jsdom",include:[...s.include??x],exclude:[...s.exclude??["**/node_modules/**","**/dist/**","test/integration/**"]],pool:"threads",...s.setupFiles!==void 0&&{setupFiles:[...s.setupFiles]}}}],coverage:{provider:"v8",reporter:["text","lcov","html"],reportsDirectory:e.reportsDirectory??"./coverage",include:[...e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","apps/web/src/**/*.{ts,tsx}","packages/**/src/**/*.ts"]],exclude:[...v,...e.coverageExclude??[]],...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}export{L as defineRepoVitestConfig};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/vitest-repo.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The single-file `projects` composition: backend (`node`) plus SPA (DOM).\n *\n * Provenance: AWS-AccessBridge (split by `.ts`/`.tsx` extension),\n * Mail-Meow (split by `test/web/**` directory, with per-project `setupFiles`\n * and the React plugin on the web project), CalDAV-Bridge (split by directory\n * with `happy-dom`). The two-file repos (Durable-DAV-Router, Mail-Otter) keep\n * `defineUnitVitestConfig()` + `defineWebVitestConfig()`; this factory is the\n * same two halves as `projects` entries in one file, sharing one root coverage\n * gate.\n *\n * Canonical decisions (all three sources agree):\n *\n * 1. **Coverage lives at the root**, not per project: one floor for the whole\n * unit suite. (Durable-DAV-Router's warning about a shared floor stands for\n * the two-file split; within one file the three sources all gate once.)\n * 2. **Each project repeats the alias table.** Vitest projects do not inherit\n * the root `resolve` (Mail-Meow), so a suite resolving `@scope/*`\n * differently from its sibling fails like a product bug. Both entries carry\n * the full table — backend with `@/` → API, web with `@/` + `~/` → SPA.\n * 3. **The web project keeps `pool: 'threads'`** and its DOM from\n * `defineWebVitestConfig()`; the backend project keeps `environment:\n * 'node'` and `server.deps.inline` from `defineUnitVitestConfig()`.\n */\n\nimport { defineConfig, type Plugin } from 'vitest/config';\nimport { fileURLToPath } from 'node:url';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\nimport type { CoverageThresholds } from './vitest.ts';\n\n/**\n * The backend half of the `projects` pair.\n */\nexport interface RepoBackendOptions {\n /**\n * Which suites to collect. Defaults to the whole unit suite minus SPA and\n * integration shapes.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default.\n */\n readonly exclude?: readonly string[];\n /**\n * Setup files run before each backend test file.\n */\n readonly setupFiles?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite. Defaults to `['dofs']`.\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Extra resolver entries for the backend project only.\n */\n readonly aliases?: readonly VitestAlias[];\n}\n\n/**\n * The SPA half of the `projects` pair.\n */\nexport interface RepoWebOptions {\n /**\n * The DOM implementation. `jsdom` is the family default; `happy-dom` is\n * CalDAV-Bridge's.\n */\n readonly environment?: 'jsdom' | 'happy-dom';\n /**\n * Which suites to collect. Defaults to every SPA shape the family uses.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default.\n */\n readonly exclude?: readonly string[];\n /**\n * Setup files run before each SPA test file.\n */\n readonly setupFiles?: readonly string[];\n /**\n * Vite plugins the SPA needs (`react()` for JSX).\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Extra resolver entries for the web project only.\n */\n readonly aliases?: readonly VitestAlias[];\n}\n\n/**\n * What `defineRepoVitestConfig` accepts.\n */\nexport interface RepoVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`.\n */\n readonly scope: string;\n /**\n * Workspace package directory names. Defaults to the family superset.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * The repo root, as a file URL.\n */\n readonly root?: string;\n /**\n * Extra resolver entries applied to *both* projects (e.g. the `hono`\n * dedupe). Per-project extras go on `backend.aliases` / `web.aliases`.\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Resolver `noExternal` patterns, merged after {@link KIT_NO_EXTERNAL}.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * The backend half. Omitted fields take the `defineUnitVitestConfig`\n * defaults.\n */\n readonly backend?: RepoBackendOptions;\n /**\n * The SPA half. Omitted fields take the `defineWebVitestConfig` defaults.\n */\n readonly web?: RepoWebOptions;\n /**\n * Coverage `include` globs. Defaults to the worker, the SPA and every\n * workspace package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Coverage floors. Omitted by default; a repo that wants them sets them.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * Backend suites excluded from the backend project: the SPA shapes live in the\n * web project, and integration is its own config.\n */\nconst BACKEND_EXCLUDE: readonly string[] = [\n '**/node_modules/**',\n '**/dist/**',\n 'test/integration/**',\n 'test/web/**',\n 'test/**/web-*.test.{ts,tsx}',\n 'apps/web/**/*.test.{ts,tsx}',\n];\n\n/**\n * SPA suite shapes collected by the web project.\n */\nconst WEB_INCLUDE: readonly string[] = ['test/web/**/*.test.{ts,tsx}', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude`: the union of the unit and web halves' canonical sets.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/types.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * Build the single-file `projects` config.\n *\n * ```ts\n * // vitest.config.mts\n * import { defineRepoVitestConfig } from '@rexezuge/tooling/vitest-repo';\n * export default defineRepoVitestConfig({\n * scope: '@myapp',\n * web: { environment: 'happy-dom' },\n * thresholds: { statements: 87, branches: 77, functions: 88, lines: 90 },\n * });\n * ```\n */\nexport function defineRepoVitestConfig(options: RepoVitestConfigOptions): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const noExternal = [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])];\n const backend = options.backend ?? {};\n const web = options.web ?? {};\n\n const backendAliases = [\n ...workspaceAliases({ scope: options.scope, root, packages, mocks }),\n ...(options.aliases ?? []),\n ...(backend.aliases ?? []),\n ];\n // `@/` means the SPA in the web project (Mail-Otter's SPA source imports\n // through it); the workspace table's `@/` → API entry is dropped and the\n // SPA's own prepended. `~/` → SPA either way.\n const webSrc = fileURLToPath(new URL('apps/web/src', root));\n const webAliases: VitestAlias[] = [\n { find: /^@\\//, replacement: `${webSrc}/` },\n { find: /^~\\//, replacement: `${webSrc}/` },\n // Drop the workspace table's `@/`/`~/` (RegExp) entries — the SPA's own\n // prepended above win — and keep the `@scope/*` + `cloudflare:*` strings.\n ...workspaceAliases({ scope: options.scope, root, packages, mocks }).filter((alias) => typeof alias.find === 'string'),\n ...(options.aliases ?? []),\n ...(web.aliases ?? []),\n ];\n\n return defineConfig({\n test: {\n projects: [\n {\n resolve: { alias: backendAliases, noExternal },\n test: {\n name: 'backend',\n globals: true,\n environment: 'node',\n include: [...(backend.include ?? ['test/**/*.test.{ts,tsx}'])],\n exclude: [...(backend.exclude ?? BACKEND_EXCLUDE)],\n ...(backend.setupFiles !== undefined && { setupFiles: [...backend.setupFiles] }),\n server: { deps: { inline: [...(backend.serverDepsInline ?? ['dofs'])] } },\n },\n },\n {\n ...(web.plugins !== undefined && { plugins: [...web.plugins] }),\n resolve: { alias: webAliases, noExternal },\n test: {\n name: 'web',\n globals: true,\n environment: web.environment ?? 'jsdom',\n include: [...(web.include ?? WEB_INCLUDE)],\n exclude: [...(web.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**'])],\n pool: 'threads',\n ...(web.setupFiles !== undefined && { setupFiles: [...web.setupFiles] }),\n },\n },\n ],\n coverage: {\n provider: 'v8',\n reporter: ['text', 'lcov', 'html'],\n reportsDirectory: options.reportsDirectory ?? './coverage',\n include: [\n ...(options.coverageInclude ?? [\n 'apps/api/src/**/*.ts',\n 'apps/background/src/**/*.ts',\n 'apps/web/src/**/*.{ts,tsx}',\n 'packages/**/src/**/*.ts',\n ]),\n ],\n exclude: [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])],\n ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),\n },\n },\n });\n}\n"],
|
|
5
|
+
"mappings": "AAyBA,OAAS,gBAAAA,MAAiC,gBAC1C,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,mBAAAC,EAAiB,oBAAAC,MAAwB,sBA2HxG,MAAMC,EAAqC,CACzC,qBACA,aACA,sBACA,cACA,8BACA,+BAMIC,EAAiC,CAAC,8BAA+B,8BAA+B,6BAA6B,EAK7HC,EAAgD,CACpD,aACA,eACA,gBACA,YACA,cACA,gBACA,cACA,cACA,kBACA,gBACA,mBACA,eAgBI,SAAUC,EAAuBC,EAAgC,CACrE,MAAMC,EAAOD,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDE,EAAWF,EAAQ,UAAYP,EAC/BU,EAAQH,EAAQ,OAASR,EACzBY,EAAa,CAAC,GAAGV,EAAiB,GAAIM,EAAQ,YAAc,CAAA,CAAG,EAC/DK,EAAUL,EAAQ,SAAW,CAAA,EAC7BM,EAAMN,EAAQ,KAAO,CAAA,EAErBO,EAAiB,CACrB,GAAGZ,EAAiB,CAAE,MAAOK,EAAQ,MAAO,KAAAC,EAAM,SAAAC,EAAU,MAAAC,C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AAC,GAAGA,EAAI,UAAU,CAAC,KAI3E,SAAU,CACR,SAAU,KACV,SAAU,CAAC,OAAQ,OAAQ,MAAM,EACjC,iBAAkBN,EAAQ,kBAAoB,aAC9C,QAAS,CACP,GAAIA,EAAQ,iBAAmB,CAC7B,uBACA,8BACA,6BACA,4BAGJ,QAAS,CAAC,GAAGF,EAA4B,GAAIE,EAAQ,iBAAmB,CAAA,CAAG,EAC3E,GAAIA,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,EAAQ,UAAU,CAAE,IAGpF,CACH",
|
|
6
|
+
"names": ["defineConfig", "fileURLToPath", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_NO_EXTERNAL", "workspaceAliases", "BACKEND_EXCLUDE", "WEB_INCLUDE", "CANONICAL_COVERAGE_EXCLUDE", "defineRepoVitestConfig", "options", "root", "packages", "mocks", "noExternal", "backend", "web", "backendAliases", "webSrc", "webAliases", "alias"]
|
|
7
|
+
}
|
package/dist/vitest-web.d.ts
CHANGED
|
@@ -1,36 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The SPA's test and coverage gate.
|
|
3
3
|
*
|
|
4
|
-
* Provenance: converged from Durable-DAV-Router's
|
|
5
|
-
* `vitest.web.config.mts
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `
|
|
4
|
+
* Provenance: converged from all nine repos' SPA suites — Durable-DAV-Router's
|
|
5
|
+
* and Mail-Otter's `vitest.web.config.mts` (the two repos that gave the frontend
|
|
6
|
+
* its own file), Mail-Meow's and CalDAV-Bridge's `projects` entries (the two
|
|
7
|
+
* that keep backend and SPA in one file), and AWS-AccessBridge's
|
|
8
|
+
* extension-split `dom` project. Durable-DAV-Router's file is the canonical
|
|
9
|
+
* shape — it is the one that records *why* the split exists; Mail-Otter's
|
|
10
|
+
* contributes the React plugin and the `apps/web/**` include; CalDAV-Bridge
|
|
11
|
+
* contributes `happy-dom` and the `test/web/**` directory convention;
|
|
12
|
+
* Mail-Meow contributes `setupFiles` and the note that projects do not inherit
|
|
13
|
+
* the root `resolve`.
|
|
9
14
|
*
|
|
10
15
|
* Canonical decisions:
|
|
11
16
|
*
|
|
12
|
-
* 1. **
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
17
|
+
* 1. **A DOM for every file here**, rather than a `@vitest-environment` pragma
|
|
18
|
+
* per file: these are the tests that need a DOM, and the pragma is one more
|
|
19
|
+
* place to forget. `jsdom` is the family default (seven repos);
|
|
20
|
+
* `happy-dom` is CalDAV-Bridge's, and is one option away.
|
|
16
21
|
* 2. **`pool: 'threads'`, bounded, rather than one forked worker per file.** Each
|
|
17
22
|
* jsdom document is a whole browser environment; a fork per file exhausts
|
|
18
23
|
* memory on a constrained machine, and when it does the run dies partway with
|
|
19
24
|
* a bare "Worker exited unexpectedly" and no test reports a failure — which
|
|
20
25
|
* reads as a flaky suite rather than as an out-of-memory kill.
|
|
21
|
-
* 3.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
26
|
+
* 3. **`include` covers every shape the family uses** — the `test/web/**`
|
|
27
|
+
* directory convention, the root-suite `web-*` naming convention, and suites
|
|
28
|
+
* bundled under `apps/web` — and the same globs are what
|
|
29
|
+
* `defineUnitVitestConfig()` excludes, so a file is collected by exactly one
|
|
30
|
+
* config.
|
|
31
|
+
* 4. **Projects do not inherit the root `resolve`** (Mail-Meow): a
|
|
32
|
+
* single-file `projects` composition must repeat the alias table per
|
|
33
|
+
* project. `defineRepoVitestConfig()` does that; two-file repos get it from
|
|
34
|
+
* these factories directly.
|
|
35
|
+
* 5. **`@/` means the SPA here, not the API worker.** The unit config maps
|
|
36
|
+
* `@/` to `apps/api/src`; this config maps both `@/` (Mail-Otter's SPA
|
|
37
|
+
* source) and `~/` (Mail-Meow's and CalDAV-Bridge's SPA tests) to
|
|
38
|
+
* `apps/web/src`. Workspace `@scope/*` imports still resolve to the
|
|
39
|
+
* packages, so web tests reach shared logic the same way backend tests do.
|
|
27
40
|
*/
|
|
28
41
|
import { defineConfig, type Plugin } from 'vitest/config';
|
|
29
|
-
import type {
|
|
42
|
+
import type { VitestAlias } from './vitest-aliases.ts';
|
|
43
|
+
import type { CoverageThresholds } from './vitest.ts';
|
|
30
44
|
/**
|
|
31
45
|
* What `defineWebVitestConfig` accepts.
|
|
32
46
|
*/
|
|
33
47
|
export interface WebVitestConfigOptions {
|
|
48
|
+
/**
|
|
49
|
+
* The consuming repo's npm scope, e.g. `'@myapp'`. When supplied, `@scope/*`
|
|
50
|
+
* workspace aliases are generated so web tests reach shared logic; when
|
|
51
|
+
* omitted, only the `cloudflare:*`, `@/` and `~/` aliases apply.
|
|
52
|
+
*/
|
|
53
|
+
readonly scope?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Workspace package directory names. Defaults to the family superset.
|
|
56
|
+
*/
|
|
57
|
+
readonly packages?: readonly string[];
|
|
58
|
+
/**
|
|
59
|
+
* Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.
|
|
60
|
+
*/
|
|
61
|
+
readonly mocks?: readonly string[];
|
|
34
62
|
/**
|
|
35
63
|
* Vite plugins the SPA needs — `@vitejs/plugin-react` for a React app. Passed
|
|
36
64
|
* by the consumer rather than imported here, because the kit must stay
|
|
@@ -38,7 +66,7 @@ export interface WebVitestConfigOptions {
|
|
|
38
66
|
*/
|
|
39
67
|
readonly plugins?: readonly Plugin[];
|
|
40
68
|
/**
|
|
41
|
-
* Extra resolver entries.
|
|
69
|
+
* Extra resolver entries, applied after the canonical ones.
|
|
42
70
|
*/
|
|
43
71
|
readonly aliases?: readonly VitestAlias[];
|
|
44
72
|
/**
|
|
@@ -46,9 +74,38 @@ export interface WebVitestConfigOptions {
|
|
|
46
74
|
*/
|
|
47
75
|
readonly root?: string;
|
|
48
76
|
/**
|
|
49
|
-
*
|
|
77
|
+
* The DOM implementation. `jsdom` is the family default; `happy-dom` is
|
|
78
|
+
* CalDAV-Bridge's (lighter, and sufficient for its hook/service suites).
|
|
79
|
+
*/
|
|
80
|
+
readonly environment?: 'jsdom' | 'happy-dom';
|
|
81
|
+
/**
|
|
82
|
+
* Which suites to collect. Defaults to every shape the family uses.
|
|
50
83
|
*/
|
|
51
84
|
readonly include?: readonly string[];
|
|
85
|
+
/**
|
|
86
|
+
* Suite paths to skip, replacing the default.
|
|
87
|
+
*/
|
|
88
|
+
readonly exclude?: readonly string[];
|
|
89
|
+
/**
|
|
90
|
+
* Setup files run before each test file.
|
|
91
|
+
*/
|
|
92
|
+
readonly setupFiles?: readonly string[];
|
|
93
|
+
/**
|
|
94
|
+
* `node_modules` specifiers to inline through Vite rather than externalize.
|
|
95
|
+
*/
|
|
96
|
+
readonly serverDepsInline?: readonly string[];
|
|
97
|
+
/**
|
|
98
|
+
* Resolver `noExternal` patterns, merged after {@link KIT_NO_EXTERNAL}.
|
|
99
|
+
*/
|
|
100
|
+
readonly noExternal?: readonly (string | RegExp)[];
|
|
101
|
+
/**
|
|
102
|
+
* Coverage `include` globs. Defaults to the SPA source.
|
|
103
|
+
*/
|
|
104
|
+
readonly coverageInclude?: readonly string[];
|
|
105
|
+
/**
|
|
106
|
+
* Coverage `exclude` globs, merged with the canonical set.
|
|
107
|
+
*/
|
|
108
|
+
readonly coverageExclude?: readonly string[];
|
|
52
109
|
/**
|
|
53
110
|
* Coverage floors. Omitted by default; see `defineUnitVitestConfig`.
|
|
54
111
|
*/
|
|
@@ -66,7 +123,7 @@ export interface WebVitestConfigOptions {
|
|
|
66
123
|
* // vitest.web.config.mts
|
|
67
124
|
* import react from '@vitejs/plugin-react';
|
|
68
125
|
* import { defineWebVitestConfig } from '@rexezuge/tooling/vitest-web';
|
|
69
|
-
* export default defineWebVitestConfig({ plugins: [react()] });
|
|
126
|
+
* export default defineWebVitestConfig({ scope: '@myapp', plugins: [react()] });
|
|
70
127
|
* ```
|
|
71
128
|
*/
|
|
72
129
|
export declare function defineWebVitestConfig(options?: WebVitestConfigOptions): ReturnType<typeof defineConfig>;
|
package/dist/vitest-web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-web.d.ts","sourceRoot":"","sources":["../src/vitest-web.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"vitest-web.d.ts","sourceRoot":"","sources":["../src/vitest-web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7C;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACnD;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAcD;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CA6C3G"}
|
package/dist/vitest-web.js
CHANGED
|
@@ -1,72 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The SPA's test and coverage gate.
|
|
3
|
-
*
|
|
4
|
-
* Provenance: converged from Durable-DAV-Router's and Mail-Otter's
|
|
5
|
-
* `vitest.web.config.mts`, which are the two repos that gave the frontend its own
|
|
6
|
-
* suite. Durable-DAV-Router's is the canonical shape — it is the one that records
|
|
7
|
-
* *why* the split exists; Mail-Otter's contributes the React plugin and the
|
|
8
|
-
* `apps/web/**` include.
|
|
9
|
-
*
|
|
10
|
-
* Canonical decisions:
|
|
11
|
-
*
|
|
12
|
-
* 1. **It is a separate config, not a `projects` entry in one.** With a single
|
|
13
|
-
* config the SPA suites ran under `node` and the worker suites under `jsdom`
|
|
14
|
-
* in the same pass, so a test could pass in one environment and fail in the
|
|
15
|
-
* other with neither run noticing.
|
|
16
|
-
* 2. **`pool: 'threads'`, bounded, rather than one forked worker per file.** Each
|
|
17
|
-
* jsdom document is a whole browser environment; a fork per file exhausts
|
|
18
|
-
* memory on a constrained machine, and when it does the run dies partway with
|
|
19
|
-
* a bare "Worker exited unexpectedly" and no test reports a failure — which
|
|
20
|
-
* reads as a flaky suite rather than as an out-of-memory kill.
|
|
21
|
-
* 3. **jsdom is set here for every file**, rather than a `@vitest-environment`
|
|
22
|
-
* pragma per file: these are the tests that need a DOM, and the pragma is one
|
|
23
|
-
* more place to forget.
|
|
24
|
-
* 4. **`include` covers both shapes the repos use** — the root-suite `web-*`
|
|
25
|
-
* naming convention and suites bundled under `apps/web` — and the same globs
|
|
26
|
-
* are what `defineUnitVitestConfig()` excludes.
|
|
27
|
-
*/
|
|
28
|
-
import { defineConfig } from 'vitest/config';
|
|
29
|
-
import { fileURLToPath } from 'node:url';
|
|
30
|
-
/**
|
|
31
|
-
* The default suite globs: the root-suite `web-*` convention and the
|
|
32
|
-
* bundled-under-`apps/web` convention, so either layout works unchanged.
|
|
33
|
-
*/
|
|
34
|
-
const DEFAULT_INCLUDE = ['test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];
|
|
35
|
-
/**
|
|
36
|
-
* Build the SPA's test config.
|
|
37
|
-
*
|
|
38
|
-
* ```ts
|
|
39
|
-
* // vitest.web.config.mts
|
|
40
|
-
* import react from '@vitejs/plugin-react';
|
|
41
|
-
* import { defineWebVitestConfig } from '@rexezuge/tooling/vitest-web';
|
|
42
|
-
* export default defineWebVitestConfig({ plugins: [react()] });
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export function defineWebVitestConfig(options = {}) {
|
|
46
|
-
const root = options.root ?? new URL('.', import.meta.url).href;
|
|
47
|
-
const webSrc = fileURLToPath(new URL('apps/web/src', root));
|
|
48
|
-
const aliases = [{ find: /^@\//, replacement: `${webSrc}/` }, ...(options.aliases ?? [])];
|
|
49
|
-
return defineConfig({
|
|
50
|
-
...(options.plugins !== undefined && { plugins: [...options.plugins] }),
|
|
51
|
-
resolve: { alias: aliases },
|
|
52
|
-
test: {
|
|
53
|
-
globals: true,
|
|
54
|
-
environment: 'jsdom',
|
|
55
|
-
include: [...(options.include ?? DEFAULT_INCLUDE)],
|
|
56
|
-
// Threads, bounded, rather than one forked worker per file — see the
|
|
57
|
-
// header. A custom `exclude` replaces Vitest's defaults, so `node_modules`
|
|
58
|
-
// must be re-listed.
|
|
59
|
-
pool: 'threads',
|
|
60
|
-
exclude: ['**/node_modules/**', '**/dist/**', 'test/integration/**'],
|
|
61
|
-
coverage: {
|
|
62
|
-
provider: 'v8',
|
|
63
|
-
reporter: ['text', 'lcov'],
|
|
64
|
-
reportsDirectory: options.reportsDirectory ?? './coverage-spa',
|
|
65
|
-
include: ['apps/web/src/**/*.{ts,tsx}'],
|
|
66
|
-
exclude: ['**/*.test.{ts,tsx}', '**/*.d.ts', '**/types.ts', '**/generated/**'],
|
|
67
|
-
...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=vitest-web.js.map
|
|
1
|
+
import{defineConfig as l}from"vitest/config";import{fileURLToPath as c}from"node:url";import{DEFAULT_CLOUDFLARE_MOCKS as i,DEFAULT_WORKSPACE_PACKAGES as a,KIT_NO_EXTERNAL as u,workspaceAliases as f}from"./vitest-aliases.js";const o=["test/web/**/*.test.{ts,tsx}","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],p=["**/*.test.{ts,tsx}","**/*.d.ts","**/types.ts","**/generated/**"];function v(e={}){const s=e.root??new URL(".",import.meta.url).href,r=c(new URL("apps/web/src",s)),n=f({scope:e.scope??"@unused",root:s,packages:e.packages??a,mocks:e.mocks??i}).filter(t=>typeof t.find=="string"&&!t.find.startsWith("@unused")),d=[{find:/^@\//,replacement:`${r}/`},{find:/^~\//,replacement:`${r}/`},...n.filter(t=>typeof t.find=="string"&&(t.find.startsWith("cloudflare:")||e.scope!==void 0)),...e.aliases??[]];return l({...e.plugins!==void 0&&{plugins:[...e.plugins]},resolve:{alias:d,noExternal:[...u,...e.noExternal??[]]},test:{globals:!0,environment:e.environment??"jsdom",include:[...e.include??o],pool:"threads",exclude:[...e.exclude??["**/node_modules/**","**/dist/**","test/integration/**"]],...e.setupFiles!==void 0&&{setupFiles:[...e.setupFiles]},...e.serverDepsInline!==void 0&&{server:{deps:{inline:[...e.serverDepsInline]}}},coverage:{provider:"v8",reporter:["text","lcov"],reportsDirectory:e.reportsDirectory??"./coverage-spa",include:[...e.coverageInclude??["apps/web/src/**/*.{ts,tsx}"]],exclude:[...p,...e.coverageExclude??[]],...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}export{v as defineWebVitestConfig};
|
package/dist/vitest-web.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/vitest-web.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The SPA's test and coverage gate.\n *\n * Provenance: converged from all nine repos' SPA suites — Durable-DAV-Router's\n * and Mail-Otter's `vitest.web.config.mts` (the two repos that gave the frontend\n * its own file), Mail-Meow's and CalDAV-Bridge's `projects` entries (the two\n * that keep backend and SPA in one file), and AWS-AccessBridge's\n * extension-split `dom` project. Durable-DAV-Router's file is the canonical\n * shape — it is the one that records *why* the split exists; Mail-Otter's\n * contributes the React plugin and the `apps/web/**` include; CalDAV-Bridge\n * contributes `happy-dom` and the `test/web/**` directory convention;\n * Mail-Meow contributes `setupFiles` and the note that projects do not inherit\n * the root `resolve`.\n *\n * Canonical decisions:\n *\n * 1. **A DOM for every file here**, rather than a `@vitest-environment` pragma\n * per file: these are the tests that need a DOM, and the pragma is one more\n * place to forget. `jsdom` is the family default (seven repos);\n * `happy-dom` is CalDAV-Bridge's, and is one option away.\n * 2. **`pool: 'threads'`, bounded, rather than one forked worker per file.** Each\n * jsdom document is a whole browser environment; a fork per file exhausts\n * memory on a constrained machine, and when it does the run dies partway with\n * a bare \"Worker exited unexpectedly\" and no test reports a failure — which\n * reads as a flaky suite rather than as an out-of-memory kill.\n * 3. **`include` covers every shape the family uses** — the `test/web/**`\n * directory convention, the root-suite `web-*` naming convention, and suites\n * bundled under `apps/web` — and the same globs are what\n * `defineUnitVitestConfig()` excludes, so a file is collected by exactly one\n * config.\n * 4. **Projects do not inherit the root `resolve`** (Mail-Meow): a\n * single-file `projects` composition must repeat the alias table per\n * project. `defineRepoVitestConfig()` does that; two-file repos get it from\n * these factories directly.\n * 5. **`@/` means the SPA here, not the API worker.** The unit config maps\n * `@/` to `apps/api/src`; this config maps both `@/` (Mail-Otter's SPA\n * source) and `~/` (Mail-Meow's and CalDAV-Bridge's SPA tests) to\n * `apps/web/src`. Workspace `@scope/*` imports still resolve to the\n * packages, so web tests reach shared logic the same way backend tests do.\n */\n\nimport { defineConfig, type Plugin } from 'vitest/config';\nimport { fileURLToPath } from 'node:url';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\nimport type { CoverageThresholds } from './vitest.ts';\n\n/**\n * What `defineWebVitestConfig` accepts.\n */\nexport interface WebVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. When supplied, `@scope/*`\n * workspace aliases are generated so web tests reach shared logic; when\n * omitted, only the `cloudflare:*`, `@/` and `~/` aliases apply.\n */\n readonly scope?: string;\n /**\n * Workspace package directory names. Defaults to the family superset.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * Vite plugins the SPA needs — `@vitejs/plugin-react` for a React app. Passed\n * by the consumer rather than imported here, because the kit must stay\n * zero-dependency and the plugin belongs to the app, not the harness.\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Extra resolver entries, applied after the canonical ones.\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * The repo root, as a file URL.\n */\n readonly root?: string;\n /**\n * The DOM implementation. `jsdom` is the family default; `happy-dom` is\n * CalDAV-Bridge's (lighter, and sufficient for its hook/service suites).\n */\n readonly environment?: 'jsdom' | 'happy-dom';\n /**\n * Which suites to collect. Defaults to every shape the family uses.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default.\n */\n readonly exclude?: readonly string[];\n /**\n * Setup files run before each test file.\n */\n readonly setupFiles?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite rather than externalize.\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Resolver `noExternal` patterns, merged after {@link KIT_NO_EXTERNAL}.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * Coverage `include` globs. Defaults to the SPA source.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Coverage floors. Omitted by default; see `defineUnitVitestConfig`.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written. Separate from the unit config's, so\n * the two gates never overwrite each other's report.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The default suite globs: every shape the family uses — the `test/web/**`\n * directory convention, the root-suite `web-*` convention, and the\n * bundled-under-`apps/web` convention — so any layout works unchanged.\n */\nconst DEFAULT_INCLUDE: readonly string[] = ['test/web/**/*.test.{ts,tsx}', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude` globs for the SPA half.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = ['**/*.test.{ts,tsx}', '**/*.d.ts', '**/types.ts', '**/generated/**'];\n\n/**\n * Build the SPA's test config.\n *\n * ```ts\n * // vitest.web.config.mts\n * import react from '@vitejs/plugin-react';\n * import { defineWebVitestConfig } from '@rexezuge/tooling/vitest-web';\n * export default defineWebVitestConfig({ scope: '@myapp', plugins: [react()] });\n * ```\n */\nexport function defineWebVitestConfig(options: WebVitestConfigOptions = {}): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const webSrc = fileURLToPath(new URL('apps/web/src', root));\n // The workspace table maps `@/` to the API worker; here `@/` means the SPA,\n // so drop its `@/`/`~/` entries and prepend the SPA's own. String finds\n // (`@scope/*`, `cloudflare:*`) survive; a placeholder scope contributes none.\n const scopePart = workspaceAliases({\n scope: options.scope ?? '@unused',\n root,\n packages: options.packages ?? DEFAULT_WORKSPACE_PACKAGES,\n mocks: options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS,\n }).filter((alias) => typeof alias.find === 'string' && !alias.find.startsWith('@unused'));\n const aliases: VitestAlias[] = [\n { find: /^@\\//, replacement: `${webSrc}/` },\n { find: /^~\\//, replacement: `${webSrc}/` },\n ...scopePart.filter((alias) => typeof alias.find === 'string' && (alias.find.startsWith('cloudflare:') || options.scope !== undefined)),\n ...(options.aliases ?? []),\n ];\n\n return defineConfig({\n ...(options.plugins !== undefined && { plugins: [...options.plugins] }),\n resolve: { alias: aliases, noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])] },\n test: {\n globals: true,\n environment: options.environment ?? 'jsdom',\n include: [...(options.include ?? DEFAULT_INCLUDE)],\n // Threads, bounded, rather than one forked worker per file — see the\n // header. A custom `exclude` replaces Vitest's defaults, so `node_modules`\n // must be re-listed.\n pool: 'threads',\n exclude: [...(options.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**'])],\n ...(options.setupFiles !== undefined && { setupFiles: [...options.setupFiles] }),\n ...(options.serverDepsInline !== undefined && {\n server: { deps: { inline: [...options.serverDepsInline] } },\n }),\n coverage: {\n provider: 'v8',\n reporter: ['text', 'lcov'],\n reportsDirectory: options.reportsDirectory ?? './coverage-spa',\n include: [...(options.coverageInclude ?? ['apps/web/src/**/*.{ts,tsx}'])],\n exclude: [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?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SAAWH,CAAgB,EAIjD,KAAM,UACN,QAAS,CAAC,GAAIG,EAAQ,SAAW,CAAC,qBAAsB,aAAc,qBAAqB,CAAE,EAC7F,GAAIA,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAC,GAAGA,EAAQ,UAAU,CAAC,EAC7E,GAAIA,EAAQ,mBAAqB,QAAa,CAC5C,OAAQ,CAAE,KAAM,CAAE,OAAQ,CAAC,GAAGA,EAAQ,gBAAgB,CAAC,CAAE,GAE3D,SAAU,CACR,SAAU,KACV,SAAU,CAAC,OAAQ,MAAM,EACzB,iBAAkBA,EAAQ,kBAAoB,iBAC9C,QAAS,CAAC,GAAIA,EAAQ,iBAAmB,CAAC,4BAA4B,CAAE,EACxE,QAAS,CAAC,GAAGF,EAA4B,GAAIE,EAAQ,iBAAmB,CAAA,CAAG,EAC3E,GAAIA,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,EAAQ,UAAU,CAAE,IAGpF,CACH",
|
|
6
|
+
"names": ["defineConfig", "fileURLToPath", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_NO_EXTERNAL", "workspaceAliases", "DEFAULT_INCLUDE", "CANONICAL_COVERAGE_EXCLUDE", "defineWebVitestConfig", "options", "root", "webSrc", "scopePart", "alias", "aliases"]
|
|
7
|
+
}
|
package/dist/vitest.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The unit-test Vitest config for the worker-and-packages half of the suite.
|
|
3
3
|
*
|
|
4
|
-
* Provenance: converged from
|
|
4
|
+
* Provenance: converged from all nine repos' `vitest.config.mts`. The coverage
|
|
5
5
|
* block is Durable-DAV-Router's (the most complete: v8 provider, explicit
|
|
6
6
|
* include/exclude patterns, thresholds with the reasoning for why they sit just
|
|
7
|
-
* under the measured value); the alias block is Durable-DAV's
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* under the measured value); the alias block is the union of Durable-DAV's
|
|
8
|
+
* `cloudflare:*` mocks, every repo's `@scope/* → src` workspace table, and the
|
|
9
|
+
* shared `@/` + `~/` prefixes — see {@link ./vitest-aliases.js}.
|
|
10
10
|
*
|
|
11
11
|
* Canonical decisions:
|
|
12
12
|
*
|
|
@@ -17,26 +17,24 @@
|
|
|
17
17
|
* invisible rather than counted as zero, which is the exact regression this
|
|
18
18
|
* gate exists to catch.
|
|
19
19
|
* 2. **The SPA is excluded here**, so this config and `defineWebVitestConfig()`
|
|
20
|
-
* partition the suite rather than each running all of it.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* files two directories away.
|
|
20
|
+
* partition the suite rather than each running all of it. The default covers
|
|
21
|
+
* every suite shape the family uses (`test/web/**`, `test/**/web-*`,
|
|
22
|
+
* `apps/web/**`); see `defineRepoVitestConfig()` for the single-file
|
|
23
|
+
* `projects` composition the AWS/Mail-Meow/CalDAV repos use.
|
|
25
24
|
* 3. **A custom `exclude` re-lists `node_modules`** — `test/` is a workspace
|
|
26
25
|
* project and therefore has its own, so without the re-list the glob reaches
|
|
27
26
|
* into `test/node_modules` and tries to run other packages' suites.
|
|
28
27
|
* 4. **Thresholds are a consumer argument**, not a kit default. A floor is a
|
|
29
28
|
* per-repo ratchet measured against that repo's suite; the kit cannot know a
|
|
30
29
|
* number, and guessing one is how floors get lowered.
|
|
30
|
+
* 5. **`@rexezuge/*` is never externalized** — see `KIT_NO_EXTERNAL`: the kit
|
|
31
|
+
* ships ESM `dist/` with bundler-style extensionless imports, which Node's
|
|
32
|
+
* resolver refuses, so the kit stays inside Vite's pipeline (the same
|
|
33
|
+
* resolver that bundles the worker).
|
|
31
34
|
*/
|
|
32
|
-
import { defineConfig } from 'vitest/config';
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
36
|
-
export interface VitestAlias {
|
|
37
|
-
readonly find: string | RegExp;
|
|
38
|
-
readonly replacement: string;
|
|
39
|
-
}
|
|
35
|
+
import { defineConfig, type Plugin } from 'vitest/config';
|
|
36
|
+
import type { VitestAlias } from './vitest-aliases.ts';
|
|
37
|
+
export type { VitestAlias } from './vitest-aliases.ts';
|
|
40
38
|
/**
|
|
41
39
|
* Coverage thresholds, in the four figures Vitest gates on.
|
|
42
40
|
*/
|
|
@@ -53,14 +51,64 @@ export interface CoverageThresholds {
|
|
|
53
51
|
*/
|
|
54
52
|
export interface UnitVitestConfigOptions {
|
|
55
53
|
/**
|
|
56
|
-
*
|
|
54
|
+
* The consuming repo's npm scope, e.g. `'@myapp'`. When supplied, `@scope/*`
|
|
55
|
+
* workspace aliases are generated from `packages` (plus `background` under
|
|
56
|
+
* `apps/`); when omitted, only the `cloudflare:*`, `@/` and `~/` aliases
|
|
57
|
+
* apply and `aliases` carries the workspace table by hand.
|
|
58
|
+
*/
|
|
59
|
+
readonly scope?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Workspace package directory names. Defaults to the family superset; a repo
|
|
62
|
+
* without a domain package keeps the default harmlessly (its alias never
|
|
63
|
+
* matches).
|
|
64
|
+
*/
|
|
65
|
+
readonly packages?: readonly string[];
|
|
66
|
+
/**
|
|
67
|
+
* Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.
|
|
68
|
+
*/
|
|
69
|
+
readonly mocks?: readonly string[];
|
|
70
|
+
/**
|
|
71
|
+
* Extra resolver entries, applied after the canonical ones (e.g. the `hono`
|
|
72
|
+
* dedupe two repos carry, or an `/index.ts` exact entry).
|
|
57
73
|
*/
|
|
58
74
|
readonly aliases?: readonly VitestAlias[];
|
|
59
75
|
/**
|
|
60
76
|
* Where the repo root is, as a file URL. Defaults to the directory this
|
|
61
77
|
* factory is *called* from, which is the repo root's `vitest.config.mts`.
|
|
78
|
+
* Pass `new URL('.', import.meta.url).href` explicitly from the caller —
|
|
79
|
+
* never rely on this module's own URL, which points into `node_modules`.
|
|
62
80
|
*/
|
|
63
81
|
readonly root?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Which suites to collect. Defaults to the whole unit suite.
|
|
84
|
+
*/
|
|
85
|
+
readonly include?: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* Suite paths to skip, replacing the default. Defaults re-list
|
|
88
|
+
* `node_modules`/`dist`/`integration` plus every SPA shape.
|
|
89
|
+
*/
|
|
90
|
+
readonly exclude?: readonly string[];
|
|
91
|
+
/**
|
|
92
|
+
* `node_modules` specifiers to inline through Vite rather than externalize.
|
|
93
|
+
* Defaults to `['dofs']` (Durable-DAV: `dofs` imports `cloudflare:workers`,
|
|
94
|
+
* which Node rejects before `resolve.alias` is consulted).
|
|
95
|
+
*/
|
|
96
|
+
readonly serverDepsInline?: readonly string[];
|
|
97
|
+
/**
|
|
98
|
+
* Resolver `noExternal` patterns. Defaults to keeping `@rexezuge/*` inside
|
|
99
|
+
* Vite's pipeline; see `KIT_NO_EXTERNAL`.
|
|
100
|
+
*/
|
|
101
|
+
readonly noExternal?: readonly (string | RegExp)[];
|
|
102
|
+
/**
|
|
103
|
+
* Vite plugins for the suite (rare on the backend half; the SPA half passes
|
|
104
|
+
* `react()` here).
|
|
105
|
+
*/
|
|
106
|
+
readonly plugins?: readonly Plugin[];
|
|
107
|
+
/**
|
|
108
|
+
* Setup files run before each test file (e.g. AWS's floci guard, Meow's
|
|
109
|
+
* backend/web setups).
|
|
110
|
+
*/
|
|
111
|
+
readonly setupFiles?: readonly string[];
|
|
64
112
|
/**
|
|
65
113
|
* Coverage `include` globs. Defaults to the worker plus every workspace
|
|
66
114
|
* package's `src`.
|
|
@@ -85,7 +133,10 @@ export interface UnitVitestConfigOptions {
|
|
|
85
133
|
* ```ts
|
|
86
134
|
* // vitest.config.mts
|
|
87
135
|
* import { defineUnitVitestConfig } from '@rexezuge/tooling/vitest';
|
|
88
|
-
* export default defineUnitVitestConfig(
|
|
136
|
+
* export default defineUnitVitestConfig({
|
|
137
|
+
* scope: '@myapp',
|
|
138
|
+
* thresholds: { statements: 60, branches: 55, functions: 65, lines: 60 },
|
|
139
|
+
* });
|
|
89
140
|
* ```
|
|
90
141
|
*/
|
|
91
142
|
export declare function defineUnitVitestConfig(options?: UnitVitestConfigOptions): ReturnType<typeof defineConfig>;
|
package/dist/vitest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SA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