Back to list
doanchienthangdev

avoiding-testing-anti-patterns

by doanchienthangdev

Omega Vibecode Kit

2🍴 1📅 Jan 21, 2026

SKILL.md


name: avoiding-testing-anti-patterns description: AI agent identifies and fixes common testing anti-patterns that lead to flaky, slow, or unmaintainable test suites. Use when reviewing tests, debugging test failures, or improving test quality.

Avoiding Testing Anti-Patterns

Quick Start

  1. Identify - Recognize anti-pattern category (flaky, implementation, over-mocking)
  2. Assess Severity - Critical (fix now), High (fix soon), Medium (plan to fix)
  3. Apply Fix - Use proper async handling, test behavior not implementation
  4. Verify - Run tests in random order, ensure independence
  5. Prevent - Add test smell detection to CI

Features

FeatureDescriptionGuide
Flaky TestsRandom failures destroying trustUse waitFor, not sleep; deterministic data
Implementation TestingBreaks on every refactorTest behavior through public interface
Over-MockingTests pass but bugs slip throughMock boundaries only, not your own code
Slow TestsHurt development velocityRight test layer, shared setup, mock network
Test InterdependenceCan't run tests in isolationFresh state in beforeEach, no shared mutation
Poor DesignHard to understand/maintainDescriptive names, focused tests, clear values

Common Patterns

// FLAKY: Timing-dependent
await sleep(100);  // May not be enough
expect(result).toBe('processed');

// FIXED: Wait for condition
await waitFor(() => {
  expect(result).toBe('processed');
}, { timeout: 5000 });

// FLAKY: Shared state between tests
let sharedState = [];
it('test1', () => { sharedState.push('a'); });
it('test2', () => { expect(sharedState).toHaveLength(1); }); // Order-dependent!

// FIXED: Fresh state each test
beforeEach(() => { sharedState = []; });

// IMPLEMENTATION: Testing private state
expect(counter._count).toBe(1);

// BEHAVIOR: Testing public interface
expect(counter.getValue()).toBe(1);

// OVER-MOCKING: Everything mocked
const mockDb = { save: jest.fn() };
const mockPayment = { charge: jest.fn() };
// Only testing that mocks were called

// FIXED: Mock boundaries only
const testDb = await createTestDatabase();  // Real
const mockPayment = createMockPaymentProvider();  // External only
# Anti-Pattern Severity Guide
CRITICAL (fix immediately):
- Flaky tests - Random failures destroy trust
- Testing implementation - Breaks on every refactor
- Hidden dependencies - Tests fail mysteriously

HIGH (fix soon):
- Slow tests - Hurt development velocity
- Test interdependence - Can't run in isolation
- Over-mocking - Tests pass but bugs slip through

MEDIUM (plan to fix):
- Poor naming - Tests don't document behavior
- Magic values - Unclear expected values
- Giant tests - Hard to understand

LOW (fix when touching):
- Commented tests - Remove or fix
- Duplicate tests - Consolidate

Best Practices

DoAvoid
Test behavior, not implementationAccessing private properties
Use factories for test dataRandom/inconsistent test data
Write descriptive test namesGeneric names like "test1", "should work"
Keep tests independentShared mutable state between tests
Mock only external boundariesMocking your own code extensively
Use waitFor, not sleepsetTimeout/sleep in tests
Make assertions specifictoBeDefined() for everything
Run tests in random orderAssuming test execution order
  • developing-test-driven - TDD with proper patterns
  • testing-with-vitest - Vitest testing framework
  • testing-with-playwright - E2E testing patterns
  • debugging-systematically - Debug flaky test failures

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon