cypress-io/cypress · error · SchematicsException

Invalid project name: ${options.project}

Error message

Invalid project name: ${options.project}

What it means

Raised by the cypress-ct-tests ng-generate schematic when options.project is falsy. This schematic generates component-testing specs by reading the named project from angular.json (projects[options.project]) and needs a concrete project to locate sourceRoot, so it refuses to run without one rather than guessing.

Source

Thrown at npm/cypress-schematic/src/schematics/ng-generate/cypress-ct-tests/index.ts:9

import { Rule, Tree, SchematicsException } from '@angular-devkit/schematics'

import { getAngularJsonValue, getDirectoriesAndCreateSpecs } from '../../utils'
import { Schema } from './schema'

export default function (options: Schema): Rule {
  return (tree: Tree) => {
    if (!options.project) {
      throw new SchematicsException(`Invalid project name: ${options.project}`)
    }

    const angularJsonValue = getAngularJsonValue(tree)
    const { projects } = angularJsonValue
    const project = projects[options.project]

    const appPath = `${project.sourceRoot}`

    return getDirectoriesAndCreateSpecs({ tree, appPath })
  }
}

View on GitHub (pinned to 0d85fdc912)

Solutions

  1. Pass the project name explicitly: `ng generate @cypress/schematic:cypress-ct-tests --project <name>`.
  2. Confirm the project name matches a key under projects in angular.json.
  3. If you expect a default project, ensure angular.json sets a defaultProject (note: this schematic does not fall back to it — you must pass --project).

Example fix

# before: ng g @cypress/schematic:cypress-ct-tests
# after: ng g @cypress/schematic:cypress-ct-tests --project app
Defensive patterns

Strategy: validation

Validate before calling

function assertProjectOption(options: { project?: string }) {
  if (!options.project) {
    throw new Error('--project is required for the cypress-ct-tests schematic')
  }
  return options.project
}

Type guard

function hasProjectName(o: { project?: string }): o is { project: string } {
  return typeof o.project === 'string' && o.project.length > 0
}

Prevention

When it happens

Trigger: Running `ng generate @cypress/schematic:cypress-ct-tests` (or the alias) without a --project flag in a workspace that has no default project resolution into options.project, or with an explicit empty --project.

Common situations: Forgetting the --project flag in a multi-app workspace; a wrapper script that drops the flag; an Angular CLI version that does not auto-populate options.project from the default project.

Related errors


AI-assisted analysis of cypress-io/cypress@0d85fdc912 (2026-08-12). Data as JSON: /api/errors/7e8e749fd02a56ba. Report an issue: GitHub.