一键导入
flaky-tests
Identify flaky tests by running tests multiple times and analyzing intermittent failures. Use when investigating test reliability.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Identify flaky tests by running tests multiple times and analyzing intermittent failures. Use when investigating test reliability.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Run a comprehensive review of the Queuert library before publishing, launching 10 parallel agents to check documentation coherence, API design, implementation verification, feature completeness, API consistency, schema design, code style, benchmarks, changeset coverage, and OTEL semantic conventions. Use when preparing to publish or validating publish readiness.
Run a comprehensive code review of local changes, analyzing staged and unstaged changes to provide insights, identify issues, and suggest alternative approaches. Use when reviewing code before committing or creating pull requests.
Create a release for the Queuert monorepo. Guides through changeset creation, version bumping, committing, merging dev to main, tagging, and creating a GitHub prerelease.
Check if documentation is up to date with code changes. Analyzes git changes and identifies documentation that may need updating, comparing code modifications against reference docs and package READMEs.
Generate a conventional commit message from staged changes. Analyzes changes to determine affected packages and appropriate commit type, then outputs a properly formatted commit message.
| name | flaky-tests |
| description | Identify flaky tests by running tests multiple times and analyzing intermittent failures. Use when investigating test reliability. |
| argument-hint | [runs] [--filter=pattern] |
| disable-model-invocation | true |
| allowed-tools | Bash(pnpm *), Bash(mkdir *), Bash(grep *), Bash(cat *) |
Run the test suite multiple times sequentially and identify tests that exhibit intermittent behavior (sometimes pass, sometimes fail). This helps identify unreliable tests that may cause CI failures.
Parse $ARGUMENTS as follows:
--filter, -t)Examples:
/flaky-tests → 10 runs with pnpm test --run/flaky-tests 5 → 5 runs/flaky-tests 20 --filter=worker → 20 runs with filterCreate a scratchpad directory for temporary log files:
SCRATCHPAD="$TMPDIR/flaky-tests-$(date +%s)"
mkdir -p "$SCRATCHPAD"
IMPORTANT: Tests MUST be run sequentially (one at a time), NOT in parallel. Running tests in parallel can cause resource contention that creates false flakiness signals.
For each run (1 to N):
pnpm test --run with any additional arguments$SCRATCHPAD/test-run-$i.logUse a single bash command with a for loop:
for i in {1..N}; do
echo "=== Test Run $i ==="
pnpm test --run [extra args] 2>&1 | tee "$SCRATCHPAD/test-run-$i.log"
if [ ${PIPESTATUS[0]} -eq 0 ]; then
echo "Run $i: PASSED"
else
echo "Run $i: FAILED"
fi
done
For each run, extract from the log files:
Look for patterns in vitest output:
✓ or √ = passed× or ✗ = failed↓ = skippedFAIL prefix in summary = failed test file with suite pathCategorize tests by reliability:
| Category | Definition |
|---|---|
| Flaky | Failed in some runs but passed in others (0 < failures < total runs) |
| Consistently Failing | Failed in ALL runs |
| Consistently Passing | Passed in ALL runs |
| Slow | Tests taking >1000ms that may be prone to timeouts |
For flaky tests, calculate:
Provide a structured report with all flaky tests, their failure rates, and any observable patterns.
# Flaky Test Report
## Summary
- **Total Runs**: X
- **Runs Passed**: Y (Z%)
- **Runs Failed**: W (V%)
- **Flaky Tests Found**: N
## Flaky Tests
Tests that passed in some runs but failed in others:
| Test | Failures | Rate | Package |
| ----------------- | -------- | ---- | ------------ |
| Suite > test name | X/Y | Z% | package-name |
### Detailed Analysis
#### [Test Name]
- **File**: path/to/test.spec.ts
- **Failure Rate**: X/Y runs (Z%)
- **Failed in Runs**: 2, 5, 8
- **Error Pattern**: [timeout | assertion | exception]
- **Sample Error**:
[First error message encountered]
## Consistently Failing Tests
Tests that failed in ALL runs (not flaky, just broken):
| Test | Package | Error Type |
|------|---------|------------|
| Suite > test name | package-name | timeout/assertion |
## Slow Tests (Potential Timeout Risk)
Tests taking >1000ms that may be prone to flakiness:
| Test | Avg Duration | Package |
|------|--------------|---------|
| Suite > test name | Xms | package-name |
## Run-by-Run Summary
| Run | Status | Failed Tests |
|-----|--------|--------------|
| 1 | PASS | - |
| 2 | FAIL | test-a, test-b |
| ... | ... | ... |
## Recommendations
[Suggestions for addressing the flakiness, such as:]
- Tests with timeout errors: Consider increasing timeout or optimizing
- Tests with ordering issues: May have race conditions
- Tests with assertion errors: May depend on execution order or shared state
After identifying flaky tests, investigate these common causes: