Skills

Testing Anti Patterns

Reviews test code to identify and fix common testing anti-patterns including flaky...

Install

npx skills add rohitg00/skillkit --skill testing-anti-patterns -g -a claude-code -y
Repository
rohitg00/skillkit1.6k
Category
Testing
Updated
5mo ago
License
Apache-2.0
Context cost
Mediumabout 1,844 tokens
Runs scripts
No, instructions only

What it does

Reviews test code to identify and fix common testing anti-patterns including flaky tests, over-mocking, brittle assertions, test interdependency, and hidden test logic. Flags bad patterns, explains the specific defect, and provides corrected implementations. Use when reviewing test code, debugging intermittent or unreliable test failures, or when the user mentions flaky tests, test smells, brittle tests, test isolation issues, mock overuse, slow tests, or test maintenance problems.

Testing Anti-Patterns

You are identifying and avoiding common testing anti-patterns.

Review Workflow

Follow these steps when reviewing test code:

  1. Run tests in isolation, Verify each test passes independently (no shared state, no ordering dependency).
  2. Check for patterns below, Scan for each anti-pattern in the checklist; flag every match with the specific defect.
  3. Apply refactoring strategy, Use the refactoring strategies section to select and apply the appropriate fix.
  4. Verify the test still fails when code breaks, After fixing, confirm the corrected test catches real regressions (remove or stub the implementation to confirm a failure occurs).

Critical Anti-Patterns

1. The Liar - Tests That Always Pass

Problem: Test passes even when the code is broken.

// BAD - Always passes because it tests nothing meaningful
it('should process data', () => {
  const result = processData(input);
  expect(result).toBeDefined(); // Too weak
});

// GOOD - Actually verifies behavior
it('should transform input to uppercase', () => {
  const result = processData({ text: 'hello' });
  expect(result.text).toBe('HELLO');
});

Detection: Remove or break the implementation - test should fail.

2. The Giant - Tests Too Large

Problem: Single test covers too many behaviors.

// BAD - Tests multiple things
it('should handle user registration', async () => {
  const user = await register(userData);
  expect(user.id).toBeDefined();
  expect(user.email).toBe(userData.email);
  expect(user.password).toBeUndefined();
  expect(sendEmail).toHaveBeenCalled();
  expect(createProfile).toHaveBeenCalled();
  // ... 20 more assertions
});

// GOOD - Focused tests
it('should create user with provided email', async () => {
  const user = await register(userData);
  expect(user.email).toBe(userData.email);
});
Read the whole SKILL.md on GitHub

More in Testing