cypress-io/cypress · error · RunSpecError

NO_PROJECT

NO_PROJECT

Error message

A project must be open prior to attempting to run a spec

What it means

Thrown by ProjectActions.runSpec (ProjectActions.ts:519-521) with code NO_PROJECT when this.ctx.currentProject is null at the moment runSpec is invoked. runSpec is the action that launches a specific spec file; it needs an active, opened project to resolve the spec path against. The error is wrapped into a RunSpecError and the surrounding catch returns { code: 'NO_PROJECT', detailMessage } rather than rethrowing, so callers receive a structured result, not a thrown exception.

Source

Thrown at packages/data-context/src/actions/ProjectActions.ts:520

      let maxIterations = 3

      while (this.ctx.coreData.app.browserStatus !== 'open') {
        await Promise.race([
          new Promise((resolve) => setTimeout(resolve, 1000)),
          browserStatusSubscription.next(),
        ])

        if (--maxIterations === 0) {
          break
        }
      }

      await browserStatusSubscription.return(undefined as any)
    }

    try {
      if (!this.ctx.currentProject) {
        throw new RunSpecError('NO_PROJECT', 'A project must be open prior to attempting to run a spec')
      }

      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 {

View on GitHub (pinned to 0d85fdc912)

Solutions

  1. Ensure a project is opened first (await the openProject/launchProject flow) and that ctx.currentProject is set before invoking runSpec.
  2. If this appears after an error, check why currentProject is null (prior open failure, config error in diagnostics) and re-open the project.
  3. In the UI/GraphQL layer, disable the run-spec control until currentProject is non-null.

Example fix

// before
const result = await ctx.actions.runSpec({ specPath })

// after
if (!ctx.currentProject) {
  await ctx.actions.openProject(/* ... */) // finish opening first
}
const result = await ctx.actions.runSpec({ specPath })
Defensive patterns

Strategy: validation

Validate before calling

// Validate project-open state before invoking runSpec
function canRunSpec(ctx: DataContext): boolean {
  return ctx.currentProject != null
}

if (!canRunSpec(ctx)) {
  // open a project first, or surface the requirement to the launchpad
  return
}
const result = await ctx.actions.runSpec({ specPath })

Prevention

When it happens

Trigger: Calling the runSpec mutation/action before a project has been opened/initialized (currentProject still null). Happens if the GraphQL runSpec mutation fires during launchpad onboarding before openProject completes, or after a project was closed/errored and currentProject was reset to null.

Common situations: Race during launchpad startup where the UI triggers a run before project open finishes; a previous project-open failed and left currentProject null; the user backed out to project selection and a stale run request fired; programmatic/automated driver that calls runSpec without first opening a project.

Related errors


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