vitest-dev/vitest · error · TypeError
The " " browser provider does not provide a…
Error message
The "${name}" browser provider does not provide a "providerFactory" function. Received ${typeof options.provider.providerFactory}. What it means
A TypeError thrown when the resolved provider object exists but its providerFactory field is not a function. The factory is what Vitest calls as providerFactory(project) to build the live provider instance; a missing/non-function factory means the provider object is malformed.
Solutions
- If shipping a custom provider, expose providerFactory: (project) => BrowserProviderInstance as a method on the provider definition.
- Upgrade or downgrade the provider package to the version compatible with your installed @vitest/browser (check the peer range).
- Audit your provider object dump (console.log(options.provider)) to confirm the expected function exists at the right key.
Example fix
// before: custom provider missing the factory
const myProvider = { name: 'mine', supportedBrowser: ['chromium'] }
// after
const myProvider = {
name: 'mine',
supportedBrowser: ['chromium'],
providerFactory: (project) => new MyProviderInstance(project),
} Defensive patterns
Strategy: type-guard
Validate before calling
function assertProviderFactory(p) {
if (typeof p?.providerFactory !== 'function') {
throw new TypeError(`Provider "${p?.name}" is missing providerFactory(project).`)
}
} Type guard
function hasProviderFactory(p): p is { providerFactory: (project: unknown) => unknown } {
return !!p && typeof p.providerFactory === 'function'
} Prevention
- When writing a custom provider, type it against the BrowserProvider interface so the factory is enforced at compile time.
- Pin provider package versions to the compatible range; providerFactory was introduced in a specific major.
When it happens
Trigger: options.provider passes the null check and the supportedBrowser check, but typeof options.provider.providerFactory !== 'function' — e.g. it is undefined, a string, or an object.
Common situations: A hand-rolled custom provider that omits the providerFactory method; a provider package whose public surface changed across versions (breaking change); partial mock of a provider in a plugin.
Related errors
- All browser instances within a project must use the same…
- browser is not initialized
- Browser Mode requires the "provider" to always be specified.
- Browser Mode was enabled, but provider was not specified…
- Commands are only available for browser tests.
AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11).
Data as JSON: /api/errors/69a9d457293db0c3.
Report an issue: GitHub.
Appendix: source
Thrown at packages/browser/src/node/utils.ts:91
const name = project.name ? `[${project.name}] ` : ''
if (!browser) {
throw new Error(
`${name}Browser name is required. Please, set \`test.browser.instances[].browser\` option manually.`,
)
}
if (options.provider == null) {
throw new Error(`Browser Mode requires the "provider" to always be specified.`)
}
const supportedBrowsers = options.provider.supportedBrowser || []
if (supportedBrowsers.length && !supportedBrowsers.includes(browser)) {
throw new Error(
`${name}Browser "${browser}" is not supported by the browser provider "${
options.provider.name
}". Supported browsers: ${supportedBrowsers.join(', ')}.`,
)
}
if (typeof options.provider.providerFactory !== 'function') {
throw new TypeError(`The "${name}" browser provider does not provide a "providerFactory" function. Received ${typeof options.provider.providerFactory}.`)
}
return options.provider.providerFactory(project)
}
export function slash(path: string): string {
return path.replace(/\\/g, '/').replace(/\/+/g, '/')
}
export function assertBrowserFileAccess(project: TestProject, path: string): void {
const normalized = slash(path)
if (
!isFileLoadingAllowed(project.vite.config, normalized)
&& !isFileLoadingAllowed(project.vitest.vite.config, normalized)
) {
throw new Error(
`Access denied to "${path}". See Vite config documentation for "server.fs": https://vitejs.dev/config/server-options.html#server-fs-strict.`,
)
}View on GitHub (pinned to 1fa9837ec2)