npx skills add https://github.com/a2f0/tearleads --skill preen-test-flakiness通过移除非确定性等待、稳定异步行为以及强化断言,主动减少不稳定的测试,确保重复运行产生相同结果。
在以下情况运行此技能:
preen-test-flakiness首先关注确定性的反模式:
# 基于时间的等待模式
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'setTimeout\(|waitForTimeout\(|sleep\(' packages . | head -40 || true
# 显式的不稳定性标记 / 重试
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'retry|retries|flaky|TODO.*flaky|FIXME.*flaky' packages . | head -40 || true
# 测试中使用的非确定性来源
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'Math\.random|Date\.now|new Date\(|performance\.now' packages . | head -40 || true
# 快照过度使用的热点
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'toMatchSnapshot\(' packages . | head -30 || true
sleep 和固定的 setTimeout 等待是主要的不稳定性来源。Proactively reduce flaky tests by removing nondeterministic waits, stabilizing async behavior, and tightening assertions so repeated runs produce the same result.
Run this skill when:
preen-test-flakinessFocus on deterministic anti-patterns first:
# Time-based waiting patterns
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'setTimeout\(|waitForTimeout\(|sleep\(' packages . | head -40 || true
# Explicit flake markers / retries
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'retry|retries|flaky|TODO.*flaky|FIXME.*flaky' packages . | head -40 || true
# Non-deterministic sources used in tests
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'Math\.random|Date\.now|new Date\(|performance\.now' packages . | head -40 || true
# Snapshot overuse hotspots
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'toMatchSnapshot\(' packages . | head -30 || true
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
await、孤立的 promise 以及延迟的断言会导致非确定性。按此顺序修复:
// 之前
await new Promise((resolve) => setTimeout(resolve, 1000));
expect(await screen.findByText('Ready')).toBeVisible();
// 之后
await waitFor(() => {
expect(screen.getByText('Ready')).toBeVisible();
});
vi.useFakeTimers();
vi.setSystemTime(new Date('2026-01-01T00:00:00Z'));
git checkout -b test/flake-<area>/commit-and-push,然后运行 /enter-merge-queue。如果未找到高价值的修复,请不要创建分支。
尽可能多次运行目标测试套件:
pnpm exec tsx scripts/ciImpact/runImpactedTests.ts >/dev/null
pnpm exec tsx scripts/ciImpact/runImpactedQuality.ts >/dev/null
对于可疑的测试套件,使用最可靠的最小命令直接循环重新运行。
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'setTimeout\(|waitForTimeout\(|sleep\(' packages . | head -40 || true
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'retry|retries|flaky|TODO.*flaky|FIXME.*flaky' packages . | head -40 || true
pnpm exec tsx scripts/ciImpact/runImpactedTests.ts >/dev/null
pnpm exec tsx scripts/ciImpact/runImpactedQuality.ts >/dev/null
git commit -S -m "message" >/dev/null
git push >/dev/null
如果失败,请在没有抑制输出的情况下重新运行失败的命令。
每周安装次数
1
代码仓库
首次出现
1 天前
安全审计
安装于
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
sleep and fixed setTimeout waits are primary flake sources.await, orphaned promises, and late assertions create nondeterminism.Fix in this order:
// Before
await new Promise((resolve) => setTimeout(resolve, 1000));
expect(await screen.findByText('Ready')).toBeVisible();
// After
await waitFor(() => {
expect(screen.getByText('Ready')).toBeVisible();
});
vi.useFakeTimers();
vi.setSystemTime(new Date('2026-01-01T00:00:00Z'));
git checkout -b test/flake-<area>/commit-and-push, then /enter-merge-queue.If no high-value fix is found, do not create a branch.
Run targeted suites multiple times when possible:
pnpm exec tsx scripts/ciImpact/runImpactedTests.ts >/dev/null
pnpm exec tsx scripts/ciImpact/runImpactedQuality.ts >/dev/null
For suspicious suites, rerun directly in a loop with the smallest reliable command.
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'setTimeout\(|waitForTimeout\(|sleep\(' packages . | head -40 || true
rg -n --glob '**/*.{test,spec}.{ts,tsx}' 'retry|retries|flaky|TODO.*flaky|FIXME.*flaky' packages . | head -40 || true
pnpm exec tsx scripts/ciImpact/runImpactedTests.ts >/dev/null
pnpm exec tsx scripts/ciImpact/runImpactedQuality.ts >/dev/null
git commit -S -m "message" >/dev/null
git push >/dev/null
On failure, rerun the failing command without suppression.
Weekly Installs
1
Repository
First Seen
1 day ago
Security Audits
Installed on
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
31,600 周安装