Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Cypress io Cypress DetectFramework

From Leeroopedia
Knowledge Sources
Domains Configuration, Component_Testing
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tool for automatically detecting the UI framework and bundler in a project provided by the @packages/scaffold-config module.

Description

The detectFramework function iterates through known framework definitions (CT_FRAMEWORKS), checking if required dependencies are installed at satisfying versions. It uses resolve-package-path for fast dependency resolution and semver for version constraint matching. The function prioritizes template frameworks over library frameworks.

Usage

Call this function during the Cypress setup wizard or programmatically when auto-configuring component testing. It requires access to the project's node_modules directory.

Code Reference

Source Location

Signature

export async function detectFramework(
  projectPath: string,
  frameworks: Cypress.ResolvedComponentFrameworkDefinition[]
): Promise<DetectFramework>

// Return type
interface DetectFramework {
  framework?: ResolvedComponentFrameworkDefinition
  bundler?: 'vite' | 'webpack'
}

Import

import { detectFramework } from '@packages/scaffold-config'

I/O Contract

Inputs

Name Type Required Description
projectPath string Yes Absolute path to the project root
frameworks ResolvedComponentFrameworkDefinition[] Yes List of known frameworks to detect (CT_FRAMEWORKS)

Outputs

Name Type Description
framework ResolvedComponentFrameworkDefinition or undefined Detected framework definition
bundler 'vite' or 'webpack' or undefined Detected bundler type

Usage Examples

Detecting Project Framework

import { detectFramework } from '@packages/scaffold-config'
import { CT_FRAMEWORKS } from '@packages/scaffold-config/src/frameworks'

const result = await detectFramework('/path/to/project', CT_FRAMEWORKS)

if (result.framework) {
  console.log(`Detected: ${result.framework.name} with ${result.bundler}`)
} else {
  console.log('No framework detected')
}

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment