vitest-dev/vitest · error · Error
Provider does not support command " ".
Error message
Provider ${this.provider.name} does not support command "${name}". What it means
triggerCommand looks up the command name first in this.commands (project-browser-scoped commands) then in this.parent.commands (parent-wide builtins and user commands). If neither map contains the name, the provider is considered not to support it and the error names the provider so the user knows which provider was active.
Solutions
- Check the exact command name spelling at the call site against the registration; commands are case-sensitive.
- Ensure the plugin or config.browser.commands entry that registers the command is loaded for the project running the test.
- If using a custom command, register it in setup files that run before the test, on the correct project.
- Confirm the provider you selected actually exposes the command (some commands are provider-specific).
Example fix
// before browser.commands.takescreenshot() // typo, not registered // after browser.commands.takeScreenshot()
Defensive patterns
Strategy: type-guard
Validate before calling
function commandAvailable(commands: Record<string, unknown>, name: string): boolean {
return Object.prototype.hasOwnProperty.call(commands, name)
} Type guard
function isRegistered(commands: Record<string, Function>, name: string): name is keyof typeof commands {
return name in commands
} Prevention
- Keep command names consistent between registration and call sites.
- Ensure the registering plugin/setup file is loaded for the project running the test.
- Use TypeScript keyof types so a renamed command produces a compile error.
When it happens
Trigger: Calling a browser command from a test (e.g. browser.commands.foo()) that was never registered via registerCommand or via config.browser.commands; a typo in the command name; a command registered on a different project than the one running the test.
Common situations: Removing a plugin that registered a command but leaving calls to it in tests; renaming a command without updating call sites; running a test under a different project/instance whose commands set does not include the command.
Related errors
- Commands are only available for browser tests.
- All browser instances within a project must use the same…
- benchmark provider did not return a result for
- Benchmark provider loaded from
- browser is not initialized
AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11).
Data as JSON: /api/errors/aa575cadac370acd.
Report an issue: GitHub.
Appendix: 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 1fa9837ec2)