cypress-io/cypress · error · SchematicsException
No file name specified. This is required to generate a new C
Error message
No file name specified. This is required to generate a new Cypress file.
What it means
Raised by the cypress-test ng-generate schematic when options.name is undefined. The name becomes the spec file name in the generated template (the templates use __path__/name substitution), so without it the schematic cannot produce a file. The schematic checks this after resolving the project, so a valid project is required first.
Source
Thrown at npm/cypress-schematic/src/schematics/ng-generate/cypress-test/index.ts:53
return async (tree: Tree) => {
const host = createSpec(tree)
const { workspace } = await workspaces.readWorkspace('/', host)
const testType = options.component ? 'component' : 'e2e'
let project
if (!options.project) {
project = workspace.projects.get(workspace.extensions.defaultProject as string)
} else {
project = workspace.projects.get(options.project)
}
if (!project) {
throw new SchematicsException(`Invalid project name: ${options.project}`)
}
if (options.name === undefined) {
throw new SchematicsException(`No file name specified. This is required to generate a new Cypress file.`)
}
if (options.path === undefined) {
options.path = testType === 'component' ? `${project.sourceRoot}/${project.prefix}` : `${project.root}/cypress/e2e`
}
console.log(`Creating new ${testType} spec named: ${options.name}`)
const templatePath = testType === 'component' ? '../files/ct/__path__' : '../files/e2e/__path__'
const templateSource = createTemplate({ templatePath, options })
return chain([
mergeWith(templateSource),
])
}
}
View on GitHub (pinned to 0d85fdc912)
Solutions
- Pass a name: `ng generate @cypress/schematic:cypress-test --project app --name <spec-name>`.
- If using the positional form, ensure the name argument is forwarded: `ng g @cypress/schematic:cypress-test <name> --project app`.
- Check that a custom schematic alias or script template includes the --name option.
Example fix
# before: ng g @cypress/schematic:cypress-test --project app # after: ng g @cypress/schematic:cypress-test --project app --name login
Defensive patterns
Strategy: validation
Validate before calling
function assertName(options: { name?: string }) {
if (options.name === undefined || options.name === '') {
throw new Error('--name is required to generate a Cypress spec')
}
return options.name
} Type guard
function hasName(o: { name?: string }): o is { name: string } {
return typeof o.name === 'string' && o.name.length > 0
} Prevention
- Always pass --name (or the positional name) when invoking the cypress-test schematic.
- Validate options in wrapper scripts that build schematic commands.
- Document the required --name flag for your team's generators.
When it happens
Trigger: Running `ng generate @cypress/schematic:cypress-test --project app` with no --name flag, or an Angular CLI invocation that does not forward the positional name argument into options.name.
Common situations: Forgetting the --name flag; a wrapper script that constructs the schematic command without a name; a CLI alias that strips the positional argument.
Related errors
- Invalid project name: ${options.project}
- File not found.
- Invalid project name: ${options.project}
- projects in angular.json is not defined
- angular.json not found
AI-assisted analysis of cypress-io/cypress@0d85fdc912 (2026-08-12).
Data as JSON: /api/errors/2dccdc6bd55a6df5.
Report an issue: GitHub.