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.allowView on GitHub (pinned to d568f8ce37)
Solutions
- Check the command name spelling and case.
- Confirm the command is registered — `project.browser.commands` (project) or `parent.commands` (builtin/global).
- Switch to a provider that implements the command, or implement it yourself via `registerCommand`.
- 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
- Double-check command-name spelling and case.
- Confirm the active provider implements the command (some are provider-specific).
- Register custom commands before tests run via the browser config.
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
- Cannot compare screenshots without a test path
- `resolveOptions` has to be used in a test file
- Invalid command name "${name}". Only alphanumeric characters
- Invalid command name "${command}". Only alphanumeric charact
- Commands are only available for browser tests.
AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03).
Data as JSON: /data/errors/aa575cadac370acd.json.
Report an issue: GitHub.