{"id":"0b4d26899d30309f","repo":"vitest-dev/vitest","slug":"browser-instances-was-set-in-the-config-but-the","errorCode":null,"errorMessage":"\"browser.instances\" was set in the config, but the array is empty. Define at least one browser config. The \"browser.name\" was set to \"${browser.name}\" which filtered all configs (${instances.map(c => c.browser).join(', ')}). Did you mean to use another name?","messagePattern":"\"browser\\.instances\" was set in the config, but the array is empty\\. Define at least one browser config\\. The \"browser\\.name\" was set to \"(.+?)\" which filtered all configs \\((.+?)\\)\\. Did you mean to use another name\\?","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/config/resolveConfig.ts","lineNumber":437,"sourceCode":"      )\n    }\n    browser.provider ??= browser.instances.find(instance => instance.provider)?.provider\n\n    // use `chromium` by default when the preview provider is specified\n    // for a smoother experience. if chromium is not available, it will\n    // open the default browser anyway\n    if (!browser.instances.length && browser.provider?.name === 'preview') {\n      browser.instances = [{ browser: 'chromium' }]\n    }\n\n    if (browser.name && instances?.length) {\n      // --browser=chromium filters configs to a single one\n      browser.instances = browser.instances.filter(instance => instance.browser === browser.name)\n\n      // if `instances` were defined, but now they are empty,\n      // let's throw an error because the filter is invalid\n      if (!browser.instances.length) {\n        throw new Error([\n          `\"browser.instances\" was set in the config, but the array is empty. Define at least one browser config.`,\n          ` The \"browser.name\" was set to \"${browser.name}\" which filtered all configs (${instances.map(c => c.browser).join(', ')}). Did you mean to use another name?`,\n        ].join(''))\n      }\n    }\n\n    browser.instances.forEach((instance) => {\n      instance.name ??= resolved.name\n        ? `${resolved.name} (${instance.browser})`\n        : instance.browser\n    })\n  }\n\n  if (resolved.coverage.enabled && resolved.coverage.provider === 'istanbul' && resolved.experimental?.viteModuleRunner === false) {\n    throw new Error(`\"Istanbul\" coverage provider is not compatible with \"experimental.viteModuleRunner: false\". Please, enable \"viteModuleRunner\" or switch to \"v8\" coverage provider.`)\n  }\n\n  if (browser.enabled && resolved.detectAsyncLeaks) {","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/config/resolveConfig.ts#L419-L455","documentation":"When `browser.name` is set (often via `--browser=chromium`), Vitest filters `browser.instances` to those whose `browser` field matches that name. If the filter removes every instance, the config is left with no runnable browser, so resolveConfig.ts:436 throws with the list of configured browser names to help you spot the mismatch.","triggerScenarios":"Config defines `browser.instances: [{ browser: 'firefox' }]` and you run `vitest --browser=chromium`. The filter at line 432 removes the firefox instance, leaving an empty array.","commonSituations":"Passing --browser with a name that doesn't match any defined instance; typo'd browser name; defaulting to chromium when only webkit/firefox are configured.","solutions":["Pass a name that matches one of your configured instances: `--browser=firefox`.","Add an instance for the browser you want to target: `instances: [{ browser: 'chromium' }, ...]`.","Drop --browser to run all configured instances, or remove the filter to let Vitest pick."],"exampleFix":"// config: instances: [{ browser: 'firefox' }]\n# before\nvitest --browser=chromium\n# after\nvitest --browser=firefox","handlingStrategy":"validation","validationCode":"function assertBrowserNameMatchesInstance(opts: { name?: string; instances?: { browser: string }[] }) {\n  if (opts.name && opts.instances?.length && !opts.instances.some(i => i.browser === opts.name)) {\n    throw new Error(`--browser=${opts.name} matches no instance (${opts.instances.map(i => i.browser).join(', ')})`)\n  }\n}","typeGuard":"function browserNameHasMatch(opts: { name?: string; instances?: { browser: string }[] }): boolean {\n  return !opts.name || !opts.instances?.length || opts.instances.some(i => i.browser === opts.name)\n}","tryCatchPattern":null,"preventionTips":["Cross-check --browser values against configured instances.","Add an instance for each browser you intend to target via --browser.","Omit --browser to run all instances."],"tags":["cli","browser","instances","filter","config"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}