All skills
asyrafhussin avatar

/testing-best-practices

@575c801

Unit testing, integration testing, and test-driven development principles. Use when writing tests, reviewing test code, improving test coverage, or setting up testing strategy. Triggers on "write tests", "review tests", "testing best practices", or "TDD".

Use this Skill: https://skilld.dev/gh/asyrafhussin/agent-skills/testing-best-practices

This session only. Nothing lands on disk.

rulesstruct-descriptive-names.md

≈593 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Descriptive Test Names

Impact: CRITICAL (test documentation and debugging speed)

Write test names that clearly describe the scenario being tested and the expected outcome. Good naming patterns include [method/feature] [expected behavior] [under condition], should [expected behavior] when [condition], or returns [value] for [input description].

Incorrect

// ❌ Bad: Vague and uninformative names
test('test1', () => {
  expect(validateEmail('test@example.com')).toBe(true);
});

test('email validation', () => {
  expect(validateEmail('invalid')).toBe(false);
});

test('it works', () => {
  const user = createUser({ name: 'John' });
  expect(user.name).toBe('John');
});

test('user test', () => {
  expect(() => createUser({ name: '' })).toThrow();
});

Problems:

  • Names like test1 and it works provide no insight into what is tested
  • When a test fails, the name gives no clue about what behavior broke
  • Cannot assess test coverage by reading test names alone
  • Inconsistent naming patterns across tests

Correct

// ✅ Good: Clear, descriptive names following a consistent pattern
describe('validateEmail', () => {
  test('returns true for valid email with standard format', () => {
    expect(validateEmail('user@example.com')).toBe(true);
  });

  test('returns false when email is missing @ symbol', () => {
    expect(validateEmail('userexample.com')).toBe(false);
  });

  test('returns false when email has multiple @ symbols', () => {
    expect(validateEmail('user@@example.com')).toBe(false);
  });
});

describe('createUser', () => {
  test('creates user with provided name', () => {
    const user = createUser({ name: 'John' });
    expect(user.name).toBe('John');
  });

  test('throws ValidationError when name is empty string', () => {
    expect(() => createUser({ name: '' })).toThrow(ValidationError);
  });
});

Benefits:

  • Test names serve as self-documenting specifications
  • Failed tests immediately reveal which behavior broke
  • Reviewing test names exposes gaps in coverage
  • Team members understand tested behaviors at a glance

Reference: Better Specs — Naming Conventions

Source: SKILL.md on GitHub

No alerts16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides comprehensive guidelines and best practices for unit testing, integration testing, and Test-Driven Development (TDD). It consists entirely of documentation and illustrative code examples using industry-standard tools like Jest and Vitest. No security risks or malicious patterns were detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    29 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 575c801. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago
metadata
{
  "author": "agent-skills",
  "version": "2.0.0"
}

README badge

README badge for asyrafhussin/agent-skills/testing-best-practices