PackageTestScripts
constPackageTestScripts:FilePolicyDefinition<PackageTestScriptsConfig|undefined> &object
Defined in: policies/PackageTestScripts.ts:215
A policy that ensures packages have test scripts when test files exist.
This policy helps maintain testing discipline by requiring test scripts for packages that have test directories or test framework dependencies.
Type Declaration
Section titled “Type Declaration”requiresConfig
Section titled “requiresConfig”requiresConfig:
true
Remarks
Section titled “Remarks”The policy detects that tests are expected based on:
- Test directories: If
test/,tests/, or__tests__/exists - Test dependencies: If vitest, jest, mocha, etc. are in devDependencies
When tests are detected, the policy requires specified test scripts to exist.
Example
Section titled “Example”import { makePolicy } from "repopo";import { PackageTestScripts } from "repopo/policies";
const config: RepopoConfig = { policies: [ makePolicy(PackageTestScripts, { config: { testDirectories: ["test", "tests"], testDependencies: ["vitest", "jest"], requiredScripts: ["test"], }, }), ],};