detect

package
v0.0.0-...-3776344 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package detect provides pure detection and command-building logic for test runners, extracted so it can be unit-tested without executing shell commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectFramework

func DetectFramework(pkg *PackageJSON) string

DetectFramework detects the test framework from package.json dependencies.

func DetectPackageManager

func DetectPackageManager(pkg *PackageJSON, appDir string) string

DetectPackageManager determines the Node.js package manager from the packageManager field or lock files on disk.

func ExpandSuites

func ExpandSuites[T comparable](suites []T) []T

ExpandSuites deduplicates a list of suite names.

func FilterExistingDirs

func FilterExistingDirs(appDir string, dirs []string) []string

FilterExistingDirs returns only the directories that exist relative to appDir.

func FindPytest

func FindPytest(appDir string) string

FindPytest looks for pytest in common virtualenv locations, then falls back to checking if "pytest" is on the system PATH (returns empty string if not found).

func FrameworkCommand

func FrameworkCommand(pm string, framework string, dirs []string, coverage bool) []string

FrameworkCommand builds the test runner command for a given framework.

func PytestArgs

func PytestArgs(pytestBin string, dirs []string, coverage bool) []string

PytestArgs builds the pytest command-line arguments.

Types

type PackageJSON

type PackageJSON struct {
	Type            string            `json:"type"`
	PackageManager  string            `json:"packageManager"`
	Scripts         map[string]string `json:"scripts"`
	DevDependencies map[string]string `json:"devDependencies"`
	Dependencies    map[string]string `json:"dependencies"`
}

PackageJSON holds the fields we need from a Node.js package.json.

func LoadPackageJSON

func LoadPackageJSON(appDir string) (*PackageJSON, error)

LoadPackageJSON reads and parses the package.json in appDir.

func (*PackageJSON) IsESM

func (p *PackageJSON) IsESM() bool

IsESM returns true if the package uses ES modules ("type": "module").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL