test-fixing

通过分析错误、更新断言和重构测试代码来自动诊断和修复失败的测试

📖 中文导读:通过分析错误、更新断言和重构测试代码来自动诊断和修复失败的测试 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: test-fixing description: Automatically diagnose and fix failing tests by analyzing errors, updating assertions, and refactoring test code

Test Fixing Skill

Diagnose and fix failing tests automatically using error analysis and intelligent refactoring.

When to Use

  • Failing test suite
  • Flaky tests
  • Test maintenance
  • CI/CD pipeline failures

Core Capabilities

  • Error analysis and root cause identification
  • Assertion updates
  • Mock/stub fixing
  • Timeout adjustments
  • Race condition detection
  • Test data refresh
  • Dependency updates

Common Fixes

// Fix 1: Update assertion
- expect(result).toBe(5);
+ expect(result).toBe(6); // Updated expected value

// Fix 2: Add async/await
- it('should fetch data', () => {
-   const data = fetchData();
+ it('should fetch data', async () => {
+   const data = await fetchData();

// Fix 3: Fix mock
- jest.mock('./api');
+ jest.mock('./api', () => ({
+   fetchUser: jest.fn().mockResolvedValue({ id: 1 })
+ }));

// Fix 4: Increase timeout
- it('slow test', () => {
+ it('slow test', () => {
+   jest.setTimeout(10000);

Best Practices

  • Analyze error messages first
  • Check for environmental issues
  • Update test data regularly
  • Fix flaky tests immediately
  • Run tests in isolation

Resources