testkit-cli
v1.0.0
Published
<p align="center"> <img src=".github/assets/banner.svg" alt="testkit-cli banner" width="800"/> </p>
Downloads
17
Maintainers
Readme
testkit-cli
Test coverage analysis, quality detection, and test generation CLI — find untested code, detect anti-patterns, and generate tests from your terminal.
No MCP. No external APIs. Pure filesystem analysis with regex-based code parsing.
Install
npm install -g testkit-cli
# or run without installing:
npx testkit-cli coverage .Architecture
graph LR
A[terminal] --> B[testkit CLI]
B --> C[analysis engine]
C --> D[coverage-parser]
C --> E[ast-analyzer]
C --> F[config-validator]
C --> G[project-scanner]
D --> H[results]
E --> H
F --> H
G --> H
H --> I[formatters]
I --> J[human-readable output]
H --> K[--json flag]
K --> L[JSON output]Commands
testkit coverage [path]
Analyze test coverage for a project.
testkit coverage .
testkit coverage ./my-project --threshold 90
testkit coverage . --coverage-path ./coverage/lcov.json --jsonOptions:
--coverage-path <path>— explicit path to coverage JSON (auto-detected if omitted)--threshold <n>— minimum coverage % (default: 80)--json— JSON output
Exit codes: 0 = success, 1 = error, 2 = coverage below threshold (for CI)
Example output:
Coverage Report — my-project
────────────────────────────────────────────────────────────
File Lines Branch Fn
src/utils.ts 92% 85% 100%
src/api.ts 45% 30% 50% ← below threshold
Overall: 78% lines | 72% branches | 83% functions
Files below 80% threshold: 1 of 2testkit missing [path]
Find source files with missing tests.
testkit missing .
testkit missing . --include "src/**/*.ts" --jsonOptions:
--include <patterns...>— glob patterns for source files--exclude <patterns...>— glob patterns to exclude--json— JSON output
testkit quality [path]
Analyze test quality and detect anti-patterns.
testkit quality .
testkit quality . --min-score 80Options:
--min-score <n>— minimum quality score (exit 2 if below)--json— JSON output
Detected patterns: assertion-free, snapshot-heavy, implementation-coupled, hardcoded-timeout, no-error-tests, console-pollution, broad-mock
testkit config [path]
Validate test configuration and detect issues.
testkit config .
testkit config . --jsonOptions:
--json— JSON output
testkit generate unit <file>
Generate unit test scaffolds for a source file.
testkit generate unit src/utils.ts
testkit generate unit src/api.ts --framework jest --output tests/api.test.ts
testkit generate unit src/utils.ts --jsonOptions:
--framework <vitest|jest>— test framework (auto-detected or defaults to vitest)--output <path>— write to file instead of stdout--json— JSON output
testkit generate integration <file>
Generate integration test scaffolds for a route file.
testkit generate integration src/routes/users.ts
testkit generate integration src/routes/auth.ts --output tests/auth.integration.test.tsOptions:
--framework <vitest|jest>— test framework--output <path>— write to file instead of stdout--json— JSON output
testkit generate e2e <description>
Generate E2E test scaffold from a flow description.
testkit generate e2e "user logs in and views dashboard"
testkit generate e2e "checkout flow" --framework cypress --output cypress/e2e/checkout.cy.tsOptions:
--framework <playwright|cypress>— E2E framework (default: playwright)--output <path>— write to file instead of stdout--json— JSON output
Global Options
| Option | Description |
|:-------|:-----------|
| --json | Output as JSON instead of human-readable |
| -V, --version | Print version |
| -h, --help | Print help |
CI Integration
# GitHub Actions
- name: Check coverage
run: npx testkit-cli coverage . --threshold 80
# exits 2 if below threshold, 1 on error
- name: Check test quality
run: npx testkit-cli quality . --min-score 70Exit Codes
| Code | Meaning | |:-----|:--------| | 0 | Success | | 1 | Error (invalid input, file not found) | | 2 | Threshold/score check failed (for CI) |
Pro Features
Set PRO_LICENSE environment variable to unlock:
testkit mutate <file> (PRO)
Run mutation testing to assess test effectiveness.
PRO_LICENSE=your-key testkit mutate src/utils.ts
PRO_LICENSE=your-key testkit mutate src/api.ts --test-command "npx jest" --timeout 60000Options: --test-command <cmd>, --timeout <ms>, --json
testkit flaky [path] (PRO)
Detect flaky test indicators via static analysis (timing, network, shared state, async race, order dependency).
PRO_LICENSE=your-key testkit flaky .testkit impact <files...> (PRO)
Analyze which tests are affected by changed source files (BFS import graph).
PRO_LICENSE=your-key testkit impact src/utils.ts src/api.tstestkit snapshots [path] (PRO)
Audit snapshot tests for issues (oversized, implementation-detail, missing companion assertions).
PRO_LICENSE=your-key testkit snapshots .testkit mocks [path] (PRO)
Analyze mock patterns in test files (over-mocked, broad-mock, signature-mismatch).
PRO_LICENSE=your-key testkit mocks .testkit report [path] (PRO)
Generate a comprehensive test health report combining coverage, missing, quality, and config analysis.
PRO_LICENSE=your-key testkit report .
PRO_LICENSE=your-key testkit report . --format markdown --output report.mdOptions: --format <json|markdown>, --output <file>, --json
Get a license at craftpipe.dev/testkit-cli.
Supported Frameworks
- vitest (auto-detected from
vitest.config.*) - jest (auto-detected from
jest.config.*orpackage.json#jest) - mocha (auto-detected from
.mocharc.*)
License
MIT — see LICENSE
Built by Craftpipe
