angular/angular-cli · error · SchematicsException
Project "${options.project}" is configured to use Karma. Ple
Error message
Project "${options.project}" is configured to use Karma. Please migrate to Vitest before adding browser testing support. What it means
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.
Source
Thrown at packages/schematics/angular/vitest-browser/index.ts:46
export default function (options: VitestBrowserOptions): Rule {
return async (host: Tree, _context: SchematicContext) => {
const workspace = await getWorkspace(host);
const project = workspace.projects.get(options.project);
if (!project) {
throw new SchematicsException(`Project "${options.project}" does not exist.`);
}
const testTarget = project.targets.get('test');
if (testTarget?.builder !== Builders.BuildUnitTest) {
throw new SchematicsException(
`Project "${options.project}" does not have a "test" target with a supported builder.`,
);
}
if (testTarget.options?.['runner'] === 'karma') {
throw new SchematicsException(
`Project "${options.project}" is configured to use Karma. ` +
'Please migrate to Vitest before adding browser testing support.',
);
}
const packageName = options.package;
if (!packageName) {
return;
}
const dependencies = [packageName];
if (packageName === '@vitest/browser-playwright') {
dependencies.push('playwright');
} else if (packageName === '@vitest/browser-webdriverio') {
dependencies.push('webdriverio');
}
// Update tsconfig.spec.jsonView on GitHub (pinned to bb72145f9a)
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.
Example fix
// before (angular.json test target options)
"options": { "runner": "karma" }
// after
"options": { "runner": "vitest" } Defensive patterns
Strategy: validation
Validate before calling
const ws = JSON.parse(fs.readFileSync('angular.json', 'utf8'));
const runner = ws.projects?.[name]?.architect?.test?.options?.runner;
if (runner === 'karma') {
throw new Error(`Project "${name}" still uses Karma; migrate to Vitest before adding browser testing.`);
} Try / catch
try {
await ngGenerate(['vitest-browser', '--project', name]);
} catch (e) {
if (String((e as Error).message).includes('use Karma')) {
console.error('Run the Vitest migration first; then rerun this schematic.');
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Project "${projectName}" uses the "kjhtml" reporter. This ha
- Project "${projectName}" uses a custom Karma reporter "${r}"
- Project "${projectName}" has a non-string reporter in Karma
- No "test" target found for project "${options.project}". A "
- Cannot add a Vitest configuration as builder for "test" targ
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/394591d530c19590.
Report an issue: GitHub.