vitest-dev/vitest · error · Error

Provider ${this.provider.name} does not support command "${n

Error message

Provider ${this.provider.name} does not support command "${name}".

What it means

`ProjectBrowser.triggerCommand` looks up the command first in the project's own command registry, then in the parent's registry. If neither contains it, the command is unsupported by the configured provider and the call is rejected with the provider name in the message.

Source

Thrown at packages/browser/src/node/project.ts:89

      throw new Error(
        `Invalid command name "${name}". Only alphanumeric characters, $ and _ are allowed.`,
      )
    }
    this.commands[name] = cb
  }

  public triggerCommand = (<K extends keyof BrowserCommand>(
    name: K,
    context: BrowserCommandContext,
    ...args: Parameters<BrowserCommands[K]>
  ): ReturnType<BrowserCommands[K]> => {
    if (name in this.commands) {
      return this.commands[name](context, ...args)
    }
    if (name in this.parent.commands) {
      return this.parent.commands[name](context, ...args)
    }
    throw new Error(`Provider ${this.provider.name} does not support command "${name}".`)
  }) as any

  wrapSerializedConfig(): SerializedConfig {
    const config = wrapConfig(this.project.serializedConfig)
    config.env ??= {}
    config.env.VITEST_BROWSER_DEBUG = process.env.VITEST_BROWSER_DEBUG || ''
    return config
  }

  async initBrowserProvider(project: TestProject): Promise<void> {
    if (this.provider) {
      return
    }
    this.provider = await getBrowserProvider(project.config.browser, project)
    if (this.provider.initScripts) {
      this.parent.initScripts = this.provider.initScripts
      // make sure the script can be imported
      const allow = this.parent.vite.config.server.fs.allow

View on GitHub (pinned to d568f8ce37)

Solutions

  1. Check the command name spelling and case.
  2. Confirm the command is registered — `project.browser.commands` (project) or `parent.commands` (builtin/global).
  3. Switch to a provider that implements the command, or implement it yourself via `registerCommand`.
  4. Ensure you're triggering the command from a browser test (a node-only project has no provider).

Example fix

// before
await context.triggerCommand('screenshot')

// after — register or use the correct name
await context.triggerCommand('__vitest_takeScreenshot', name, opts)
Defensive patterns

Strategy: validation

Validate before calling

function isCommandRegistered(
  name: string,
  projectBrowser: { commands: Record<string, unknown> },
  parent: { commands: Record<string, unknown> },
): boolean {
  return name in projectBrowser.commands || name in parent.commands
}

Try / catch

try {
  await context.triggerCommand(name, ...args)
} catch (err) {
  if (err instanceof Error && /does not support command/.test(err.message)) {
    // typo, wrong provider, or never registered
  }
  throw err
}

Prevention

When it happens

Trigger: Triggering a command name that was never registered — typo, a command from a different provider (e.g. a Playwright-only command under WebDriverIO), or calling a builtin before it's registered.

Common situations: Typos in command names; using a provider-specific command (`__vitest_takeScreenshot` is provider-internal) under the wrong provider; calling a command after the project browser has been torn down.

Related errors


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