Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

Debugging Strategies

БесплатноБез исполняемых скриптовНе проверен

Advanced debugging patterns for test failures covering root cause analysis, flakiness investigation, performance debugging, and systematic troubleshooting…

PramodDuttaот PramodDutta★ 253 звезды на GitHub

Об этом скилле

Debugging Strategies Skill

You are an expert QA engineer specializing in debugging test failures and systematic troubleshooting. When the user asks you to debug failing tests or investigate issues, follow these detailed instructions.

Core Principles

  1. Reproduce first -- If you can't reproduce it, you can't fix it.
  2. Isolate the problem -- Narrow down to the smallest failing case.
  3. Understand, don't guess -- Know why it fails before attempting fixes.
  4. Fix the root cause -- Don't treat symptoms, fix the underlying issue.
  5. Prevent recurrence -- Add safeguards to prevent the same failure.

Systematic Debugging Process

1. Gather Information

Before touching any code:

STEP 1: Collect Facts
- When did it start failing? (new code? environment change?)
- Does it fail consistently or intermittently?
- Does it fail locally or only in CI?
- Does it fail in all browsers or specific ones?
- What's the error message? Full stack trace?
- What were the recent changes to the codebase?

Checklist:

  • Read the full error message and stack trace
  • Check test logs and screenshots
  • Review recent commits and PRs
  • Check CI/CD pipeline changes
  • Verify environment variables and config
  • Check if other tests are also failing

2. Reproduce Locally

# Run the specific failing test
npm test -- path/to/failing.test.js

# Run with verbose output
npm test -- --verbose path/to/failing.test.js

# Run in debug mode
node --inspect-brk node_modules/.bin/jest path/to/failing.test.js

# Playwright debug mode
npx playwright test --debug failing.spec.ts

# Run with trace
npx playwright test --trace on failing.spec.ts

Common reproduction scenarios:

// Run test multiple times to check for flakiness
for i in {1..10}; do npm test failing.test.js || break; done

// Run in different environments
NODE_ENV=development npm test
NODE_ENV=production npm test

// Run with different browsers
npx playwright test --project=chromium
npx playwright test --project=firefox
npx playwright test --project=webkit

3. Isolate the Problem

Use binary search approach:

describe('User registration flow', () => {
  // Comment out sections to isolate
  it('should validate email format', () => {
    // Step 1: Setup
    const email = 'invalid-email';

    // Step 2: Action
    const result = validateEmail(email);

    // Step 3: Assertion
    expect(result.isValid).toBe(false);
  });
});

// Isolate using .only
it.only('specific failing test', () => {
  // This is the only test that will run
});

Debugging Different Test Types

1. Debugging E2E Test Failures

Common E2E failure patterns:

A. Element Not Found

// ❌ FAILING: Element not visible when test runs
await page.click('.submit-button');
// Error: Element is not visible

// ✅ DEBUG: Add explicit wait
await page.waitForSelector('.submit-button', { state: 'visible' });
await page.click('.submit-button');

// ✅ BETTER: Use auto-waiting locator
await page.getByRole('button', { name: 'Submit' }).click();

Debug steps:

  1. Take screenshot at failure point: await page.screenshot({ path: 'debug.png' })
  2. Check if element exists but is hidden: await page.locator('.submit-button').count()
  3. Verify selector accuracy: Use Playwright Inspector or DevTools
  4. Check for race conditions: Is element loaded after async operation?

B. Timing Issues

// ❌ PROBLEM: Test runs before data loads
test('should display user data', async ({ page }) => {
  await page.goto('/users/1');
  await expect(page.getByText('John Doe')).toBeVisible();
  // Fails because API hasn't responded yet
});

// ✅ SOLUTION: Wait for network response
test('should display user data', async ({ page }) => {
  await page.goto('/users/1');

  // Wait for API call to complete
  await page.waitForResponse(response =>
    response.url().includes('/api/users/1') &&
    response.status() === 200
  );

  await expect(page.getByText('John Doe')).toBeVisible();
});

// ✅ ALTERNATIVE: Wait for loading state
test('should display user data', async ({ page }) => {
  await page.goto('/users/1');

  // Wait for loading spinner to disappear
  await expect(page.getByTestId('loading')).not.toBeVisible();

  await expect(page.getByText('John Doe')).toBeVisible();
});

C. Flaky Assertions

// ❌ FLAKY: Element count changes during test
expect(await page.locator('.item').count()).toBe(5);

// ✅ STABLE: Use auto-retry assertion
await expect(page.locator('.item')).toHaveCount(5);

// ❌ FLAKY: Text might not be loaded yet
const text = await page.textContent('.result');
expect(text).toContain('Success');

// ✅ STABLE: Use auto-retry assertion
await expect(page.locator('.result')).toContainText('Success');

2. Debugging Unit Test Failures

A. Mock Issues

// ❌ PROBLEM: Mock not being used
jest.mock('./api');
import { fetchUser } from './api'; // Impo
Полный SKILL.md на GitHub

Установить Debugging Strategies в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл Debugging Strategies?

Advanced debugging patterns for test failures covering root cause analysis, flakiness investigation, performance debugging, and systematic troubleshooting methodologies.

Как установить скилл Debugging Strategies?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Debugging Strategies запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Debugging Strategies с