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 ¶
- func DetectFramework(pkg *PackageJSON) string
- func DetectPackageManager(pkg *PackageJSON, appDir string) string
- func ExpandSuites[T comparable](suites []T) []T
- func FilterExistingDirs(appDir string, dirs []string) []string
- func FindPytest(appDir string) string
- func FrameworkCommand(pm string, framework string, dirs []string, coverage bool) []string
- func PytestArgs(pytestBin string, dirs []string, coverage bool) []string
- type PackageJSON
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 ¶
FilterExistingDirs returns only the directories that exist relative to appDir.
func FindPytest ¶
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 ¶
FrameworkCommand builds the test runner command for a given framework.
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").