Command Palette

Search for a command to run...

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

testing

БесплатноЗапускает вложенные скриптыНе проверен

Comprehensive testing standards including unit, integration, security, and property-based testing with TDD methodology

williamzujkowskiот williamzujkowski★ 23 звезды на GitHub14 установок в других каталогах

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

Testing Standards Skill

Level 1: Quick Start (5 minutes)

What You'll Learn

Implement effective testing strategies to ensure code quality, catch bugs early, and maintain confidence in changes.

Core Principles

  • Test First: Write tests before implementation (TDD)
  • Coverage: Aim for >80% code coverage
  • Isolation: Tests should be independent and repeatable
  • Speed: Keep unit tests fast (<100ms each)

Testing Pyramid

      /\
     /  \  E2E Tests (Few)
    /----\
   / Inte \
  / gration \ (Some)
 /  Tests   \
/------------\
/ Unit Tests  \ (Many)
/--------------\

Quick Start Example

// 1. Write the test first (RED)
describe("calculateDiscount", () => {
  it("should apply 10% discount for premium users", () => {
    const user = { tier: "premium" };
    const order = { total: 100 };

    const result = calculateDiscount(user, order);

    expect(result).toBe(90);
  });
});

// 2. Implement minimal code (GREEN)
function calculateDiscount(user, order) {
  if (user.tier === "premium") {
    return order.total * 0.9;
  }
  return order.total;
}

// 3. Refactor (REFACTOR)
function calculateDiscount(
  user: User,
  order: Order
): number {
  const PREMIUM_DISCOUNT = 0.1;
  return user.tier === "premium"
    ? order.total * (1 - PREMIUM_DISCOUNT)
    : order.total;
}

Essential Checklist

  • Unit tests for all business logic
  • Integration tests for critical paths
  • Tests run in CI/CD pipeline
  • Coverage >80%
  • Tests are maintainable and readable

Common Pitfalls

  • Testing implementation details instead of behavior
  • Slow tests that discourage running them
  • Flaky tests that fail intermittently
  • Poor test isolation (shared state)

Level 2: Implementation (30 minutes)

Deep Dive Topics

1. Test-Driven Development (TDD)

Red-Green-Refactor Cycle:

// STEP 1: RED - Write failing test
describe("UserService", () => {
  describe("createUser", () => {
    it("should hash password before saving", async () => {
      const userData = {
        email: "[email protected]",
        password: "SecurePass123!",
      };

      const service = new UserService(mockRepository, mockHasher);
      await service.createUser(userData);

      expect(mockHasher.hash).toHaveBeenCalledWith("SecurePass123!");
      expect(mockRepository.save).toHaveBeenCalledWith(
        expect.objectContaining({
          email: "[email protected]",
          passwordHash: expect.any(String),
        })
      );
    });
  });
});

// STEP 2: GREEN - Minimal implementation
class UserService {
  constructor(
    private repository: UserRepository,
    private hasher: PasswordHasher
  ) {}

  async createUser(userData: UserData): Promise<User> {
    const passwordHash = await this.hasher.hash(userData.password);
    return this.repository.save({
      ...userData,
      passwordHash,
    });
  }
}

// STEP 3: REFACTOR - Improve design
class UserService {
  constructor(
    private repository: UserRepository,
    private hasher: PasswordHasher,
    private validator: UserValidator
  ) {}

  async createUser(userData: UserData): Promise<User> {
    await this.validator.validate(userData);
    const passwordHash = await this.hasher.hash(userData.password);

    const user = new User({
      email: userData.email,
      passwordHash,
      createdAt: new Date(),
    });

    return this.repository.save(user);
  }
}

NIST Mapping:

  • @nist-controls: [si-10, si-11, au-2, au-3]

2. Property-Based Testing

import { fc } from "fast-check";

// Traditional example-based test
it("should reverse a reversed string back to original", () => {
  expect(reverse(reverse("hello"))).toBe("hello");
  expect(reverse(reverse("world"))).toBe("world");
  // Limited to specific examples
});

// Property-based test - tests thousands of cases
it("reversing twice should return original string", () => {
  fc.assert(
    fc.property(fc.string(), (str) => {
      expect(reverse(reverse(str))).toBe(str);
    })
  );
});

// Complex property testing
describe("calculateTotal", () => {
  it("should always return non-negative totals", () => {
    fc.assert(
      fc.property(
        fc.array(fc.record({ price: fc.nat(), quantity: fc.nat() })),
        (items) => {
          const total = calculateTotal(items);
          expect(total).toBeGreaterThanOrEqual(0);
        }
      )
    );
  });

  it("should be commutative (order doesn't matter)", () => {
    fc.assert(
      fc.property(fc.array(fc.record({ price: fc.nat(), quantity: fc.nat() })), (items) => {
        const total1 = calculateTotal(items);
        const total2 = calculateTotal([...items].reverse());
        expect(total1).toBe(total2);
      })
    );
  });
});

3. Integration Testing

// API Integration Test
describe("POST /api/users", () => {
  let app: Express;
  let db: Database;

  beforeAll(async () => {
    // Setup test database
    db = await cr
Полный SKILL.md на GitHub

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

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

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

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

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

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

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

Вложенные файлы

e2e-testing/REFERENCE.mde2e-testing/SKILL.mde2e-testing/config/README.mde2e-testing/config/cypress.config.tse2e-testing/config/playwright.config.tse2e-testing/resources/README.mde2e-testing/resources/e2e-best-practices.mde2e-testing/scripts/README.mde2e-testing/scripts/run-e2e-tests.she2e-testing/templates/README.mde2e-testing/templates/page-object.tse2e-testing/templates/test-template.spec.tsintegration-testing/SKILL.mdintegration-testing/resources/README.mdintegration-testing/resources/examples/contract-testing.mdintegration-testing/scripts/README.mdintegration-testing/scripts/setup-test-db.shintegration-testing/templates/README.mdintegration-testing/templates/api-test-template.jsintegration-testing/templates/docker-compose.test.ymlintegration-testing/templates/integration-test-python.pyperformance-testing/REFERENCE.mdperformance-testing/SKILL.mdperformance-testing/config/jmeter-test-plan.jmxperformance-testing/resources/README.mdperformance-testing/resources/performance-checklist.mdperformance-testing/scripts/README.mdperformance-testing/scripts/run-perf-tests.shperformance-testing/templates/README.mdperformance-testing/templates/grafana-dashboard.jsonperformance-testing/templates/k6-load-test.jsperformance-testing/templates/k6-stress-test.jsunit-testing/SKILL.mdunit-testing/config/jest.config.jsunit-testing/config/pytest.iniunit-testing/resources/README.mdunit-testing/resources/configs/jest.config.jsunit-testing/resources/configs/pytest.iniunit-testing/resources/coverage-configs/.coveragercunit-testing/resources/test-pyramid-diagram.md

FAQ

Что делает скилл testing?

Comprehensive testing standards including unit, integration, security, and property-based testing with TDD methodology

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

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

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

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

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

Сравнить testing с