Change-aware, flake-aware test intelligence for CI. Run the tests a change actually touches. Trust the green.
Live demo: zkasuran.github.io/testrazor
Built with Kiro using spec-driven development. The .kiro/
directory in this repo holds the requirements, design, tasks, steering docs and
agent hooks that produced it.
CI has two everyday failures that have nothing to do with your code:
- It reruns the whole suite for a one-line change, so feedback takes minutes.
- A flaky test fails at random, turns the build red and blocks a correct change.
testrazor fixes both from artifacts your suite already emits. No account, no API key, no network. Same inputs, same output.
- Impact. From a git diff (or an explicit changed-file list) and a source import graph, it selects only the test files a change can reach.
- Flake. From two or more JUnit runs, it finds tests that both pass and fail, scores them and quarantines them. A test that only ever fails is a real bug and is never quarantined.
- Gate. One exit code for CI. A quarantined flaky failure does not block. A real failure always does.
git clone https://github.com/zkasuran/testrazor && cd testrazor
npm ci && npm run build
# Impact: which tests does a change to discount.ts touch?
node dist/cli.js impact --root fixtures/sample-repo --changed src/discount.ts
# Flake: find the flaky test across two recorded runs and quarantine it
node dist/cli.js flake \
--report fixtures/sample-repo/runs/run1.xml \
--report fixtures/sample-repo/runs/run2.xml \
--quarantine /tmp/q.json
# Gate: the flaky failure does not block (exit 0). Drop --quarantine to see it fail.
node dist/cli.js gate --report fixtures/sample-repo/runs/run2.xml --quarantine /tmp/q.jsonRequires Node 20+. Clone and npm ci && npm run build, then run
node dist/cli.js. Or link it as testrazor with npm link.
testrazor <command> [flags]
impact select tests affected by a change (git diff or --changed)
flake detect flaky tests from JUnit runs and update the quarantine
gate exit non-zero on a real, non-quarantined failure
report print a combined impact + flake report, no side effects
init scaffold testrazor.config.json and a runnable example
Flags: --report <file> (JUnit XML, repeatable), --changed <file>
(repeatable, skips git), --base <ref> and --head <ref> (git range),
--root <dir> (import-graph root), --quarantine <file>, --config <file>,
--json, --markdown. CLI flags override the config file, which overrides the
defaults.
testrazor init writes a config and a runnable example under .testrazor/ so
you can try flake immediately.
- uses: zkasuran/testrazor@v1
with:
args: gate --report reports/junit.xml --quarantine .testrazor/quarantine.json
comment: "true" # upsert one PR comment with the reportThe action builds testrazor, runs the CLI with your args, writes the report to
the job summary and (on a pull request) posts or updates a single PR comment
keyed by a hidden marker. It exits with the CLI's own exit code, so gate fails
the job on a real failure. This repo dogfoods it in .github/workflows/ci.yml.
testrazor.config.json at the repo root:
{
"root": "src",
"base": "origin/main",
"quarantine": ".testrazor/quarantine.json",
"reports": ["reports/junit.xml"],
"testPattern": "\\.(test|spec)\\.[cm]?[jt]sx?$"
}testrazor was built with Kiro's spec-driven workflow and the artifacts are
committed under .kiro/ so you can see the process, not just the result:
- Specs (
.kiro/specs/testrazor/):requirements.mdstates the behavior as EARS acceptance criteria,design.mdfixes the architecture andtasks.mdis the implementation plan. Every module maps back to a numbered requirement. - Steering (
.kiro/steering/):product.md,tech.mdandstructure.mdkept every generated file consistent (one runtime dependency, pure engines, the honest-scope rule) without repeating it in each prompt. - Hooks (
.kiro/hooks/): one command hook runs typecheck and tests on every source save, one agent hook checks that each test still maps to an acceptance criterion.
The design changed mid-build through the spec: an early draft used coverage reports for impact, but standard coverage is aggregated per run and cannot say which test touched which line, so the spec and the code moved to a source import graph. That revision is visible in the spec history.
Every test name carries a @covers <requirement>.<criterion> tag, so the suite
is a live traceability matrix over the requirements.
- Flake and gate work for any language that emits JUnit XML (jest, vitest, pytest, mocha, go test through a converter).
- Impact is supported for JavaScript and TypeScript, by resolving
relative
import,export ... from,requireand dynamicimport()specifiers (including.jsspecifiers that resolve to.tssources).
None. testrazor makes no network calls, needs no API key or account and reads
only local files. The GitHub Action's optional PR comment uses the workflow's
own GITHUB_TOKEN, subject to normal GitHub API limits.
npm ci
npm run typecheck # strict TypeScript, no errors
npm test # 27 vitest cases, all green, emits reports/junit.xml
npm run build # compiles to dist/Then run the three sample commands in Quick start above. No test credentials are required, because nothing authenticates.
To see testrazor judge itself, run the suite twice and flake-check the output:
npx vitest run --reporter=junit --outputFile=reports/run1.xml
npx vitest run --reporter=junit --outputFile=reports/run2.xml
node dist/cli.js flake --report reports/run1.xml --report reports/run2.xml \
--quarantine .testrazor/quarantine.jsonPure parsers turn a git diff and JUnit XML into normalized data. A source
walker builds the import graph. Two pure engines compute impact (test files that
transitively import a changed file) and flake (per-test pass/fail variance across
runs). A reporter renders a table, JSON or a Markdown PR comment and the gate
reduces it all to an exit code. The engines do no IO, so they are deterministic
and fully unit tested. See .kiro/specs/testrazor/design.md.
Depends on fast-xml-parser
(MIT) for JUnit parsing. Everything else uses the Node standard library.
MIT. See LICENSE.