{"record":{"id":"1de4b74e9ee180c6","repo":"angular/angular-cli","slug":"no-test-target-found-for-project-options-proj","errorCode":null,"errorMessage":"No \"test\" target found for project \"${options.project}\". A \"test\" target is required to generate a Vitest configuration.","messagePattern":"No \"test\" target found for project \"(.+?)\"\\. A \"test\" target is required to generate a Vitest configuration\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/config/index.ts","lineNumber":55,"sourceCode":"      default:\n        throw new SchematicsException(`\"${options.type}\" is an unknown configuration file type.`);\n    }\n  },\n);\n\nexport default configSchematic;\n\nfunction addVitestConfig(options: ConfigOptions): Rule {\n  return (tree, context) =>\n    updateWorkspace((workspace) => {\n      const project = workspace.projects.get(options.project);\n      if (!project) {\n        throw new SchematicsException(`Project name \"${options.project}\" doesn't not exist.`);\n      }\n\n      const testTarget = project.targets.get('test');\n      if (!testTarget) {\n        throw new SchematicsException(\n          `No \"test\" target found for project \"${options.project}\".` +\n            ' A \"test\" target is required to generate a Vitest configuration.',\n        );\n      }\n\n      if (testTarget.builder !== AngularBuilder.BuildUnitTest) {\n        throw new SchematicsException(\n          `Cannot add a Vitest configuration as builder for \"test\" target in project does not` +\n            ` use \"${AngularBuilder.BuildUnitTest}\".`,\n        );\n      }\n\n      testTarget.options ??= {};\n      testTarget.options.runnerConfig = true;\n\n      // Check runner option.\n      if (testTarget.options.runner === 'karma') {\n        context.logger.warn(","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/config/index.ts#L37-L73","documentation":"After locating the project, `addVitestConfig` requires the project to have a `test` architect target (`project.targets.get('test')`). If the project defines no `test` target, there is nowhere to attach the Vitest configuration, so the schematic throws this exception. The Vitest config generation is designed to augment an existing unit-test builder setup, not to create the target itself.","triggerScenarios":"Running `ng generate config <project> --type vitest` against a project whose angular.json entry lacks a `targets`/`architect` `test` entry — e.g. a plain application generated with only build/serve targets, or a library without a test target.","commonSituations":"Older projects that never had a test target; projects where the test target was manually removed; new libraries created without testing; running the config schematic before adding `@angular/build:unit-test` (or karma) builder to the project.","solutions":["Add a `test` target to the project in angular.json using the unit-test builder, e.g. `\"test\": { \"builder\": \"@angular/build:unit-test\", \"options\": {} }`.","Regenerate testing support with `ng generate config <project> --type vitest` only after the test target exists.","Verify the correct project was targeted — another project in the workspace may already have the test target."],"exampleFix":"// angular.json before\n\"my-app\": { \"architect\": { \"build\": { ... } } }\n// after\n\"my-app\": { \"architect\": {\n  \"build\": { ... },\n  \"test\": { \"builder\": \"@angular/build:unit-test\", \"options\": { \"tsConfig\": \"tsconfig.spec.json\" } }\n} }","handlingStrategy":"validation","validationCode":"const angularJson = JSON.parse(tree.read('angular.json')!.toString('utf8'));\nconst project = angularJson.projects[options.project];\nif (!project?.architect?.test && !project?.targets?.test) {\n  throw new Error(`Project \"${options.project}\" has no \"test\" target; add @angular/build:unit-test first.`);\n}","typeGuard":"function hasTestTarget(p: any): p is { architect: { test: object } } {\n  return !!p && !!(p.architect?.test ?? p.targets?.test);\n}","tryCatchPattern":"try {\n  await runSchematic('config', { project, type: 'vitest' });\n} catch (e) {\n  if (e instanceof SchematicsException && e.message.includes('No \"test\" target')) {\n    console.error('Add a test target (unit-test builder) before generating a Vitest config.');\n  } else throw e;\n}","preventionTips":["Ensure unit testing is initialized (`ng generate config --type vitest` only augments an existing test target).","Check the project's architect/targets section in angular.json before running config schematics.","Verify you targeted the project that actually has tests, not a library without one."],"tags":["angular","schematics","missing-target","vitest"],"backgroundTag":"missing-test-target","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}