{"record":{"id":"5a41490f56076908","repo":"cypress-io/cypress","slug":"cannot-generate-a-spec-without-a-framework","errorCode":null,"errorMessage":"Cannot generate a spec without a framework","messagePattern":"Cannot generate a spec without a framework","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/data-context/src/codegen/spec-options.ts","lineNumber":55,"sourceCode":"    this.parsedPath = path.parse(options.codeGenPath)\n  }\n\n  async getCodeGenOptions () {\n    if (this.options.codeGenType === 'component') {\n      return this.getComponentCodeGenOptions()\n    }\n\n    return {\n      codeGenType: this.options.codeGenType,\n      fileName: await this.buildFileName(),\n      templateKey: this.options.codeGenType as TemplateKey,\n      overrideCodeGenDir: '',\n    }\n  }\n\n  private async getComponentCodeGenOptions () {\n    if (!this.options.framework) {\n      throw new Error('Cannot generate a spec without a framework')\n    }\n\n    switch (this.options.framework.codeGenFramework) {\n      case 'react':\n        return await this.getReactSpecOptions()\n      case 'vue':\n        return await this.getVueSpecOptions()\n      default:\n        throw new Error(`Unable to generate spec for ${this.options.framework.codeGenFramework}`)\n    }\n  }\n\n  private getRelativePathToComponent (specParsedPath?: ParsedPath) {\n    if (specParsedPath) {\n      const componentPathRelative = path.relative(specParsedPath.dir, this.parsedPath.dir)\n\n      const componentPath = path.join(componentPathRelative, this.parsedPath.base)\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/cypress-io/cypress/blob/0d85fdc91230885bca0a91df278312800a48b727/packages/data-context/src/codegen/spec-options.ts#L37-L73","documentation":"Thrown by SpecOptions.getComponentCodeGenOptions when this.options.framework is falsy. Component spec generation needs a framework (React, Vue, etc.) to pick the right template and import shape; e2e generation does not. The code path is reached only when codeGenType === 'component', and the guard is a hard stop because there is no sensible default framework.","triggerScenarios":"The Launchpad / scaffold flow calls SpecOptions with codeGenType: 'component' but no framework detected in the project. This happens when framework detection (@packages/scaffold-config) returned nothing — e.g. a project with no React/Vue/Angular/Svelte imports, a brand-new empty project, or a project using a framework Cypress does not yet detect.","commonSituations":"User clicked 'Create new spec' -> 'Component' before configuring a component framework in the Launchpad, framework detection ran on a project whose source files do not import a known framework, or the framework detection cache is stale.","solutions":["In the Launchpad, complete the framework setup step so Cypress records a detected/selected framework before generating a component spec.","Install at least one component-testing-supported framework (react, vue, etc.) and import it in a source file so detection succeeds.","If detection should work, restart the Launchpad so the framework cache refreshes.","For unsupported frameworks, fall back to generating an empty component spec (componentEmpty template) or use e2e generation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function assertFrameworkForComponentSpec (opts: { codeGenType: string; framework?: unknown }) {\n  if (opts.codeGenType === 'component' && !opts.framework) {\n    throw new Error('Configure a component framework in the Launchpad before generating a spec')\n  }\n}","typeGuard":"function hasFramework (opts: { framework?: unknown }): opts is { framework: Cypress.ResolvedComponentFrameworkDefinition } {\n  return Boolean(opts.framework)\n}","tryCatchPattern":null,"preventionTips":["Complete framework setup in the Launchpad before scaffolding component specs.","Install at least one supported component framework and import it in a source file.","Restart the Launchpad to refresh framework detection."],"tags":["codegen","scaffolding","framework-detection","component-testing"],"backgroundTag":null,"analyzedSha":"0d85fdc91230885bca0a91df278312800a48b727","analyzedAt":"2026-08-12T16:24:28.056Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}