mcpField
T
test-failure-investigator

test-failure-investigator

github.com/proffesor-for-testingTesting & quality51965 installsUpdated today
Repository

About test-failure-investigator

A runbook-style skill for investigating failing tests, aimed at developers and testing agents. It reproduces failures, classifies them, narrows likely causes, and structures findings into a report.

Key features

  1. 01Classifies failures as regression, flaky, environment, or transient
  2. 02Reproduces tests across repeated runs
  3. 03Investigates changes and likely root causes
  4. 04Produces a structured failure report
  5. 05Suggests follow-up testing skills

Use cases

  1. 01Diagnosing a newly failing test
  2. 02Checking whether a failure is intermittent
  3. 03Tracing a regression to recent code changes

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/proffesor-for-testing/agentic-qe --skill test-failure-investigator

After installing, type/test-failure-investigatorin Claude Code to confirm it loaded.

Details

From the project README

Test Failure Investigator

Runbook-style skill for systematic test failure investigation. Given a failing test, determines root cause and recommends action.

Activation

/test-failure-investigator [test-name-or-file]

Investigation Flow

Step 1: Classify the Failure

Run the test 3 times and classify:

Result PatternClassificationAction
Fails consistentlyRegression or EnvironmentContinue to Step 2
Fails intermittentlyFlakySkip to Step 4
Passes nowTransientCheck CI logs, environment diff
# Run test 3 times
for i in 1 2 3; do npx jest {{test_file}} 2>&1 | tail -5; echo "--- Run $i ---"; done
Step 2: Narrow the Scope
# When did it start failing?
git log --oneline -20 -- {{related_source_files}}

# What changed recently?
git diff HEAD~5 -- {{related_source_files}}

# Does it fail in isolation?
npx jest {{test_file}} --testNamePattern="{{test_name}}"

# Does it fail with other tests?
npx jest --runInBand  # sequential execution
Step 3: Root Cause Analysis
SymptomLikely CauseInvestigation
TimeoutNetwork/DB dependencyCheck external service availability
Assertion mismatchLogic changeCompare expected vs actual, check git blame
Import errorDependency changeCheck package.json changes, run npm ci
Permission deniedEnvironmentCheck file permissions, Docker volumes
Out of memoryResource leakProfile with --detectOpenHandles
Step 4: Flaky Test Investigation
# Run 10 times to confirm flakiness
for i in $(seq 1 10); do npx jest {{test_file}} --forceExit 2>&1 | grep -E 'PASS|FAIL'; done

# Common flaky causes:
# - Shared state between tests (missing cleanup)
# - Time-dependent assertions (use fake timers)
# - Race conditions (missing await)
# - Port conflicts (use random ports)
# - Order dependency (run with --randomize)
Step 5: Report
## Test Failure Report
- **Test**: {{test_name}}
- **File**: {{test_file}}
- **Classification**: Regression / Flaky / Environment / Transient
- **Root Cause**: {{description}}
- **First Failed**: {{commit_hash}} ({{date}})
- **Fix**: {{recommended_action}}
- **Verified**: [ ] Fix applied and test passes 3x consecutively

Composition

After investigation, compose with:

  • /bug-reporting-excellence — if regression found, file a bug report
  • /regression-testing — if regression, add to regression suite
  • /qe-test-execution — for re-running tests after fix

Gotchas

  • Agent may guess at root cause without running the test — always reproduce first
  • "Works on my machine" is not a diagnosis — compare environments (node version, OS, deps)
  • Flaky tests that pass 9/10 times will still be reported as "passing" by CI — run 10+ times
  • Test isolation failures are the #1 cause of flaky tests — check for shared state in beforeAll/afterAll

Comments

Markdown supported