@naturalcycles/dev-lib 20.65.0 → 20.65.1

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.
@@ -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 = shouldBeSilent(runsInIDE)
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,
@@ -335,32 +333,20 @@ function getTestType(runsInIDE) {
335
333
  return process.env.TEST_TYPE || 'unit'
336
334
  }
337
335
 
338
- function shouldBeSilent(runsInIDE) {
339
- if (runsInIDE) {
340
- return false
341
- }
342
- return isRunningAllTests()
343
- }
344
-
345
336
  /**
346
- * Detects if vitest is run with all tests, or with selected individual tests.
337
+ * Console output of failed tests only, in every CLI run - whether it runs all tests or a single
338
+ * file. Pass `--silent=false` to see the output of passing tests too.
339
+ * In the IDE everything is printed, as IDE runs are interactive debugging.
347
340
  */
348
- function isRunningAllTests() {
349
- let vitestArg = false
350
- let hasPositionalArgs = false
351
- process.argv.forEach(a => {
352
- if (a.includes('.bin/vitest')) {
353
- vitestArg = true
354
- return
355
- }
356
- if (!vitestArg) return
357
- if (!a.startsWith('-')) {
358
- hasPositionalArgs = true
359
- }
360
- })
361
- // console.log({vitestArg, hasPositionalArgs}, process.argv)
362
-
363
- return !hasPositionalArgs
341
+ function getSilent(runsInIDE) {
342
+ if (runsInIDE) return false
343
+ // Vitest applies `--silent=false` to `silent` by itself; mirroring it here keeps TEST_SILENT
344
+ // (see above) in sync, so the output vitest can't intercept is shown as well.
345
+ const silentFalse = process.argv.some(
346
+ (a, i) => a === '--silent=false' || (a === '--silent' && process.argv[i + 1] === 'false'),
347
+ )
348
+ if (silentFalse) return false
349
+ return 'passed-only'
364
350
  }
365
351
 
366
352
  function getSetupFiles(testType, cwd = process.cwd()) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
3
  "type": "module",
4
- "version": "20.65.0",
4
+ "version": "20.65.1",
5
5
  "dependencies": {
6
6
  "prompts": "^2",
7
7
  "@naturalcycles/js-lib": "^15",