@naturalcycles/dev-lib 20.50.0 → 20.51.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/cfg/summaryReporter.js +5 -1
- package/cfg/vitest.config.d.ts +7 -0
- package/cfg/vitest.config.js +47 -9
- package/package.json +1 -1
package/cfg/summaryReporter.js
CHANGED
|
@@ -11,7 +11,11 @@ export class SummaryReporter {
|
|
|
11
11
|
let stats = []
|
|
12
12
|
|
|
13
13
|
for (const mod of testModules) {
|
|
14
|
-
|
|
14
|
+
// In the monorepo root run testModules span all projects, so prefix with the
|
|
15
|
+
// (short) package name to disambiguate identically-named files across packages.
|
|
16
|
+
const pkg = mod.project?.name?.split('/').at(-1)
|
|
17
|
+
const file = mod.moduleId.split('/').at(-1)
|
|
18
|
+
const name = pkg ? `${pkg} ${file}` : file
|
|
15
19
|
const diag = mod.diagnostic()
|
|
16
20
|
stats.push({ name, ms: diag.duration })
|
|
17
21
|
}
|
package/cfg/vitest.config.d.ts
CHANGED
|
@@ -20,6 +20,13 @@ export function defineVitestConfig(config?: Partial<ViteUserConfig>, cwd?: strin
|
|
|
20
20
|
*/
|
|
21
21
|
export function getSharedConfig(cwd?: string): InlineConfig
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Reporters for the monorepo root config (Vitest `projects` mode), where
|
|
25
|
+
* `reporters` is a root-only option. Returns the compact 'agent' reporter for
|
|
26
|
+
* agents, otherwise the default reporters plus a monorepo-wide SummaryReporter.
|
|
27
|
+
*/
|
|
28
|
+
export function getRootReporters(): InlineConfig['reporters']
|
|
29
|
+
|
|
23
30
|
export const CollectReporter: any
|
|
24
31
|
|
|
25
32
|
export class SummaryReporter {}
|
package/cfg/vitest.config.js
CHANGED
|
@@ -128,16 +128,10 @@ export function getSharedConfig(cwd) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
function getReporters(junitReporterEnabled, testType) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (VITEST_REPORTER) {
|
|
134
|
-
return [VITEST_REPORTER]
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (isAgent) {
|
|
138
|
-
return ['agent']
|
|
139
|
-
}
|
|
131
|
+
const override = getReporterOverride()
|
|
132
|
+
if (override) return override
|
|
140
133
|
|
|
134
|
+
const { GITHUB_ACTIONS } = process.env
|
|
141
135
|
return [
|
|
142
136
|
'default',
|
|
143
137
|
GITHUB_ACTIONS && 'github-actions',
|
|
@@ -152,6 +146,50 @@ function getReporters(junitReporterEnabled, testType) {
|
|
|
152
146
|
].filter(Boolean)
|
|
153
147
|
}
|
|
154
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Reporters for the monorepo root config (Vitest `projects` mode).
|
|
151
|
+
*
|
|
152
|
+
* `reporters` is a root-only Vitest option: per-project reporters are ignored
|
|
153
|
+
* when running via `projects`. So the per-package SummaryReporter never runs in
|
|
154
|
+
* the aggregate root run, and - crucially - a root-level SummaryReporter sees
|
|
155
|
+
* the test modules of ALL projects at once, letting it report the slowest tests
|
|
156
|
+
* across the entire monorepo.
|
|
157
|
+
*
|
|
158
|
+
* Use it in the root vitest.config.ts:
|
|
159
|
+
*
|
|
160
|
+
* export default defineConfig({
|
|
161
|
+
* test: {
|
|
162
|
+
* projects: ['./packages/*'],
|
|
163
|
+
* reporters: getRootReporters(),
|
|
164
|
+
* },
|
|
165
|
+
* })
|
|
166
|
+
*/
|
|
167
|
+
export function getRootReporters() {
|
|
168
|
+
const override = getReporterOverride()
|
|
169
|
+
if (override) return override
|
|
170
|
+
|
|
171
|
+
const { GITHUB_ACTIONS } = process.env
|
|
172
|
+
return ['default', GITHUB_ACTIONS && 'github-actions', new SummaryReporter()].filter(Boolean)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Reporter overrides shared by both the per-package and root configs:
|
|
177
|
+
* - VITEST_REPORTER env var fully replaces the reporter set
|
|
178
|
+
* - agents get the compact 'agent' reporter, with no summary
|
|
179
|
+
*
|
|
180
|
+
* Returns `undefined` when no override applies (caller uses its own defaults).
|
|
181
|
+
*/
|
|
182
|
+
function getReporterOverride() {
|
|
183
|
+
const { VITEST_REPORTER } = process.env
|
|
184
|
+
if (VITEST_REPORTER) {
|
|
185
|
+
return [VITEST_REPORTER]
|
|
186
|
+
}
|
|
187
|
+
if (isAgent) {
|
|
188
|
+
return ['agent']
|
|
189
|
+
}
|
|
190
|
+
return undefined
|
|
191
|
+
}
|
|
192
|
+
|
|
155
193
|
function doesItRunInIDE() {
|
|
156
194
|
// example command line below:
|
|
157
195
|
// /usr/local/bin/node /Users/some/Idea/some/node_modules/vitest/vitest.mjs --run --reporter /Users/some/Library/Application Support/JetBrains/IntelliJIdea2025.2/plugins/javascript-plugin/helpers/vitest-intellij/node_modules/vitest-intellij-reporter-safe.js --testNamePattern=^ ?case 001: empty data$ /Users/some/Idea/some/src/some/some.integration.test.ts
|