[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D8DNHMWQ073053D5FGHP3R":3,"skill-same:01M7D8DNHMWQ073053D5FGHP3R":82},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":60,"commitSha":61,"skillDirectory":62,"forksCount":14,"repositoryHtmlUrl":63,"repositoryHomepageUrl":6,"ownerHtmlUrl":64,"ownerBlogUrl":65,"ownerDescription":66,"updatedAt":67,"install":68,"resources":81},"01M7D8DNHMWQ073053D5FGHP3R","Debugging Strategies",null,"Advanced debugging patterns for test failures covering root cause analysis, flakiness investigation, performance debugging, and systematic troubleshooting methodologies.","GrupoANDevelopment-m\u002Falberto-ai","GrupoANDevelopment-m","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F257455179?v=4","01M7D69X2N2KEVN0SJF6WGM6SH","Antônio  Ndombe","01M7D69X3P5JTT8H8S904N3888",0,"MIT","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Fdebugging-strategies\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: Debugging Strategies\ndescription: Advanced debugging patterns for test failures covering root cause analysis, flakiness investigation, performance debugging, and systematic troubleshooting methodologies.\nversion: 1.0.0\nauthor: thetestingacademy\nlicense: MIT\ntags: [debugging, troubleshooting, test-failures, flakiness, root-cause-analysis, performance-debugging]\ntestingTypes: [e2e, unit, integration]\nframeworks: [playwright, cypress, jest, pytest]\nlanguages: [typescript, javascript, python]\ndomains: [web, api]\nagents: [claude-code, cursor, github-copilot, windsurf, codex, aider, continue, cline, zed, bolt]\n---\n\n# Debugging Strategies Skill\n\nYou 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.\n\n## Core Principles\n\n1. **Reproduce first** -- If you can't reproduce it, you can't fix it.\n2. **Isolate the problem** -- Narrow down to the smallest failing case.\n3. **Understand, don't guess** -- Know why it fails before attempting fixes.\n4. **Fix the root cause** -- Don't treat symptoms, fix the underlying issue.\n5. **Prevent recurrence** -- Add safeguards to prevent the same failure.\n\n## Systematic Debugging Process\n\n### 1. Gather Information\n\nBefore touching any code:\n\n```\nSTEP 1: Collect Facts\n- When did it start failing? (new code? environment change?)\n- Does it fail consistently or intermittently?\n- Does it fail locally or only in CI?\n- Does it fail in all browsers or specific ones?\n- What's the error message? Full stack trace?\n- What were the recent changes to the codebase?\n```\n\n**Checklist:**\n- [ ] Read the full error message and stack trace\n- [ ] Check test logs and screenshots\n- [ ] Review recent commits and PRs\n- [ ] Check CI\u002FCD pipeline changes\n- [ ] Verify environment variables and config\n- [ ] Check if other tests are also failing\n\n### 2. Reproduce Locally\n\n```bash\n# Run the specific failing test\nnpm test -- path\u002Fto\u002Ffailing.test.js\n\n# Run with verbose output\nnpm test -- --verbose path\u002Fto\u002Ffailing.test.js\n\n# Run in debug mode\nnode --inspect-brk node_modules\u002F.bin\u002Fjest path\u002Fto\u002Ffailing.test.js\n\n# Playwright debug mode\nnpx playwright test --debug failing.spec.ts\n\n# Run with trace\nnpx playwright test --trace on failing.spec.ts\n```\n\n**Common reproduction scenarios:**\n\n```javascript\n\u002F\u002F Run test multiple times to check for flakiness\nfor i in {1..10}; do npm test failing.test.js || break; done\n\n\u002F\u002F Run in different environments\nNODE_ENV=development npm test\nNODE_ENV=production npm test\n\n\u002F\u002F Run with different browsers\nnpx playwright test --project=chromium\nnpx playwright test --project=firefox\nnpx playwright test --project=webkit\n```\n\n### 3. Isolate the Problem\n\nUse binary search approach:\n\n```javascript\ndescribe('User registration flow', () => {\n  \u002F\u002F Comment out sections to isolate\n  it('should validate email format', () => {\n    \u002F\u002F Step 1: Setup\n    const email = 'invalid-email';\n\n    \u002F\u002F Step 2: Action\n    const result = validateEmail(email);\n\n    \u002F\u002F Step 3: Assertion\n    expect(result.isValid).toBe(false);\n  });\n});\n\n\u002F\u002F Isolate using .only\nit.only('specific failing test', () => {\n  \u002F\u002F This is the only test that will run\n});\n```\n\n## Debugging Different Test Types\n\n### 1. Debugging E2E Test Failures\n\n**Common E2E failure patterns:**\n\n#### A. Element Not Found\n\n```javascript\n\u002F\u002F ❌ FAILING: Element not visible when test runs\nawait page.click('.submit-button');\n\u002F\u002F Error: Element is not visible\n\n\u002F\u002F ✅ DEBUG: Add explicit wait\nawait page.waitForSelector('.submit-button', { state: 'visible' });\nawait page.click('.submit-button');\n\n\u002F\u002F ✅ BETTER: Use auto-waiting locator\nawait page.getByRole('button', { name: 'Submit' }).click();\n```\n\n**Debug steps:**\n1. Take screenshot at failure point: `await page.screenshot({ path: 'debug.png' })`\n2. Check if element exists but is hidden: `await page.locator('.submit-button').count()`\n3. Verify selector accuracy: Use Playwright Inspector or DevTools\n4. Check for race conditions: Is element loaded after async operation?\n\n#### B. Timing Issues\n\n```javascript\n\u002F\u002F ❌ PROBLEM: Test runs before data loads\ntest('should display user data', async ({ page }) => {\n  await page.goto('\u002Fusers\u002F1');\n  await expect(page.getByText('John Doe')).toBeVisible();\n  \u002F\u002F Fails because API hasn't responded yet\n});\n\n\u002F\u002F ✅ SOLUTION: Wait for network response\ntest('should display user data', async ({ page }) => {\n  await page.goto('\u002Fusers\u002F1');\n\n  \u002F\u002F Wait for API call to complete\n  await page.waitForResponse(response =>\n    response.url().includes('\u002Fapi\u002Fusers\u002F1') &&\n    response.status() === 200\n  );\n\n  await expect(page.getByText('John Doe')).toBeVisible();\n});\n\n\u002F\u002F ✅ ALTERNATIVE: Wait for loading state\ntest('should display user data', async ({ page }) => {\n  await page.goto('\u002Fusers\u002F1');\n\n  \u002F\u002F Wait for loading spinner to disappear\n  await expect(page.getByTestId('loading')).not.toBeVisible();\n\n  await expect(page.getByText('John Doe')).toBeVisible();\n});\n```\n\n#### C. Flaky Assertions\n\n```javascript\n\u002F\u002F ❌ FLAKY: Element count changes during test\nexpect(await page.locator('.item').count()).toBe(5);\n\n\u002F\u002F ✅ STABLE: Use auto-retry assertion\nawait expect(page.locator('.item')).toHaveCount(5);\n\n\u002F\u002F ❌ FLAKY: Text might not be loaded yet\nconst text = await page.textContent('.result');\nexpect(text).toContain('Success');\n\n\u002F\u002F ✅ STABLE: Use auto-retry assertion\nawait expect(page.locator('.result')).toContainText('Success');\n```\n\n### 2. Debugging Unit Test Failures\n\n#### A. Mock Issues\n\n```javascript\n\u002F\u002F ❌ PROBLEM: Mock not being used\njest.mock('.\u002Fapi');\nimport { fetchUser } from '.\u002Fapi'; \u002F\u002F Import AFTER mock\n\n\u002F\u002F ✅ SOLUTION: Import after mock\njest.mock('.\u002Fapi');\nimport { fetchUser } from '.\u002Fapi';\n\ntest('should use mocked function', async () => {\n  fetchUser.mockResolvedValue({ id: 1, name: 'Test' });\n  const user = await fetchUser('1');\n  expect(user.name).toBe('Test');\n});\n```\n\n**Debug mock issues:**\n\n```javascript\n\u002F\u002F Check if mock is being called\nconst mockFn = jest.fn();\n\u002F\u002F ... test code ...\nconsole.log('Mock called:', mockFn.mock.calls);\nconsole.log('Mock call count:', mockFn.mock.calls.length);\nconsole.log('Mock results:', mockFn.mock.results);\n\n\u002F\u002F Verify mock implementation\ntest('debug mock', () => {\n  const mockFn = jest.fn((x) => x * 2);\n  console.log('Mock implementation:', mockFn.getMockImplementation());\n\n  const result = mockFn(5);\n  console.log('Result:', result); \u002F\u002F Should be 10\n});\n```\n\n#### B. Async Issues\n\n```javascript\n\u002F\u002F ❌ PROBLEM: Test completes before async operation\ntest('should fetch data', () => {\n  fetchData().then(data => {\n    expect(data.id).toBe(1); \u002F\u002F This assertion never runs!\n  });\n});\n\n\u002F\u002F ✅ SOLUTION 1: Return the promise\ntest('should fetch data', () => {\n  return fetchData().then(data => {\n    expect(data.id).toBe(1);\n  });\n});\n\n\u002F\u002F ✅ SOLUTION 2: Use async\u002Fawait\ntest('should fetch data', async () => {\n  const data = await fetchData();\n  expect(data.id).toBe(1);\n});\n\n\u002F\u002F ✅ SOLUTION 3: Use resolves\ntest('should fetch data', async () => {\n  await expect(fetchData()).resolves.toMatchObject({ id: 1 });\n});\n```\n\n### 3. Debugging Integration Test Failures\n\n#### A. Database State Issues\n\n```javascript\n\u002F\u002F ❌ PROBLEM: Tests affect each other\ntest('test 1', async () => {\n  await db.users.create({ email: 'test@example.com' });\n  \u002F\u002F ... assertions\n});\n\ntest('test 2', async () => {\n  await db.users.create({ email: 'test@example.com' });\n  \u002F\u002F Fails: duplicate email!\n});\n\n\u002F\u002F ✅ SOLUTION: Clean up after each test\nbeforeEach(async () => {\n  await db.users.deleteMany({});\n});\n\n\u002F\u002F ✅ ALTERNATIVE: Use unique data\ntest('test 1', async () => {\n  await db.users.create({ email: `test-${Date.now()}@example.com` });\n});\n```\n\n#### B. API Test Failures\n\n```javascript\n\u002F\u002F Debug API test failures\ntest('should create user', async () => {\n  \u002F\u002F Log request details\n  console.log('Request body:', requestBody);\n\n  const response = await request.post('\u002Fapi\u002Fusers', requestBody);\n\n  \u002F\u002F Log response for debugging\n  console.log('Response status:', response.status);\n  console.log('Response body:', response.body);\n  console.log('Response headers:', response.headers);\n\n  expect(response.status).toBe(201);\n});\n```\n\n## Root Cause Analysis Framework\n\n### The 5 Whys Technique\n\n```\nTest fails: \"Element not found\"\n\nWhy? The element wasn't rendered\nWhy? The API request failed\nWhy? The API endpoint returned 500\nWhy? The database connection timed out\nWhy? Connection pool was exhausted\nROOT CAUSE: Need to implement connection pooling correctly\n```\n\n### Divide and Conquer\n\n```javascript\n\u002F\u002F Original failing test\ntest('complex user flow', async () => {\n  await createUser();\n  await loginUser();\n  await updateProfile();\n  await uploadAvatar();\n  await logout();\n  \u002F\u002F One of these steps fails - which one?\n});\n\n\u002F\u002F Split into isolated tests\ntest.only('step 1: create user', async () => {\n  await createUser();\n  \u002F\u002F Pass ✓\n});\n\ntest.only('step 2: login user', async () => {\n  await createUser();\n  await loginUser();\n  \u002F\u002F Pass ✓\n});\n\ntest.only('step 3: update profile', async () => {\n  await createUser();\n  await loginUser();\n  await updateProfile();\n  \u002F\u002F FAIL ✗ - Found it!\n});\n```\n\n## Debugging Tools and Techniques\n\n### 1. Browser DevTools for E2E Tests\n\n```javascript\ntest('debug with browser open', async ({ page }) => {\n  \u002F\u002F Run in headed mode: npx playwright test --headed\n  \u002F\u002F Run with debug: npx playwright test --debug\n\n  await page.goto('\u002F');\n\n  \u002F\u002F Pause execution for manual inspection\n  await page.pause();\n\n  \u002F\u002F Open DevTools programmatically\n  await page.evaluate(() => debugger);\n});\n```\n\n### 2. Playwright Trace Viewer\n\n```bash\n# Record trace\nnpx playwright test --trace on\n\n# View trace\nnpx playwright show-trace trace.zip\n\n# Trace shows:\n# - Screenshots at each step\n# - Network requests\n# - Console logs\n# - DOM snapshots\n# - Action timeline\n```\n\n### 3. Custom Logging\n\n```javascript\n\u002F\u002F test-logger.js\nexport class TestLogger {\n  static info(message, data) {\n    console.log(`[INFO] ${message}`, data ? JSON.stringify(data, null, 2) : '');\n  }\n\n  static error(message, error) {\n    console.error(`[ERROR] ${message}`, error);\n  }\n\n  static step(stepName) {\n    console.log(`\\n>>> STEP: ${stepName}`);\n  }\n}\n\n\u002F\u002F Usage in tests\ntest('with logging', async ({ page }) => {\n  TestLogger.step('Navigate to login page');\n  await page.goto('\u002Flogin');\n\n  TestLogger.step('Fill login form');\n  await page.fill('#email', 'user@example.com');\n\n  TestLogger.info('Current URL', page.url());\n\n  TestLogger.step('Submit form');\n  await page.click('button[type=\"submit\"]');\n});\n```\n\n### 4. Video Recording\n\n```typescript\n\u002F\u002F playwright.config.ts\nexport default defineConfig({\n  use: {\n    video: 'retain-on-failure', \u002F\u002F or 'on' for all tests\n    screenshot: 'only-on-failure',\n  },\n});\n\n\u002F\u002F Videos are saved in test-results\u002F folder\n```\n\n## Flakiness Investigation\n\n### Identifying Flaky Tests\n\n```bash\n# Run test 50 times and track failures\nfor i in {1..50}; do\n  npm test failing-test.spec.js >> results.txt 2>&1\n  if [ $? -ne 0 ]; then\n    echo \"Failed on run $i\" >> failures.txt\n  fi\ndone\n\n# Check failure rate\ngrep -c \"Failed\" failures.txt\n```\n\n### Common Flakiness Causes\n\n**1. Race Conditions**\n```javascript\n\u002F\u002F ❌ FLAKY: Clicks too fast\nawait page.click('#submit');\nawait page.click('#confirm'); \u002F\u002F Might not be ready yet\n\n\u002F\u002F ✅ STABLE: Wait for element to be ready\nawait page.click('#submit');\nawait page.waitForSelector('#confirm', { state: 'visible' });\nawait page.click('#confirm');\n```\n\n**2. Animations and Transitions**\n```javascript\n\u002F\u002F ❌ FLAKY: Element moving during click\nawait page.click('.menu-item');\n\n\u002F\u002F ✅ STABLE: Wait for animations\nawait page.click('.menu-item', { force: true }); \u002F\u002F Force click\n\u002F\u002F OR disable animations in test environment\n```\n\n**3. Non-Deterministic Data**\n```javascript\n\u002F\u002F ❌ FLAKY: Timestamp changes between runs\nexpect(result.createdAt).toBe('2024-01-15T10:30:00Z');\n\n\u002F\u002F ✅ STABLE: Test relative to now\nexpect(result.createdAt).toMatch(\u002F^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\u002F);\n\n\u002F\u002F ✅ BETTER: Mock time\njest.useFakeTimers();\njest.setSystemTime(new Date('2024-01-15'));\n```\n\n**4. External Dependencies**\n```javascript\n\u002F\u002F ❌ FLAKY: Depends on real API\nconst data = await fetch('https:\u002F\u002Fapi.example.com\u002Fdata');\n\n\u002F\u002F ✅ STABLE: Mock external calls\njest.mock('node-fetch');\nfetch.mockResolvedValue({ json: () => ({ data: 'mocked' }) });\n```\n\n## Performance Debugging\n\n### Slow Test Diagnosis\n\n```javascript\n\u002F\u002F Measure test execution time\ntest('slow test', async () => {\n  const start = Date.now();\n\n  await performSlowOperation();\n\n  const duration = Date.now() - start;\n  console.log(`Operation took ${duration}ms`);\n\n  if (duration > 5000) {\n    console.warn('⚠️ Slow test detected!');\n  }\n});\n\n\u002F\u002F Use test.slow() to increase timeout\ntest.slow('known slow test', async () => {\n  \u002F\u002F Timeout is 3x normal\n});\n```\n\n### Profiling with Chrome DevTools\n\n```javascript\ntest('profile this test', async ({ page }) => {\n  \u002F\u002F Start profiling\n  await page.evaluate(() => {\n    console.profile('MyTest');\n  });\n\n  \u002F\u002F Run test steps\n  await page.goto('\u002F');\n  await page.click('.button');\n\n  \u002F\u002F Stop profiling\n  await page.evaluate(() => {\n    console.profileEnd('MyTest');\n  });\n});\n```\n\n## Best Practices for Debuggable Tests\n\n1. **Use descriptive test names** -- Know what's being tested at a glance.\n2. **Add comments for complex logic** -- Future you will thank you.\n3. **Log intermediate states** -- Don't just log errors, log success states too.\n4. **Use test.step() in Playwright** -- Organize test actions into logical steps.\n5. **Keep tests focused** -- One test should test one thing.\n6. **Use data-testid attributes** -- Makes debugging selector issues easier.\n7. **Add custom error messages** -- `expect(x).toBe(y, 'User ID should match')`\n8. **Record video on failure** -- Visual context is invaluable.\n9. **Use trace viewer** -- See exactly what happened step by step.\n10. **Fix flaky tests immediately** -- They erode trust in the test suite.\n\n## Anti-Patterns to Avoid\n\n1. **Adding wait timeouts** -- `page.waitForTimeout(5000)` hides the real problem.\n2. **Retrying flaky tests** -- Fix the flakiness, don't mask it.\n3. **Skipping failing tests** -- Fix or delete, don't skip indefinitely.\n4. **Not checking logs** -- Logs often contain the answer.\n5. **Debugging in production** -- Use staging or local environments.\n6. **Changing test assertions** -- If the assertion is correct, fix the code, not the test.\n7. **Not using version control** -- Git bisect is your friend.\n8. **Ignoring warnings** -- Warnings often indicate future failures.\n9. **Not documenting known issues** -- Add comments or tickets for workarounds.\n10. **Debugging alone** -- Pair programming on tough bugs saves time.\n\n## Debugging Checklist\n\nWhen a test fails:\n\n- [ ] Read the full error message\n- [ ] Check screenshots\u002Fvideos if available\n- [ ] Review recent code changes\n- [ ] Reproduce locally\n- [ ] Isolate the failing step\n- [ ] Add debug logging\n- [ ] Check environment variables\n- [ ] Verify test data\n- [ ] Review network requests\n- [ ] Check browser console logs\n- [ ] Run in different browsers\n- [ ] Test in CI environment\n- [ ] Use debugger\u002Fbreakpoints\n- [ ] Check for race conditions\n- [ ] Verify mock setup\n- [ ] Review fixture data\n- [ ] Check database state\n- [ ] Test with different data\n- [ ] Simplify test to minimal case\n- [ ] Ask for help if stuck > 30 min\n\nDebugging is a skill. The more systematic you are, the faster you'll find and fix issues. Document what you learn for future reference.\n","# Debugging Strategies Skill\n\nYou 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.\n\n## Core Principles\n\n1. **Reproduce first** -- If you can't reproduce it, you can't fix it.\n2. **Isolate the problem** -- Narrow down to the smallest failing case.\n3. **Understand, don't guess** -- Know why it fails before attempting fixes.\n4. **Fix the root cause** -- Don't treat symptoms, fix the underlying issue.\n5. **Prevent recurrence** -- Add safeguards to prevent the same failure.\n\n## Systematic Debugging Process\n\n### 1. Gather Information\n\nBefore touching any code:\n\n```\nSTEP 1: Collect Facts\n- When did it start failing? (new code? environment change?)\n- Does it fail consistently or intermittently?\n- Does it fail locally or only in CI?\n- Does it fail in all browsers or specific ones?\n- What's the error message? Full stack trace?\n- What were the recent changes to the codebase?\n```\n\n**Checklist:**\n- [ ] Read the full error message and stack trace\n- [ ] Check test logs and screenshots\n- [ ] Review recent commits and PRs\n- [ ] Check CI\u002FCD pipeline changes\n- [ ] Verify environment variables and config\n- [ ] Check if other tests are also failing\n\n### 2. Reproduce Locally\n\n```bash\n# Run the specific failing test\nnpm test -- path\u002Fto\u002Ffailing.test.js\n\n# Run with verbose output\nnpm test -- --verbose path\u002Fto\u002Ffailing.test.js\n\n# Run in debug mode\nnode --inspect-brk node_modules\u002F.bin\u002Fjest path\u002Fto\u002Ffailing.test.js\n\n# Playwright debug mode\nnpx playwright test --debug failing.spec.ts\n\n# Run with trace\nnpx playwright test --trace on failing.spec.ts\n```\n\n**Common reproduction scenarios:**\n\n```javascript\n\u002F\u002F Run test multiple times to check for flakiness\nfor i in {1..10}; do npm test failing.test.js || break; done\n\n\u002F\u002F Run in different environments\nNODE_ENV=development npm test\nNODE_ENV=production npm test\n\n\u002F\u002F Run with different browsers\nnpx playwright test --project=chromium\nnpx playwright test --project=firefox\nnpx playwright test --project=webkit\n```\n\n### 3. Isolate the Problem\n\nUse binary search approach:\n\n```javascript\ndescribe('User registration flow', () => {\n  \u002F\u002F Comment out sections to isolate\n  it('should validate email format', () => {\n    \u002F\u002F Step 1: Setup\n    const email = 'invalid-email';\n\n    \u002F\u002F Step 2: Action\n    const result = validateEmail(email);\n\n    \u002F\u002F Step 3: Assertion\n    expect(result.isValid).toBe(false);\n  });\n});\n\n\u002F\u002F Isolate using .only\nit.only('specific failing test', () => {\n  \u002F\u002F This is the only test that will run\n});\n```\n\n## Debugging Different Test Types\n\n### 1. Debugging E2E Test Failures\n\n**Common E2E failure patterns:**\n\n#### A. Element Not Found\n\n```javascript\n\u002F\u002F ❌ FAILING: Element not visible when test runs\nawait page.click('.submit-button');\n\u002F\u002F Error: Element is not visible\n\n\u002F\u002F ✅ DEBUG: Add explicit wait\nawait page.waitForSelector('.submit-button', { state: 'visible' });\nawait page.click('.submit-button');\n\n\u002F\u002F ✅ BETTER: Use auto-waiting locator\nawait page.getByRole('button', { name: 'Submit' }).click();\n```\n\n**Debug steps:**\n1. Take screenshot at failure point: `await page.screenshot({ path: 'debug.png' })`\n2. Check if element exists but is hidden: `await page.locator('.submit-button').count()`\n3. Verify selector accuracy: Use Playwright Inspector or DevTools\n4. Check for race conditions: Is element loaded after async operation?\n\n#### B. Timing Issues\n\n```javascript\n\u002F\u002F ❌ PROBLEM: Test runs before data loads\ntest('should display user data', async ({ page }) => {\n  await page.goto('\u002Fusers\u002F1');\n  await expect(page.getByText('John Doe')).toBeVisible();\n  \u002F\u002F Fails because API hasn't responded yet\n});\n\n\u002F\u002F ✅ SOLUTION: Wait for network response\ntest('should display user data', async ({ page }) => {\n  await page.goto('\u002Fusers\u002F1');\n\n  \u002F\u002F Wait for API call to complete\n  await page.waitForResponse(response =>\n    response.url().includes('\u002Fapi\u002Fusers\u002F1') &&\n    response.status() === 200\n  );\n\n  await expect(page.getByText('John Doe')).toBeVisible();\n});\n\n\u002F\u002F ✅ ALTERNATIVE: Wait for loading state\ntest('should display user data', async ({ page }) => {\n  await page.goto('\u002Fusers\u002F1');\n\n  \u002F\u002F Wait for loading spinner to disappear\n  await expect(page.getByTestId('loading')).not.toBeVisible();\n\n  await expect(page.getByText('John Doe')).toBeVisible();\n});\n```\n\n#### C. Flaky Assertions\n\n```javascript\n\u002F\u002F ❌ FLAKY: Element count changes during test\nexpect(await page.locator('.item').count()).toBe(5);\n\n\u002F\u002F ✅ STABLE: Use auto-retry assertion\nawait expect(page.locator('.item')).toHaveCount(5);\n\n\u002F\u002F ❌ FLAKY: Text might not be loaded yet\nconst text = await page.textContent('.result');\nexpect(text).toContain('Success');\n\n\u002F\u002F ✅ STABLE: Use auto-retry assertion\nawait expect(page.locator('.result')).toContainText('Success');\n```\n\n### 2. Debugging Unit Test Failures\n\n#### A. Mock Issues\n\n```javascript\n\u002F\u002F ❌ PROBLEM: Mock not being used\njest.mock('.\u002Fapi');\nimport { fetchUser } from '.\u002Fapi'; \u002F\u002F Import AFTER mock\n\n\u002F\u002F ✅ SOLUTION: Import after mock\njest.mock('.\u002Fapi');\nimport { fetchUser } from '.\u002Fapi';\n\ntest('should use mocked function', async () => {\n  fetchUser.mockResolvedValue({ id: 1, name: 'Test' });\n  const user = await fetchUser('1');\n  expect(user.name).toBe('Test');\n});\n```\n\n**Debug mock issues:**\n\n```javascript\n\u002F\u002F Check if mock is being called\nconst mockFn = jest.fn();\n\u002F\u002F ... test code ...\nconsole.log('Mock called:', mockFn.mock.calls);\nconsole.log('Mock call count:', mockFn.mock.calls.length);\nconsole.log('Mock results:', mockFn.mock.results);\n\n\u002F\u002F Verify mock implementation\ntest('debug mock', () => {\n  const mockFn = jest.fn((x) => x * 2);\n  console.log('Mock implementation:', mockFn.getMockImplementation());\n\n  const result = mockFn(5);\n  console.log('Result:', result); \u002F\u002F Should be 10\n});\n```\n\n#### B. Async Issues\n\n```javascript\n\u002F\u002F ❌ PROBLEM: Test completes before async operation\ntest('should fetch data', () => {\n  fetchData().then(data => {\n    expect(data.id).toBe(1); \u002F\u002F This assertion never runs!\n  });\n});\n\n\u002F\u002F ✅ SOLUTION 1: Return the promise\ntest('should fetch data', () => {\n  return fetchData().then(data => {\n    expect(data.id).toBe(1);\n  });\n});\n\n\u002F\u002F ✅ SOLUTION 2: Use async\u002Fawait\ntest('should fetch data', async () => {\n  const data = await fetchData();\n  expect(data.id).toBe(1);\n});\n\n\u002F\u002F ✅ SOLUTION 3: Use resolves\ntest('should fetch data', async () => {\n  await expect(fetchData()).resolves.toMatchObject({ id: 1 });\n});\n```\n\n### 3. Debugging Integration Test Failures\n\n#### A. Database State Issues\n\n```javascript\n\u002F\u002F ❌ PROBLEM: Tests affect each other\ntest('test 1', async () => {\n  await db.users.create({ email: 'test@example.com' });\n  \u002F\u002F ... assertions\n});\n\ntest('test 2', async () => {\n  await db.users.create({ email: 'test@example.com' });\n  \u002F\u002F Fails: duplicate email!\n});\n\n\u002F\u002F ✅ SOLUTION: Clean up after each test\nbeforeEach(async () => {\n  await db.users.deleteMany({});\n});\n\n\u002F\u002F ✅ ALTERNATIVE: Use unique data\ntest('test 1', async () => {\n  await db.users.create({ email: `test-${Date.now()}@example.com` });\n});\n```\n\n#### B. API Test Failures\n\n```javascript\n\u002F\u002F Debug API test failures\ntest('should create user', async () => {\n  \u002F\u002F Log request details\n  console.log('Request body:', requestBody);\n\n  const response = await request.post('\u002Fapi\u002Fusers', requestBody);\n\n  \u002F\u002F Log response for debugging\n  console.log('Response status:', response.status);\n  console.log('Response body:', response.body);\n  console.log('Response headers:', response.headers);\n\n  expect(response.status).toBe(201);\n});\n```\n\n## Root Cause Analysis Framework\n\n### The 5 Whys Technique\n\n```\nTest fails: \"Element not found\"\n\nWhy? The element wasn't rendered\nWhy? The API request failed\nWhy? The API endpoint returned 500\nWhy? The database connection timed out\nWhy? Connection pool was exhausted\nROOT CAUSE: Need to implement connection pooling correctly\n```\n\n### Divide and Conquer\n\n```javascript\n\u002F\u002F Original failing test\ntest('complex user flow', async () => {\n  await createUser();\n  await loginUser();\n  await updateProfile();\n  await uploadAvatar();\n  await logout();\n  \u002F\u002F One of these steps fails - which one?\n});\n\n\u002F\u002F Split into isolated tests\ntest.only('step 1: create user', async () => {\n  await createUser();\n  \u002F\u002F Pass ✓\n});\n\ntest.only('step 2: login user', async () => {\n  await createUser();\n  await loginUser();\n  \u002F\u002F Pass ✓\n});\n\ntest.only('step 3: update profile', async () => {\n  await createUser();\n  await loginUser();\n  await updateProfile();\n  \u002F\u002F FAIL ✗ - Found it!\n});\n```\n\n## Debugging Tools and Techniques\n\n### 1. Browser DevTools for E2E Tests\n\n```javascript\ntest('debug with browser open', async ({ page }) => {\n  \u002F\u002F Run in headed mode: npx playwright test --headed\n  \u002F\u002F Run with debug: npx playwright test --debug\n\n  await page.goto('\u002F');\n\n  \u002F\u002F Pause execution for manual inspection\n  await page.pause();\n\n  \u002F\u002F Open DevTools programmatically\n  await page.evaluate(() => debugger);\n});\n```\n\n### 2. Playwright Trace Viewer\n\n```bash\n# Record trace\nnpx playwright test --trace on\n\n# View trace\nnpx playwright show-trace trace.zip\n\n# Trace shows:\n# - Screenshots at each step\n# - Network requests\n# - Console logs\n# - DOM snapshots\n# - Action timeline\n```\n\n### 3. Custom Logging\n\n```javascript\n\u002F\u002F test-logger.js\nexport class TestLogger {\n  static info(message, data) {\n    console.log(`[INFO] ${message}`, data ? JSON.stringify(data, null, 2) : '');\n  }\n\n  static error(message, error) {\n    console.error(`[ERROR] ${message}`, error);\n  }\n\n  static step(stepName) {\n    console.log(`\\n>>> STEP: ${stepName}`);\n  }\n}\n\n\u002F\u002F Usage in tests\ntest('with logging', async ({ page }) => {\n  TestLogger.step('Navigate to login page');\n  await page.goto('\u002Flogin');\n\n  TestLogger.step('Fill login form');\n  await page.fill('#email', 'user@example.com');\n\n  TestLogger.info('Current URL', page.url());\n\n  TestLogger.step('Submit form');\n  await page.click('button[type=\"submit\"]');\n});\n```\n\n### 4. Video Recording\n\n```typescript\n\u002F\u002F playwright.config.ts\nexport default defineConfig({\n  use: {\n    video: 'retain-on-failure', \u002F\u002F or 'on' for all tests\n    screenshot: 'only-on-failure',\n  },\n});\n\n\u002F\u002F Videos are saved in test-results\u002F folder\n```\n\n## Flakiness Investigation\n\n### Identifying Flaky Tests\n\n```bash\n# Run test 50 times and track failures\nfor i in {1..50}; do\n  npm test failing-test.spec.js >> results.txt 2>&1\n  if [ $? -ne 0 ]; then\n    echo \"Failed on run $i\" >> failures.txt\n  fi\ndone\n\n# Check failure rate\ngrep -c \"Failed\" failures.txt\n```\n\n### Common Flakiness Causes\n\n**1. Race Conditions**\n```javascript\n\u002F\u002F ❌ FLAKY: Clicks too fast\nawait page.click('#submit');\nawait page.click('#confirm'); \u002F\u002F Might not be ready yet\n\n\u002F\u002F ✅ STABLE: Wait for element to be ready\nawait page.click('#submit');\nawait page.waitForSelector('#confirm', { state: 'visible' });\nawait page.click('#confirm');\n```\n\n**2. Animations and Transitions**\n```javascript\n\u002F\u002F ❌ FLAKY: Element moving during click\nawait page.click('.menu-item');\n\n\u002F\u002F ✅ STABLE: Wait for animations\nawait page.click('.menu-item', { force: true }); \u002F\u002F Force click\n\u002F\u002F OR disable animations in test environment\n```\n\n**3. Non-Deterministic Data**\n```javascript\n\u002F\u002F ❌ FLAKY: Timestamp changes between runs\nexpect(result.createdAt).toBe('2024-01-15T10:30:00Z');\n\n\u002F\u002F ✅ STABLE: Test relative to now\nexpect(result.createdAt).toMatch(\u002F^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\u002F);\n\n\u002F\u002F ✅ BETTER: Mock time\njest.useFakeTimers();\njest.setSystemTime(new Date('2024-01-15'));\n```\n\n**4. External Dependencies**\n```javascript\n\u002F\u002F ❌ FLAKY: Depends on real API\nconst data = await fetch('https:\u002F\u002Fapi.example.com\u002Fdata');\n\n\u002F\u002F ✅ STABLE: Mock external calls\njest.mock('node-fetch');\nfetch.mockResolvedValue({ json: () => ({ data: 'mocked' }) });\n```\n\n## Performance Debugging\n\n### Slow Test Diagnosis\n\n```javascript\n\u002F\u002F Measure test execution time\ntest('slow test', async () => {\n  const start = Date.now();\n\n  await performSlowOperation();\n\n  const duration = Date.now() - start;\n  console.log(`Operation took ${duration}ms`);\n\n  if (duration > 5000) {\n    console.warn('⚠️ Slow test detected!');\n  }\n});\n\n\u002F\u002F Use test.slow() to increase timeout\ntest.slow('known slow test', async () => {\n  \u002F\u002F Timeout is 3x normal\n});\n```\n\n### Profiling with Chrome DevTools\n\n```javascript\ntest('profile this test', async ({ page }) => {\n  \u002F\u002F Start profiling\n  await page.evaluate(() => {\n    console.profile('MyTest');\n  });\n\n  \u002F\u002F Run test steps\n  await page.goto('\u002F');\n  await page.click('.button');\n\n  \u002F\u002F Stop profiling\n  await page.evaluate(() => {\n    console.profileEnd('MyTest');\n  });\n});\n```\n\n## Best Practices for Debuggable Tests\n\n1. **Use descriptive test names** -- Know what's being tested at a glance.\n2. **Add comments for complex logic** -- Future you will thank you.\n3. **Log intermediate states** -- Don't just log errors, log success states too.\n4. **Use test.step() in Playwright** -- Organize test actions into logical steps.\n5. **Keep tests focused** -- One test should test one thing.\n6. **Use data-testid attributes** -- Makes debugging selector issues easier.\n7. **Add custom error messages** -- `expect(x).toBe(y, 'User ID should match')`\n8. **Record video on failure** -- Visual context is invaluable.\n9. **Use trace viewer** -- See exactly what happened step by step.\n10. **Fix flaky tests immediately** -- They erode trust in the test suite.\n\n## Anti-Patterns to Avoid\n\n1. **Adding wait timeouts** -- `page.waitForTimeout(5000)` hides the real problem.\n2. **Retrying flaky tests** -- Fix the flakiness, don't mask it.\n3. **Skipping failing tests** -- Fix or delete, don't skip indefinitely.\n4. **Not checking logs** -- Logs often contain the answer.\n5. **Debugging in production** -- Use staging or local environments.\n6. **Changing test assertions** -- If the assertion is correct, fix the code, not the test.\n7. **Not using version control** -- Git bisect is your friend.\n8. **Ignoring warnings** -- Warnings often indicate future failures.\n9. **Not documenting known issues** -- Add comments or tickets for workarounds.\n10. **Debugging alone** -- Pair programming on tough bugs saves time.\n\n## Debugging Checklist\n\nWhen a test fails:\n\n- [ ] Read the full error message\n- [ ] Check screenshots\u002Fvideos if available\n- [ ] Review recent code changes\n- [ ] Reproduce locally\n- [ ] Isolate the failing step\n- [ ] Add debug logging\n- [ ] Check environment variables\n- [ ] Verify test data\n- [ ] Review network requests\n- [ ] Check browser console logs\n- [ ] Run in different browsers\n- [ ] Test in CI environment\n- [ ] Use debugger\u002Fbreakpoints\n- [ ] Check for race conditions\n- [ ] Verify mock setup\n- [ ] Review fixture data\n- [ ] Check database state\n- [ ] Test with different data\n- [ ] Simplify test to minimal case\n- [ ] Ask for help if stuck > 30 min\n\nDebugging is a skill. The more systematic you are, the faster you'll find and fix issues. Document what you learn for future reference.\n",{"name":5,"tags":24,"agents":31,"author":42,"domains":43,"license":15,"version":46,"languages":47,"frameworks":51,"description":7,"testingTypes":56},[25,26,27,28,29,30],"debugging","troubleshooting","test-failures","flakiness","root-cause-analysis","performance-debugging",[32,33,34,35,36,37,38,39,40,41],"claude-code","cursor","github-copilot","windsurf","codex","aider","continue","cline","zed","bolt","thetestingacademy",[44,45],"web","api","1.0.0",[48,49,50],"typescript","javascript","python",[52,53,54,55],"playwright","cypress","jest","pytest",[57,58,59],"e2e","unit","integration","main","eac438ea9216a7cb8a570cab803eb01eeafc6793","skills\u002Fqa\u002Fdebugging-strategies","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m","https:\u002F\u002Fid-preview--d5bef06d-6c9e-4563-a3d4-a855b9d61610.lovable.app\u002F","Eu sou Antonio B. B. Ndombe \r\nEu sou um Pesquisador e desenvolvedor de sistema autonomia cognitivos, fundador de sistemas ODCs ( organismos digital conscientes)","2026-11-04 06:53:39",{"source":8,"skillName":5,"commands":69,"prompt":79,"zipAvailable":80},[70,73,76],{"tool":71,"command":72},"npx","npx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Debugging Strategies\"",{"tool":74,"command":75},"bunx","bunx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Debugging Strategies\"",{"tool":77,"command":78},"pnpm","pnpm dlx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Debugging Strategies\"","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Fdebugging-strategies\u002FSKILL.md",true,[],[83,91,98,105,112,119],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7DASC6FSCJP49JZBSK0NY1Z","nemoclaw-user-reference","Describes the NemoClaw integration layer and blueprint architecture and how they orchestrate compatible agent sandboxes. Use when looking up architecture, agent integration, plugin structure, or blueprint design. Trigger keywords - nemoclaw architecture, nemoclaw agent architecture, nemoclaw plugin blueprint structure, nemoclaw vs openshell, which cli, nemoclaw cli, openshell cli, sandbox commands, nemoclaw cli commands, nemoclaw command reference, nemoclaw network policy, sandbox egress control operator approval, nemoclaw troubleshooting, nemoclaw debug sandbox issues.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-reference\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7DAS5S79VK33XFGVAM2TFWF","nemoclaw-user-overview","Explains how OpenClaw, OpenShell, and NemoClaw form the ecosystem, NemoClaw's position in the stack, what NemoClaw adds beyond the community sandbox, and when to prefer NemoClaw versus integrating OpenShell and OpenClaw directly. Use when users ask about the relationship between OpenClaw, OpenShell, and NemoClaw, or when to use NemoClaw versus OpenShell. Trigger keywords - nemoclaw ecosystem, openclaw openshell, nemoclaw vs openshell, sandboxed openclaw, how nemoclaw works, nemoclaw sandbox lifecycle blueprint, nemoclaw overview, openclaw always-on assistants, nvidia openshell, nvidia nemotron, nemoclaw release notes, nemoclaw changelog.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-overview\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M7DAS0PQEMET5MNGZ1ABSZVS","nemoclaw-user-monitor-sandbox","Inspects sandbox health, traces agent behavior, and diagnoses problems. Use when monitoring a running sandbox, debugging agent issues, or checking sandbox logs. Trigger keywords - monitor nemoclaw sandbox, debug nemoclaw agent issues.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-monitor-sandbox\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":19},"01M7DARQYGF7E9A69VH6S3CGN9","nemoclaw-user-manage-sandboxes","Explains operational tasks after the quickstart: listing sandboxes, status and health checks, logs, diagnostics, port forwards, multiple sandboxes, credential reset, rebuilds, network presets, upgrades, and uninstall. Trigger keywords - manage nemoclaw sandboxes, nemoclaw status, nemoclaw list, nemoclaw dashboard port, nemoclaw rebuild, nemoclaw upgrade sandboxes, nemoclaw uninstall, sandbox mutability, sandbox runtime configuration, sandbox rebuild, nemoclaw backup, nemoclaw restore, workspace backup, openshell sandbox download upload, nemoclaw messaging channels, nemoclaw telegram, nemoclaw discord, nemoclaw slack, nemoclaw wechat, nemoclaw whatsapp, openshell channel messaging, nemoclaw workspace files, soul.md, user.md, identity.md, agents.md, sandbox persistence.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-sandboxes\u002FSKILL.md",[],[],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":19},"01M7DARH8BRTG51TRCAB7YWDJ4","nemoclaw-user-manage-policy","Adds, removes, or modifies allowed endpoints in the sandbox policy. Use when customizing network policy, changing egress rules, or configuring sandbox endpoint access. Trigger keywords - customize nemoclaw network policy, sandbox egress policy configuration, nemoclaw integration policy examples, post-install policy setup, openshell approval workflow, policy preset, nemoclaw approve network requests, sandbox egress approval tui.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-policy\u002FSKILL.md",[],[],{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":19},"01M7DARAT62M2VR37590VCZ5NS","nemoclaw-user-get-started","Installs NemoClaw, launches a sandbox, and runs the first agent prompt. Use when onboarding, installing, or launching a NemoClaw sandbox for the first time. Trigger keywords - nemoclaw quickstart, install nemoclaw openclaw sandbox, nemohermes quickstart, hermes agent nemoclaw, run hermes openshell sandbox, nemoclaw prerequisites, nemoclaw supported platforms, nemoclaw hardware software, nemoclaw windows wsl2 setup, nemoclaw install windows docker desktop.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-get-started\u002FSKILL.md",[],[]]