@hyperfrontend/project-scope/tech/testing

testing

Testing-framework detectors for the unit, integration, and e2e tools commonly used in JavaScript/TypeScript projects.

Covers Jest, Vitest, Mocha, Cypress, and Playwright. Each <tool>Detector follows the shared TestingFrameworkDetector contract and pairs with a <TOOL>_CONFIG_PATTERNS constant describing the config-file shapes it recognizes. detectTestingFrameworks runs all detectors against the project and returns the aggregate TestingFrameworkDetection[].

API Reference

ƒ Functions

§function

cypressDetector(projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection

Detect Cypress in project.

Parameters

NameTypeDescription
§projectPath
string
Project directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

TestingFrameworkDetection
Detection result or null if not detected

Example

Detecting Cypress testing framework

import { cypressDetector } from '@hyperfrontend/project-scope'

const result = cypressDetector('./my-project')
if (result) {
  console.log(`Cypress ${result.version} detected (${result.confidence}% confidence)`)
  // => "Cypress 13.6.0 detected (95% confidence)"
}
§function

detectTestingFrameworks(projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection[]

Detect all testing frameworks in project.

Parameters

NameTypeDescription
§projectPath
string
Project directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

TestingFrameworkDetection[]
Array of detected testing frameworks, sorted by confidence

Example

Detecting multiple testing frameworks

import { detectTestingFrameworks } from '@hyperfrontend/project-scope'

const frameworks = detectTestingFrameworks('./my-project')
// => [
//   { id: 'jest', name: 'Jest', type: 'unit', confidence: 95, ... },
//   { id: 'cypress', name: 'Cypress', type: 'e2e', confidence: 85, ... }
// ]

// Results are sorted by confidence (highest first)
const primary = frameworks[0]?.name ?? 'None'
console.log(`Primary testing framework: ${primary}`)
§function

jestDetector(projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection

Detect Jest in project.

Parameters

NameTypeDescription
§projectPath
string
Project directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

TestingFrameworkDetection
Detection result or null if not detected

Example

Detecting Jest testing framework

import { jestDetector } from '@hyperfrontend/project-scope'

const result = jestDetector('./my-project')
if (result) {
  console.log(`Jest ${result.version} detected`)
  console.log('Sources:', result.detectedFrom.map(s => s.type))
  // => "Sources: ['package.json', 'config-file']"
}
§function

mochaDetector(projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection

Detect Mocha in project.

Parameters

NameTypeDescription
§projectPath
string
Project directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

TestingFrameworkDetection
Detection result or null if not detected

Example

Detecting Mocha testing framework

import { mochaDetector } from '@hyperfrontend/project-scope'

const result = mochaDetector('./my-project')
if (result) {
  console.log(`Mocha ${result.version} detected (${result.confidence}%)`)
  // => "Mocha 10.2.0 detected (95%)"
}
§function

playwrightDetector(projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection

Detect Playwright in project.

Parameters

NameTypeDescription
§projectPath
string
Project directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

TestingFrameworkDetection
Detection result or null if not detected

Example

Detecting Playwright testing framework

import { playwrightDetector } from '@hyperfrontend/project-scope'

const result = playwrightDetector('./my-project')
if (result) {
  console.log(`Playwright ${result.version} (${result.type} tests)`)
  // => "Playwright 1.42.0 (e2e tests)"
}
§function

vitestDetector(projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection

Detect Vitest in project.

Parameters

NameTypeDescription
§projectPath
string
Project directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

TestingFrameworkDetection
Detection result or null if not detected

Example

Detecting Vitest testing framework

import { vitestDetector } from '@hyperfrontend/project-scope'

const result = vitestDetector('./my-project')
if (result) {
  console.log(`Vitest ${result.version} detected`)
  console.log('Config:', result.configPath)
  // => "Config: vitest.config.ts"
}

Interfaces

§interface

TestingFrameworkDetection

Testing framework detection result.

Properties

§confidence:number
Detection confidence (0-100)
§configPath?:string
Config file path
§detectedFrom:DetectionSource[]
Detection sources
§id:string
Framework identifier
§name:string
Human-readable name
§type:"e2e" | "unit" | "integration"
Test type
§version?:string
Detected version
§interface

TestingFrameworkDetector

Testing framework detector interface.

Properties

§id:string
Framework identifier
§name:string
Human-readable name
§testType:"e2e" | "unit" | "integration"
Test type

Variables

§type

CYPRESS_CONFIG_PATTERNS

Config patterns for Cypress
§type

JEST_CONFIG_PATTERNS

Config patterns for Jest
§type

MOCHA_CONFIG_PATTERNS

Config patterns for Mocha
§type

PLAYWRIGHT_CONFIG_PATTERNS

Config patterns for Playwright
§type

testingDetectors

All testing framework detectors
§type

VITEST_CONFIG_PATTERNS

Config patterns for Vitest