vitest-dev/vitest · error · TypeError

vitest.mergeReports() expects all paths in

Error message

vitest.mergeReports() expects all paths in "${blobsDirectory}" to be files generated by the blob reporter, but "${filename}" is not a valid blob file

What it means

A file in the blobs directory was read successfully but parsed blob had no `version` field, meaning it is not a Vitest blob report (or is a corrupt/partial one). The merge rejects it with a `TypeError` to avoid silently producing a broken merged report.

Solutions

  1. Delete the offending non-blob file (named in the error) from the blobs directory.
  2. Regenerate all blobs by re-running the blob reporter (`--run` with `reporters: ['blob']`).
  3. Use a clean, dedicated blobs directory for each merge cycle.

Example fix

# remove the bad file (name shown in the error)
rm ./blobs/not-a-blob.log

# regenerate clean blobs
vitest --run --reporters=blob --outputFile.blobs=./blobs/x.json
Defensive patterns

Strategy: validation

Validate before calling

import { readdir, readFile } from 'node:fs/promises'
import { parse } from 'flatted'

async function assertAllBlobsValid(dir: string) {
  for (const name of await readdir(dir)) {
    const [version] = parse(await readFile(resolve(dir, name), 'utf-8')) as unknown[]
    if (!version) {
      throw new Error(`'${name}' is not a valid blob file (no version). Remove or regenerate it.`)
    }
  }
}

Prevention

When it happens

Trigger: An arbitrary JSON/text file (e.g. `package.json`, a log, a half-written blob from a killed process) lands in the blobs directory and is parsed by `flatted.parse`; the destructured first element (`version`) is falsy.

Common situations: Reusing a directory that holds other output; a shard process killed mid-write leaving a truncated file; stale blobs from an older format.

Related errors


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

Appendix: source

Thrown at packages/vitest/src/node/reporters/blob.ts:134

  projectsArray: TestProject[],
): Promise<MergedBlobs> {
  // using process.cwd() because --merge-reports can only be used in CLI
  const resolvedDir = resolve(process.cwd(), blobsDirectory)
  const blobsFiles = await readdir(resolvedDir)
  const promises = blobsFiles.map(async (filename) => {
    const fullPath = resolve(resolvedDir, filename)
    const stats = await stat(fullPath)
    if (!stats.isFile()) {
      throw new TypeError(
        `vitest.mergeReports() expects all paths in "${blobsDirectory}" to be files generated by the blob reporter, but "${filename}" is not a file`,
      )
    }
    const content = await readFile(fullPath, 'utf-8')
    const [version, files, errors, coverage, executionTime, environmentModules] = parse(
      content,
    ) as MergeReport
    if (!version) {
      throw new TypeError(
        `vitest.mergeReports() expects all paths in "${blobsDirectory}" to be files generated by the blob reporter, but "${filename}" is not a valid blob file`,
      )
    }
    return { version, files, errors, coverage, file: filename, executionTime, environmentModules }
  })
  const blobs = await Promise.all(promises)

  if (!blobs.length) {
    throw new Error(
      `vitest.mergeReports() requires at least one blob file in "${blobsDirectory}" directory, but none were found`,
    )
  }

  const versions = new Set(blobs.map(blob => blob.version))
  if (versions.size > 1) {
    throw new Error(
      `vitest.mergeReports() requires all blob files to be generated by the same Vitest version, received\n\n${blobs.map(b => `- "${b.file}" uses v${b.version}`).join('\n')}`,
    )

View on GitHub (pinned to 1fa9837ec2)