vitest-dev/vitest · error · TypeError

Unexpected value "--silent=

Error message

Unexpected value "--silent=${value}". Use "--silent=true ${value}" instead.

What it means

The `--silent` option's `transform` accepts only `true|yes|true`, `false|no|false`, or the literal string `passed-only`. Any other value (e.g. `--silent=verbose`, `--silent 1`) is rejected with a `TypeError` that suggests the intended two-flag form `--silent=true <value>`.

Solutions

  1. Use a boolean: `--silent` / `--silent=true` / `--silent=false`.
  2. For passed-tests-only output use `--silent=passed-only`.
  3. If you meant to combine silence with another value, pass them as separate flags: `--silent=true --other=value`.

Example fix

# before
vitest run --silent=verbose

# after
vitest run --silent=true
# or
vitest run --silent=passed-only
Defensive patterns

Strategy: validation

Validate before calling

const SILENT_OK = new Set(['true', 'yes', 'false', 'no', 'passed-only'])
function normalizeSilent(v: unknown): true | false | 'passed-only' {
  const s = String(v ?? '').toLowerCase()
  if (s === 'true' || s === 'yes') return true
  if (s === 'false' || s === 'no') return false
  if (s === 'passed-only') return 'passed-only'
  throw new TypeError(`Unsupported --silent value: ${String(v)}`)
}

Prevention

When it happens

Trigger: Passing `--silent=verbose`, `--silent=only`, `--silent=1`, `--silent 2`, or piping another flag's value into `--silent=`. The value `passed-only` is the sole non-boolean sentinel and is returned as-is.

Common situations: Confusing `--silent` with a verbosity selector; assuming numeric levels like other tools' `--silent=2`; copy-paste from a Jest invocation where `--silent` semantics differ.

Related errors


AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11). Data as JSON: /api/errors/b05a3ec9cf81a51b. Report an issue: GitHub.

Appendix: source

Thrown at packages/vitest/src/node/cli/cli-config.ts:135

      }
      return portOrOptions
    },
  },
  silent: {
    description: 'Silent console output from tests. Use `\'passed-only\'` to see logs from failing tests only.',
    argument: '[value]',
    transform(value) {
      if (value === 'true' || value === 'yes' || value === true) {
        return true
      }
      if (value === 'false' || value === 'no' || value === false) {
        return false
      }
      if (value === 'passed-only') {
        return value
      }

      throw new TypeError(`Unexpected value "--silent=${value}". Use "--silent=true ${value}" instead.`)
    },
  },
  hideSkippedTests: {
    description: 'Hide logs for skipped tests',
  },
  reporter: null,
  reporters: {
    alias: 'reporter',
    description: `Specify reporters (default, agent, minimal, blob, verbose, dot, json, tap, tap-flat, junit, tree, hanging-process, github-actions)`,
    argument: '<name>',
    subcommands: null, // don't support custom objects
    array: true,
  },
  outputFile: {
    argument: '<filename/-s>',
    description:
      'Write test results to a file when supporter reporter is also specified, use cac\'s dot notation for individual outputs of multiple reporters (example: `--outputFile.tap=./tap.txt`)',
    subcommands: null,

View on GitHub (pinned to 1fa9837ec2)