{"record":{"id":"394591d530c19590","repo":"angular/angular-cli","slug":"project-options-project-is-configured-to-use","errorCode":null,"errorMessage":"Project \"${options.project}\" is configured to use Karma. Please migrate to Vitest before adding browser testing support.","messagePattern":"Project \"(.+?)\" is configured to use Karma\\. Please migrate to Vitest before adding browser testing support\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/vitest-browser/index.ts","lineNumber":46,"sourceCode":"\nexport default function (options: VitestBrowserOptions): Rule {\n  return async (host: Tree, _context: SchematicContext) => {\n    const workspace = await getWorkspace(host);\n    const project = workspace.projects.get(options.project);\n\n    if (!project) {\n      throw new SchematicsException(`Project \"${options.project}\" does not exist.`);\n    }\n\n    const testTarget = project.targets.get('test');\n    if (testTarget?.builder !== Builders.BuildUnitTest) {\n      throw new SchematicsException(\n        `Project \"${options.project}\" does not have a \"test\" target with a supported builder.`,\n      );\n    }\n\n    if (testTarget.options?.['runner'] === 'karma') {\n      throw new SchematicsException(\n        `Project \"${options.project}\" is configured to use Karma. ` +\n          'Please migrate to Vitest before adding browser testing support.',\n      );\n    }\n\n    const packageName = options.package;\n    if (!packageName) {\n      return;\n    }\n\n    const dependencies = [packageName];\n    if (packageName === '@vitest/browser-playwright') {\n      dependencies.push('playwright');\n    } else if (packageName === '@vitest/browser-webdriverio') {\n      dependencies.push('webdriverio');\n    }\n\n    // Update tsconfig.spec.json","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/vitest-browser/index.ts#L28-L64","documentation":"The vitest-browser schematic refuses to run on projects whose test target still has runner 'karma'. Browser testing support here is built for Vitest; you must complete the Karma-to-Vitest migration first, so this SchematicsException instructs the user to migrate.","triggerScenarios":"Running the vitest-browser schematic on a project where testTarget.options['runner'] === 'karma' — i.e. the unit-test builder is present but explicitly configured with the Karma runner.","commonSituations":"Partially migrated projects: the builder was updated to the unit-test builder but the runner option still says karma, or the user opted out of the Vitest migration and later tries to add browser testing.","solutions":["Run the official Karma-to-Vitest migration (`ng generate unit-test` migration / `ng update` flow) to switch the runner, then rerun vitest-browser.","Remove the \"runner\": \"karma\" option (or set it to 'vitest') in the project's test target options in angular.json.","Clean up leftover karma config (karma.conf.js, karma deps) after switching to Vitest so future schematics detect the Vitest setup correctly."],"exampleFix":"// before (angular.json test target options)\n\"options\": { \"runner\": \"karma\" }\n// after\n\"options\": { \"runner\": \"vitest\" }","handlingStrategy":"validation","validationCode":"const ws = JSON.parse(fs.readFileSync('angular.json', 'utf8'));\nconst runner = ws.projects?.[name]?.architect?.test?.options?.runner;\nif (runner === 'karma') {\n  throw new Error(`Project \"${name}\" still uses Karma; migrate to Vitest before adding browser testing.`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ngGenerate(['vitest-browser', '--project', name]);\n} catch (e) {\n  if (String((e as Error).message).includes('use Karma')) {\n    console.error('Run the Vitest migration first; then rerun this schematic.');\n  } else throw e;\n}","preventionTips":["Remove or update \"runner\": \"karma\" in the test target options once migrated to Vitest.","Run the official ng update migration to switch Karma to Vitest wholesale rather than partial edits.","Grep angular.json in CI for lingering karma runner options."],"tags":["schematics","vitest","karma","migration"],"backgroundTag":"karma-runner-still-configured","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}