cypress-io/cypress · error · RunSpecError
NO_SPEC_PATTERN_MATCH
NO_SPEC_PATTERN_MATCH
Error message
Unable to determine testing type, spec does not match any configured specPattern
What it means
Thrown by ProjectActions.runSpec (ProjectActions.ts:538-540) with code NO_SPEC_PATTERN_MATCH after path.relative(currentProject, specPath) is checked against both the e2e specPattern and the component specPattern via matchesSpecPattern and matches neither. The specPattern globs (from cypress.config e2e.specPattern / component.specPattern) define which files count as specs for each testing type; a path that fits neither cannot be assigned a testing type and is rejected. Returned as { code: 'NO_SPEC_PATTERN_MATCH', detailMessage }.
Source
Thrown at packages/data-context/src/actions/ProjectActions.ts:539
}
if (!specPath) {
throw new RunSpecError('NO_SPEC_PATH', '`specPath` must be a non-empty string')
}
let targetTestingType: TestingType
// Get relative path from the specPath to determine which testing type from the specPattern
const relativeSpecPath = path.relative(this.ctx.currentProject, specPath)
// Check to see whether input specPath matches the specPattern for one or the other testing type
// If it matches neither then we can't run the spec and we should error
if (await this.ctx.project.matchesSpecPattern(relativeSpecPath, 'e2e')) {
targetTestingType = 'e2e'
} else if (await this.ctx.project.matchesSpecPattern(relativeSpecPath, 'component')) {
targetTestingType = 'component'
} else {
throw new RunSpecError('NO_SPEC_PATTERN_MATCH', 'Unable to determine testing type, spec does not match any configured specPattern')
}
debug(`Spec %s matches '${targetTestingType}' pattern`, specPath)
debug('Attempting to launch spec %s', specPath)
// Look to see if there's actually a file at the target location
// This helps us avoid switching testingType *then* finding out the spec doesn't exist
if (!this.ctx.fs.existsSync(specPath)) {
throw new RunSpecError('SPEC_NOT_FOUND', `No file exists at path ${specPath}`)
}
// We now know what testingType we need to be in - if we're already there, great
// If not, verify that type is configured then switch (or throw an error if not configured)
if (this.ctx.coreData.currentTestingType !== targetTestingType) {
if (!this.ctx.lifecycleManager.isTestingTypeConfigured(targetTestingType)) {
throw new RunSpecError('TESTING_TYPE_NOT_CONFIGURED', `Input path matched specPattern for '${targetTestingType}' testing type, but it is not configured.`)
}View on GitHub (pinned to 0d85fdc912)
Solutions
- Check your cypress.config e2e.specPattern / component.specPattern and move the file into a directory the glob matches.
- Adjust the specPattern to include the file's location/extension, or restore the default (cypress/e2e for e2e, and the CT src root).
- Confirm specPath is absolute and relative-to-project resolves to the intended file (a wrong project root makes every path 'not match').
- If you intended to run a file Cypress doesn't treat as a spec, rename it to match the pattern (e.g. add the .cy.* suffix).
Example fix
// before (cypress.config.js)
// e2e: { specPattern: 'cypress/e2e/**/*.cy.{js,ts}' }
// spec at ./tests/login.spec.ts -> NO_SPEC_PATTERN_MATCH
// after
// e2e: { specPattern: ['cypress/e2e/**/*.cy.{js,ts}', 'tests/**/*.spec.{js,ts}'] } Defensive patterns
Strategy: validation
Validate before calling
// Pre-check the specPattern match before calling runSpec
const projectRoot = ctx.currentProject
if (projectRoot) {
const rel = path.relative(projectRoot, specPath)
const isE2E = await ctx.project.matchesSpecPattern(rel, 'e2e')
const isCT = await ctx.project.matchesSpecPattern(rel, 'component')
if (!isE2E && !isCT) {
// tell the user the file is outside both specPatterns; do not call runSpec
}
} Prevention
- Keep the e2e.specPattern and component.specPattern in cypress.config aligned with where your spec files actually live.
- When moving/renaming specs, confirm the new path still matches the configured glob before expecting runSpec to accept it.
- Use .cy.* (or your configured) extensions consistently so files are recognized as specs.
When it happens
Trigger: Passing runSpec a specPath whose path relative to the project root does not match either the configured e2e.specPattern or component.specPattern globs. Example: spec lives outside cypress/e2e (or src for CT), or has an extension the pattern excludes.
Common situations: Custom specPattern in cypress.config that narrows which files are specs; a file placed in a directory not covered by the pattern; renamed/moved spec whose new location is outside the glob; mismatched file extension (e.g. *.spec.ts when pattern is *.cy.*); pointing runSpec at a non-spec helper file.
Related errors
- TESTING_TYPE_NOT_CONFIGURED
- Invalid grep burn value: ${grepBurn}
- Could not find a project with projectType "application" in "
- Could not find angular.json. Looked in ${projectRoot} and up
- Cypress cannot compile your Next.js application when "nodeVe
AI-assisted analysis of cypress-io/cypress@0d85fdc912 (2026-08-12).
Data as JSON: /api/errors/3b4cefd7e7dd85e8.
Report an issue: GitHub.