vitest-dev/vitest · error · Error

BaseReporter's parseConfigModule was not overwritten

Error message

BaseReporter's parseConfigModule was not overwritten

What it means

BaseReporter.parseConfigModule() (coverage.ts:256) is the abstract-style stub. It is used by the thresholds.autoUpdate flow to AST-parse the user's config file; if a custom reporter doesn't implement it, autoUpdate cannot rewrite thresholds.

Source

Thrown at packages/vitest/src/node/coverage.ts:256

    }

    const rootMapper = this.getUntestedFilesByRoot.bind(this, testedFiles, this.options.include)

    const matrix = await Promise.all(this.roots.map(rootMapper))

    return matrix.flatMap(files => files)
  }

  createCoverageMap(): CoverageMap {
    throw new Error('BaseReporter\'s createCoverageMap was not overwritten')
  }

  async generateReports(_: CoverageMap, __: boolean | undefined): Promise<void> {
    throw new Error('BaseReporter\'s generateReports was not overwritten')
  }

  async parseConfigModule(_: string): Promise<{ generate: () => { code: string } }> {
    throw new Error('BaseReporter\'s parseConfigModule was not overwritten')
  }

  resolveOptions(): ResolvedCoverageOptions {
    return this.options
  }

  async clean(clean = true): Promise<void> {
    await this.reportsDirectoryLock.acquire()

    if (clean && existsSync(this.options.reportsDirectory)) {
      await fs.rm(this.options.reportsDirectory, {
        recursive: true,
        force: true,
        maxRetries: 10,
      })
    }

    if (existsSync(this.coverageFilesDirectory)) {

View on GitHub (pinned to d568f8ce37)

Solutions

  1. Implement async parseConfigModule(path) in your custom reporter using magicast (see the built-in implementation).
  2. Disable coverage.thresholds.autoUpdate when using a reporter that can't rewrite config.
  3. Extend a concrete reporter that already implements parseConfigModule.

Example fix

// before
class MyReporter extends BaseReporter {}
// with coverage.thresholds.autoUpdate = true

// after
class MyReporter extends BaseReporter {
  async parseConfigModule(path: string) {
    return (await parseModule(await fs.readFile(path, 'utf-8')))
  }
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (reporter.parseConfigModule === BaseReporter.prototype.parseConfigModule
    && config.coverage.thresholds.autoUpdate) {
  throw new Error('Reporter cannot autoUpdate thresholds; override parseConfigModule or disable autoUpdate')
}

Type guard

function overridesParseConfigModule(r: BaseReporter): boolean {
  return r.parseConfigModule !== BaseReporter.prototype.parseConfigModule
}

Prevention

When it happens

Trigger: coverage.thresholds.autoUpdate is enabled and the active reporter (a custom BaseReporter subclass) didn't override parseConfigModule when vitest tries to update thresholds.

Common situations: Custom reporter used together with thresholds.autoUpdate without overriding the config-parsing method.

Related errors


AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03). Data as JSON: /data/errors/0af9e59d78a31cc4.json. Report an issue: GitHub.