Back to list
chandima

strategy

by chandima

0🍴 0📅 Jan 21, 2026

SKILL.md


name: strategy description: Testing philosophy, patterns, and quality metrics. Covers the testing pyramid, test design patterns (AAA, BDD, fixtures, factories), edge case checklists, and debugging flaky tests.

Testing Strategy

Core testing philosophy and patterns for building reliable, maintainable test suites.

The Testing Pyramid

        /\
       /  \
      / E2E \       Few, slow, high-confidence
     /--------\
    /Integration\   Some, medium speed
   /--------------\
  /     Unit       \  Many, fast, focused
 /------------------\

Good Tests Are (FIRST)

PrincipleDescription
FastTests should run quickly. Slow tests don't get run.
IsolatedEach test is independent. No shared state, no order dependencies.
RepeatableSame result every time. No flakiness, no external dependencies.
Self-ValidatingClear pass/fail. No manual inspection needed.
TimelyWritten close to the code. TDD when appropriate.

Quality Metrics

MetricTargetNotes
Line Coverage80%+For business logic
Branch Coverage70%+For complex conditionals
Mutation Score60%+Measures test effectiveness
Test Execution Time< 5minFor unit tests
Flaky Test Rate< 1%Zero tolerance goal

Test Design Patterns

Arrange-Act-Assert (AAA)

it('should calculate total with tax', () => {
  // Arrange
  const items = [{ price: 10, quantity: 2 }];
  const taxRate = 0.08;
  
  // Act
  const total = calculateTotal(items, taxRate);
  
  // Assert
  expect(total).toBe(21.6);
});

Given-When-Then (BDD)

describe('User login', () => {
  describe('given valid credentials', () => {
    describe('when user submits login form', () => {
      it('then they should be redirected to dashboard', async () => {
        // Test implementation
      });
    });
  });
});

Test Fixtures

// fixtures/users.ts
export const validUser = {
  email: 'test@example.com',
  password: 'SecurePass123!',
  name: 'Test User'
};

export const adminUser = {
  ...validUser,
  email: 'admin@example.com',
  role: 'admin'
};

Factory Pattern

// factories/user.ts
export function createUser(overrides = {}) {
  return {
    id: faker.datatype.uuid(),
    email: faker.internet.email(),
    name: faker.name.fullName(),
    createdAt: new Date(),
    ...overrides
  };
}

// In tests
const user = createUser({ role: 'admin' });

Edge Cases Checklist

Input Validation

  • Empty string / null / undefined
  • Whitespace-only strings
  • Maximum length inputs
  • Special characters / Unicode / emoji
  • Negative numbers / Zero / Very large numbers
  • Invalid date formats

Collections

  • Empty array/object
  • Single item
  • Many items (performance)
  • Duplicate items
  • Unsorted input

Async Operations

  • Success case
  • Timeout
  • Network error
  • Partial failure
  • Retry behavior

Authentication/Authorization

  • Unauthenticated access
  • Invalid/expired token
  • Insufficient permissions
  • Cross-user data access

Debugging Flaky Tests

Common Causes & Fixes

CauseBadGood
Timingawait sleep(1000)await waitFor(() => expect(el).toBeVisible())
Shared stateGlobal let counterReset in beforeEach
External depsReal API callsMock or test containers
Order depsTests depend on orderEach test is independent
Date/timenew Date()Mock the clock

Isolation Fix

// Bad: Shared state
let counter = 0;
it('test 1', () => { counter++; });
it('test 2', () => { expect(counter).toBe(0); }); // Fails!

// Good: Reset in beforeEach
let counter: number;
beforeEach(() => { counter = 0; });

Test Types Summary

TypeScopeSpeedWhen to Use
UnitSingle function/classFastBusiness logic, utilities
IntegrationMultiple componentsMediumAPI endpoints, DB operations
E2EFull user workflowSlowCritical paths, smoke tests

Tools by Type

TypeTools
Unit/IntegrationJest, Vitest, Testing Library
E2E/BrowserPlaywright, agent-browser
APISupertest, Postman/Newman
MockingMSW, jest.mock, vi.mock

Score

Total Score

45/100

Based on repository quality metrics

SKILL.md

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

+20
LICENSE

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

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

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

0/5
Issue管理

オープンIssueが50未満

+5
言語

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

0/5
タグ

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

0/5

Reviews

💬

Reviews coming soon