@naturalcycles/dev-lib 20.65.0 → 20.65.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/cfg/vitest.config.d.ts +0 -18
- package/cfg/vitest.config.js +17 -55
- package/package.json +1 -1
package/cfg/vitest.config.d.ts
CHANGED
|
@@ -37,24 +37,6 @@ export function defineVitestMonorepoConfig(config: Partial<ViteUserConfig>): Vit
|
|
|
37
37
|
*/
|
|
38
38
|
export function getSharedConfig(cwd?: string): InlineConfig
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated Use defineVitestMonorepoConfig for the monorepo root config instead. It sets
|
|
42
|
-
* `reporters` together with all the other root-only options.
|
|
43
|
-
*/
|
|
44
|
-
export function getRootReporters(): InlineConfig['reporters']
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated Use defineVitestMonorepoConfig for the monorepo root config instead. It sets
|
|
48
|
-
* `outputFile` together with all the other root-only options.
|
|
49
|
-
*/
|
|
50
|
-
export function getRootOutputFile(): InlineConfig['outputFile']
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @deprecated Use defineVitestMonorepoConfig for the monorepo root config instead. It sets
|
|
54
|
-
* `coverage` together with all the other root-only options.
|
|
55
|
-
*/
|
|
56
|
-
export function getRootCoverage(): InlineConfig['coverage']
|
|
57
|
-
|
|
58
40
|
export const CollectReporter: any
|
|
59
41
|
|
|
60
42
|
export class SummaryReporter {}
|
package/cfg/vitest.config.js
CHANGED
|
@@ -9,7 +9,7 @@ export { CollectReporter } from './collectReporter.js'
|
|
|
9
9
|
|
|
10
10
|
const runsInIDE = doesItRunInIDE()
|
|
11
11
|
const testType = getTestType(runsInIDE)
|
|
12
|
-
const silent =
|
|
12
|
+
const silent = getSilent(runsInIDE)
|
|
13
13
|
const { include, exclude } = getIncludeAndExclude(testType)
|
|
14
14
|
const isCI = !!process.env.CI
|
|
15
15
|
const coverageEnabled = isCI && testType === 'unit'
|
|
@@ -27,6 +27,9 @@ if (testType === 'unit') {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (silent) {
|
|
30
|
+
// Tells the tests that vitest is suppressing console output, so they keep the output vitest
|
|
31
|
+
// can't intercept quiet too: child process stdio (see exec2.test.ts) and dev-lib's testLogger,
|
|
32
|
+
// which writes to process.stdout directly.
|
|
30
33
|
process.env.TEST_SILENT = 'true'
|
|
31
34
|
}
|
|
32
35
|
|
|
@@ -96,9 +99,6 @@ export function defineVitestMonorepoConfig(config) {
|
|
|
96
99
|
...config,
|
|
97
100
|
test: {
|
|
98
101
|
...getRootConfig(),
|
|
99
|
-
// Console output of failed tests only. Not the all-or-nothing boolean `silent` of
|
|
100
|
-
// getSharedConfig, which is kept there for backwards compatibility.
|
|
101
|
-
silent: 'passed-only',
|
|
102
102
|
...config?.test,
|
|
103
103
|
},
|
|
104
104
|
})
|
|
@@ -114,7 +114,6 @@ export function getSharedConfig(cwd) {
|
|
|
114
114
|
// In a monorepo they are IGNORED here (Vitest reads them from the root config only), so
|
|
115
115
|
// defineVitestMonorepoConfig sets them on the root config instead.
|
|
116
116
|
...getRootConfig(),
|
|
117
|
-
silent,
|
|
118
117
|
// Per-project options
|
|
119
118
|
pool,
|
|
120
119
|
maxWorkers,
|
|
@@ -146,12 +145,11 @@ export function getSharedConfig(cwd) {
|
|
|
146
145
|
* only (`NonProjectOptions` in Vitest's types, plus `sequence.sequencer`), hence the ones that
|
|
147
146
|
* must be set on the root config of a monorepo to take effect there. Shared by getSharedConfig
|
|
148
147
|
* (where they apply in a single-package repo) and defineVitestMonorepoConfig.
|
|
149
|
-
*
|
|
150
|
-
* `silent` is root-only too, but is set by the callers, as they differ in it.
|
|
151
148
|
*/
|
|
152
149
|
function getRootConfig() {
|
|
153
150
|
return {
|
|
154
151
|
watch: false,
|
|
152
|
+
silent,
|
|
155
153
|
slowTestThreshold: isCI ? 500 : 300, // higher threshold in CI
|
|
156
154
|
sequence: {
|
|
157
155
|
sequencer: VitestAlphabeticSequencer,
|
|
@@ -167,30 +165,6 @@ function getRootConfig() {
|
|
|
167
165
|
}
|
|
168
166
|
}
|
|
169
167
|
|
|
170
|
-
/**
|
|
171
|
-
* @deprecated Use defineVitestMonorepoConfig for the monorepo root config instead. It sets
|
|
172
|
-
* `reporters` together with all the other root-only options (see getRootConfig).
|
|
173
|
-
*/
|
|
174
|
-
export function getRootReporters() {
|
|
175
|
-
return getReporters(junitReporterEnabled, testType)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* @deprecated Use defineVitestMonorepoConfig for the monorepo root config instead. It sets
|
|
180
|
-
* `outputFile` together with all the other root-only options (see getRootConfig).
|
|
181
|
-
*/
|
|
182
|
-
export function getRootOutputFile() {
|
|
183
|
-
return getOutputFile()
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* @deprecated Use defineVitestMonorepoConfig for the monorepo root config instead. It sets
|
|
188
|
-
* `coverage` together with all the other root-only options (see getRootConfig).
|
|
189
|
-
*/
|
|
190
|
-
export function getRootCoverage() {
|
|
191
|
-
return getCoverageConfig()
|
|
192
|
-
}
|
|
193
|
-
|
|
194
168
|
/**
|
|
195
169
|
* The reporters, shared by the per-package (getSharedConfig) and the monorepo root
|
|
196
170
|
* (defineVitestMonorepoConfig) configs.
|
|
@@ -335,32 +309,20 @@ function getTestType(runsInIDE) {
|
|
|
335
309
|
return process.env.TEST_TYPE || 'unit'
|
|
336
310
|
}
|
|
337
311
|
|
|
338
|
-
function shouldBeSilent(runsInIDE) {
|
|
339
|
-
if (runsInIDE) {
|
|
340
|
-
return false
|
|
341
|
-
}
|
|
342
|
-
return isRunningAllTests()
|
|
343
|
-
}
|
|
344
|
-
|
|
345
312
|
/**
|
|
346
|
-
*
|
|
313
|
+
* Console output of failed tests only, in every CLI run - whether it runs all tests or a single
|
|
314
|
+
* file. Pass `--silent=false` to see the output of passing tests too.
|
|
315
|
+
* In the IDE everything is printed, as IDE runs are interactive debugging.
|
|
347
316
|
*/
|
|
348
|
-
function
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (!a.startsWith('-')) {
|
|
358
|
-
hasPositionalArgs = true
|
|
359
|
-
}
|
|
360
|
-
})
|
|
361
|
-
// console.log({vitestArg, hasPositionalArgs}, process.argv)
|
|
362
|
-
|
|
363
|
-
return !hasPositionalArgs
|
|
317
|
+
function getSilent(runsInIDE) {
|
|
318
|
+
if (runsInIDE) return false
|
|
319
|
+
// Vitest applies `--silent=false` to `silent` by itself; mirroring it here keeps TEST_SILENT
|
|
320
|
+
// (see above) in sync, so the output vitest can't intercept is shown as well.
|
|
321
|
+
const silentFalse = process.argv.some(
|
|
322
|
+
(a, i) => a === '--silent=false' || (a === '--silent' && process.argv[i + 1] === 'false'),
|
|
323
|
+
)
|
|
324
|
+
if (silentFalse) return false
|
|
325
|
+
return 'passed-only'
|
|
364
326
|
}
|
|
365
327
|
|
|
366
328
|
function getSetupFiles(testType, cwd = process.cwd()) {
|