angular/angular-cli · error · SchematicsException
Project "${options.project}" does not have a "test" target w
Error message
Project "${options.project}" does not have a "test" target with a supported builder. What it means
The vitest-browser schematic requires the target project's "test" target to already use the unit-test (Vitest) builder (Builders.BuildUnitTest). If the target is missing or built with a different builder, this SchematicsException is thrown because browser mode can only be layered onto a Vitest-based test setup.
Source
Thrown at packages/schematics/angular/vitest-browser/index.ts:40
} from '../utility/dependency';
import { JSONFile } from '../utility/json-file';
import { latestVersions } from '../utility/latest-versions';
import { getWorkspace } from '../utility/workspace';
import { Builders } from '../utility/workspace-models';
import { Schema as VitestBrowserOptions } from './schema';
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') {View on GitHub (pinned to bb72145f9a)
Solutions
- First run the unit-test/Vitest migration schematic (`ng generate init-vitest` or the project's migration command) so the test target uses @angular/build:unit-test, then rerun vitest-browser.
- Manually set the test target's builder to @angular/build:unit-test in angular.json.
- Add a "test" target if the project has none, configured with the Vitest builder.
- Verify with `ng config projects.<name>.architect.test.builder` that the builder is the supported one before running the schematic.
Example fix
// before (angular.json)
"test": { "builder": "@angular-devkit/build-angular:karma", ... }
// after
"test": { "builder": "@angular/build:unit-test", ... } Defensive patterns
Strategy: validation
Validate before calling
const ws = JSON.parse(fs.readFileSync('angular.json', 'utf8'));
const test = ws.projects?.[name]?.architect?.test ?? ws.projects?.[name]?.targets?.test;
if (test?.builder !== '@angular/build:unit-test') {
throw new Error(`Project "${name}" must first migrate its test target to the Vitest unit-test builder.`);
} Try / catch
try {
await ngGenerate(['vitest-browser', '--project', name]);
} catch (e) {
if (String((e as Error).message).includes('supported builder')) {
await ngGenerate(['init-vitest', '--project', name]); // migrate first, then retry
} else throw e;
} Prevention
- Complete the Karma-to-Vitest migration before layering browser testing on a project.
- Check the test target builder string in angular.json equals @angular/build:unit-test.
- Ensure every project that will use vitest-browser has an explicit "test" target.
When it happens
Trigger: Running the vitest-browser schematic on a project whose angular.json either has no "test" target at all, or whose test target's builder is not the @angular/build unit-test builder (e.g. karma builder or a custom builder string).
Common situations: Projects still on Karma, projects created before the Vitest migration where the test target was never converted, hand-edited angular.json with a custom test builder, or applying the schematic to a library without a test target.
Related errors
- No "test" target found for project "${options.project}". A "
- Cannot add a Vitest configuration as builder for "test" targ
- Project "${options.project}" does not exist.
- Project "${options.project}" is configured to use Karma. Ple
- Project "${projectName}" uses a custom coverage reporter "${
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/64d02195df0ad51c.
Report an issue: GitHub.