[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6QJ56CYTJ93H4CKYM3VH96D":3,"skill-same:01M6QJ56CYTJ93H4CKYM3VH96D":76},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":56,"commitSha":57,"skillDirectory":58,"forksCount":13,"repositoryHtmlUrl":59,"repositoryHomepageUrl":6,"ownerHtmlUrl":60,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":61,"install":62,"resources":75},"01M6QJ56CYTJ93H4CKYM3VH96D","test-readability",null,"Master writing readable tests: how to structure tests for clarity, name tests descriptively, and make tests self-documenting. Use when writing tests, reviewing test quality, or when tests are hard to understand. Triggers especially when user says \"readable tests\", \"test structure\", \"test naming\", \"test organization\", \"self-documenting tests\" or \"clear tests\".","ImaginerLabs\u002Fskill-manager","ImaginerLabs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F214277308?v=4","01M6QGGDPNF15RMMT1RCFDH9FN","01M6QGGDTH5BY64DQ123NR8M33",0,"MIT","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fcoding\u002Ftest-readability\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"test","test readability","readability","self","writing","for","naming","make","how to","triggers","tests","writing tests","how","structure","organization","make tests","master","use","coding","clarity","2026-11-10 10:12:30",false,"---\nname: test-readability\ndescription: >-\n  Master writing readable tests: how to structure tests for clarity, name tests descriptively, and make tests self-documenting. Use when writing tests, reviewing test quality, or when tests are hard to understand. Triggers especially when user says \"readable tests\", \"test structure\", \"test naming\", \"test organization\", \"self-documenting tests\" or \"clear tests\".\ncategory: coding\npriority: P2\ntrigger_patterns:\n  - \"readable tests\"\n  - \"test structure\"\n  - \"test naming\"\n  - \"test organization\"\n  - \"self-documenting tests\"\n  - \"clear tests\"\n---\n\n# Test Readability — Test Structure and Naming Framework\n\n## Overview\n\nTest-readability is a **behavioral specification skill** that encapsulates the methodology for **writing tests that are self-documenting, well-structured, and communicate intent clearly**.\n\nThis skill embodies the experience of developers who've inherited tests they couldn't understand and spent hours deciphering what they did — and knows that readable tests are as important as working code.\n\n## Core Philosophy\n\n### The Test Readability Principle\n\n> \"Tests are documentation. When you write a test, you're documenting how the code should behave. If someone can read your test and understand the system, you've done it right.\"\n\n### Readable vs Unreadable Tests\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    READABLE vs UNREADABLE                     │\n│                                                               │\n│    UNREADABLE:                  READABLE:                     │\n│    ───────────                  ─────────                     │\n│    test('1', () => {...})      test('returns user when      │\n│    test('2', () => {...})       valid id provided')          │\n│                                                               │\n│    expect(u).toBe(e)           expect(gotUser).toEqual(      │\n│                                  expectedUser)                │\n│                                                               │\n│    No context                   Clear intent                  │\n│    Cryptic                     Self-documenting             │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Decision Framework\n\n### What Makes a Test Readable?\n\n| Aspect | Poor | Good |\n|--------|------|------|\n| Name | \"test 1\" | \"should return user when valid id provided\" |\n| Structure | Everything in one block | Arrange-Act-Assert |\n| Assertions | Cryptic | Self-documenting |\n| Context | Hidden | Explicit |\n| Intent | Hidden | Clear |\n\n### Test Name Patterns\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    TEST NAME PATTERNS                         │\n│                                                               │\n│    PATTERN 1: \"should [expected behavior]\"                  │\n│    \"should return user when valid id provided\"              │\n│                                                               │\n│    PATTERN 2: \"[action] [target] [expected result]\"         │\n│    \"returns user for valid id\"                              │\n│                                                               │\n│    PATTERN 3: \"[when\u002Fscenario] [expected]\"                  │\n│    \"when user not found throws error\"                       │\n│                                                               │\n│    AVOID: \"test 1\", \"test 2\", \"does thing\"                 │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Behavioral Specification\n\n### Phase 1: Test Structure\n\n#### 1.1 Arrange-Act-Assert Pattern\n\n```typescript\n\u002F\u002F CLASSIC: Arrange-Act-Assert\ndescribe('UserService', () => {\n  describe('getUserById', () => {\n    it('should return user when id exists', async () => {\n      \u002F\u002F ARRANGE: Set up test data\n      const existingUser = await createTestUser({ id: '123' });\n\n      \u002F\u002F ACT: Perform the action\n      const result = await userService.getUserById('123');\n\n      \u002F\u002F ASSERT: Verify the outcome\n      expect(result).toEqual(existingUser);\n    });\n  });\n});\n```\n\n#### 1.2 Given-When-Then Pattern\n\n```typescript\n\u002F\u002F BDD: Given-When-Then\ndescribe('OrderProcessor', () => {\n  describe('when order is valid', () => {\n    given('a valid order with in-stock items', () => {\n      const order = createOrder({ items: [{ inStock: true }] });\n\n      when('processOrder is called', () => {\n        const result = orderProcessor.process(order);\n\n        then('should mark order as processed', () => {\n          expect(result.status).toBe('processed');\n        });\n      });\n    });\n  });\n});\n```\n\n#### 1.3 Descriptive Block Structure\n\n```typescript\n\u002F\u002F ORGANIZED: Nested describe blocks\ndescribe('PaymentService', () => {\n  describe('processPayment', () => {\n    describe('when payment method is credit card', () => {\n      describe('and card is valid', () => {\n        it('should process payment successfully', () => {\n          \u002F\u002F Test for valid card\n        });\n\n        it('should charge correct amount', () => {\n          \u002F\u002F Test amount calculation\n        });\n      });\n\n      describe('and card is expired', () => {\n        it('should reject payment', () => {\n          \u002F\u002F Test expired card handling\n        });\n      });\n    });\n\n    describe('when payment method is PayPal', () => {\n      \u002F\u002F PayPal-specific tests\n    });\n  });\n});\n```\n\n### Phase 2: Test Naming\n\n#### 2.1 Good Test Names\n\n```typescript\n\u002F\u002F EXCELLENT: Self-documenting\nit('should return null when user does not exist', () => { ... });\nit('should throw ValidationError when email is invalid', () => { ... });\nit('should retry three times before failing on network error', () => { ... });\nit('should format currency correctly for USD locale', () => { ... });\n\n\u002F\u002F Each name tells you:\n\u002F\u002F 1. What triggers it (when)\n\u002F\u002F 2. What expected behavior (should)\n\u002F\u002F 3. No need to read the test body to understand\n```\n\n#### 2.2 Naming Templates\n\n```typescript\n\u002F\u002F TEMPLATE: should [expected result] when [condition]\n\nit('should return {value} when {condition}', () => { ... });\nit('should throw {error} when {condition}', () => { ... });\nit('should {action} when {condition}', () => { ... });\n\n\u002F\u002F Examples:\nit('should return empty array when user has no orders', () => { ... });\nit('should throw UnauthorizedError when token is expired', () => { ... });\nit('should redirect to dashboard when login succeeds', () => { ... });\n```\n\n#### 2.3 Names to Avoid\n\n```typescript\n\u002F\u002F BAD: Cryptic names\nit('test 1', () => { ... });\nit('process', () => { ... });\nit('works', () => { ... });\nit('edge case', () => { ... });\n\n\u002F\u002F BAD: Implementation details in name\nit('calls repository.findById', () => { ... });\nit('uses cache.get', () => { ... });\n\n\u002F\u002F BAD: Too vague\nit('handles error', () => { ... });\nit('works correctly', () => { ... });\n```\n\n### Phase 3: Self-Documenting Code\n\n#### 3.1 Clear Assertions\n\n```typescript\n\u002F\u002F BAD: Cryptic assertion\nexpect(res).toBe(true);\n\n\u002F\u002F GOOD: Descriptive assertion\nexpect(isValid).toBe(true);\nexpect(paymentProcessed).toBe(true);\n\n\u002F\u002F GREAT: Clear value in assertion\nexpect(result).toEqual({\n  status: 'success',\n  userId: 'user-123',\n  amount: 99.99,\n});\n\n\u002F\u002F EVEN BETTER: Named expected value\nconst expectedOrder = {\n  status: 'pending',\n  items: [expectedItem],\n};\nexpect(order).toEqual(expectedOrder);\n```\n\n#### 3.2 Helper Functions for Clarity\n\n```typescript\n\u002F\u002F GOOD: Descriptive helpers\nfunction createValidUser(overrides?: Partial\u003CUser>): User {\n  return {\n    id: 'user-123',\n    email: 'test@example.com',\n    name: 'Test User',\n    isActive: true,\n    ...overrides,\n  };\n}\n\n\u002F\u002F Usage in test\nit('should reject inactive user', async () => {\n  const inactiveUser = createValidUser({ isActive: false });\n  \u002F\u002F Clear what 'inactive' means in context\n});\n```\n\n#### 3.3 Comments for Context\n\n```typescript\n\u002F\u002F GOOD: Why, not what\nit('should handle race condition in concurrent updates', () => {\n  \u002F\u002F Race condition occurs when two requests try to update\n  \u002F\u002F the same resource simultaneously. The database should\n  \u002F\u002F use optimistic locking to handle this gracefully.\n});\n\n\u002F\u002F BAD: What, not why (code already says this)\n\u002F\u002F Increment counter\ncounter++;\n\n\u002F\u002F GOOD: Add context when non-obvious\n\u002F\u002F Use \u003C= not \u003C to match the API spec's inclusive bounds\nconst isInRange = value \u003C= MAX_VALUE;\n```\n\n### Phase 4: Test Organization\n\n#### 4.1 Grouping Related Tests\n\n```typescript\ndescribe('UserService', () => {\n  \u002F\u002F GROUP: Creation\n  describe('createUser', () => { ... });\n  describe('createAdmin', () => { ... });\n\n  \u002F\u002F GROUP: Retrieval\n  describe('getUserById', () => { ... });\n  describe('getUserByEmail', () => { ... });\n\n  \u002F\u002F GROUP: Updates\n  describe('updateUser', () => { ... });\n  describe('deleteUser', () => { ... });\n});\n```\n\n#### 4.2 Setup and Teardown\n\n```typescript\ndescribe('OrderService', () => {\n  let orderService: OrderService;\n  let mockOrderRepo: MockOrderRepository;\n\n  \u002F\u002F SHARED SETUP: Runs before each test\n  beforeEach(() => {\n    mockOrderRepo = createMockOrderRepository();\n    orderService = new OrderService(mockOrderRepo);\n  });\n\n  \u002F\u002F CLEANUP: Runs after each test\n  afterEach(() => {\n    vi.clearAllMocks();\n  });\n\n  it('should create order', () => { ... });\n  it('should cancel order', () => { ... });\n});\n```\n\n## Common Scenarios\n\n### Scenario 1: \"This test is too long\"\n\n```typescript\n\u002F\u002F BAD: 100 lines in one test\nit('should process full order flow', async () => {\n  \u002F\u002F Create user...\n  \u002F\u002F Create product...\n  \u002F\u002F Add to cart...\n  \u002F\u002F Apply discount...\n  \u002F\u002F Calculate total...\n  \u002F\u002F Create payment...\n  \u002F\u002F Verify email...\n  \u002F\u002F Update inventory...\n  \u002F\u002F 100 lines later...\n});\n\n\u002F\u002F GOOD: Split into focused tests\nit('should create order from cart', () => {\n  const cart = createCartWithItems();\n  const order = orderService.createOrder(cart);\n  expect(order.items).toEqual(cart.items);\n});\n\nit('should calculate total with tax', () => {\n  const order = createOrder({ subtotal: 100 });\n  const total = orderService.calculateTotal(order);\n  expect(total).toBe(110); \u002F\u002F 10% tax\n});\n\nit('should send confirmation email', () => {\n  const order = createCompletedOrder();\n  await orderService.sendConfirmation(order);\n  expect(emailService.send).toHaveBeenCalledWith(order.email);\n});\n```\n\n### Scenario 2: \"What is this test testing?\"\n\n```typescript\n\u002F\u002F BAD: Unclear context\nit('should handle 400 error', () => {\n  mockApi.post.mockRejectedValue({ status: 400 });\n  \u002F\u002F What endpoint? What causes 400?\n});\n\n\u002F\u002F GOOD: Clear context\nit('should return ValidationError when POST \u002Fusers has invalid email', async () => {\n  mockApi.post.mockRejectedValue({\n    status: 400,\n    message: 'Invalid email format',\n  });\n\n  await expect(createUser({ email: 'invalid' }))\n    .rejects.toThrow(ValidationError);\n});\n```\n\n### Scenario 3: \"Magic values everywhere\"\n\n```typescript\n\u002F\u002F BAD: Magic numbers\nit('should calculate', () => {\n  const result = calculate(100, 20, 5);\n  expect(result).toBe(25);\n  \u002F\u002F What do 100, 20, 5 mean?\n});\n\n\u002F\u002F GOOD: Named values\nit('should apply discount correctly', () => {\n  const price = 100;\n  const discountPercent = 20;\n  const taxRate = 5;\n\n  const result = calculate(price, discountPercent, taxRate);\n\n  const expected = (price * (1 - discountPercent \u002F 100)) * (1 + taxRate \u002F 100);\n  expect(result).toBeCloseTo(expected);\n});\n```\n\n## Test Readability Anti-Patterns\n\n### 1. Cryptic Test Names\n\n```typescript\n\u002F\u002F BAD\ntest('1', () => { ... });\ntest('a', () => { ... });\ntest('t', () => { ... });\n\n\u002F\u002F GOOD\ntest('should return user when id is valid', () => { ... });\n```\n\n### 2. No Structure\n\n```typescript\n\u002F\u002F BAD: Everything in one flat describe\ndescribe('Tests', () => {\n  it('test 1', () => { ... });\n  it('test 2', () => { ... });\n  it('test 3', () => { ... });\n});\n\n\u002F\u002F GOOD: Organized structure\ndescribe('UserService', () => {\n  describe('getUserById', () => {\n    it('should return user when exists', () => { ... });\n    it('should throw when not found', () => { ... });\n  });\n});\n```\n\n### 3. Unclear Assertions\n\n```typescript\n\u002F\u002F BAD: What is being checked?\nexpect(result).toBe(1);\n\n\u002F\u002F GOOD: Clear expectation\nexpect(userRole).toBe(Role.ADMIN);\nexpect(hasPermission).toBe(true);\nexpect(errorCode).toBe('INVALID_EMAIL');\n```\n\n### 4. Missing Context\n\n```typescript\n\u002F\u002F BAD: Assumes global state\nbeforeEach(() => {\n  db.clear(); \u002F\u002F What db?\n});\n\n\u002F\u002F GOOD: Clear setup\nbeforeEach(() => {\n  testDatabase.clear(); \u002F\u002F What is being cleared?\n});\n```\n\n## The Test Readability Checklist\n\n```\nTEST READABILITY CHECKLIST\n==========================\n\n□ 1. Does the test name describe WHAT it tests?\n□ 2. Is the scenario\u002Fcondition clear?\n□ 3. Is the expected behavior obvious?\n□ 4. Is there Arrange-Act-Assert structure?\n□ 5. Are assertions self-documenting?\n□ 6. Are there clear setup\u002Fteardown?\n□ 7. Can someone understand test without reading code?\n□ 8. Are helper functions used to reduce noise?\n□ 9. Are magic values named?\n□ 10. Is the test single-purpose?\n\nFOR TEST NAMES:\n□ \"should [expected] when [condition]\"\n□ Describes behavior, not implementation\n□ No cryptic abbreviations\n□ Clear scenario\n```\n\n## Key Principles\n\n### 1. Tests Document Behavior\n\nGood tests explain how the system should behave.\n\n### 2. Name = Documentation\n\nThe test name should summarize the test completely.\n\n### 3. Structure for Scannability\n\nAnyone should be able to scan and find tests they need.\n\n### 4. Assertions Should Self-Verify\n\nRead the assertion, understand what was checked.\n\n### 5. Reduce Cognitive Load\n\nReaders shouldn't have to hold context in their head.\n\n## Relationship to Other Skills\n\n- `test-think` — Determines what to test\n- `intelligent-test-creation` — Creates readable tests\n- `setup-test-data` — Data setup affects readability\n- `generate-mock` — Mock setup affects readability\n- `debug-test` — Unclear tests cause debugging difficulty\n","# Test Readability — Test Structure and Naming Framework\n\n## Overview\n\nTest-readability is a **behavioral specification skill** that encapsulates the methodology for **writing tests that are self-documenting, well-structured, and communicate intent clearly**.\n\nThis skill embodies the experience of developers who've inherited tests they couldn't understand and spent hours deciphering what they did — and knows that readable tests are as important as working code.\n\n## Core Philosophy\n\n### The Test Readability Principle\n\n> \"Tests are documentation. When you write a test, you're documenting how the code should behave. If someone can read your test and understand the system, you've done it right.\"\n\n### Readable vs Unreadable Tests\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    READABLE vs UNREADABLE                     │\n│                                                               │\n│    UNREADABLE:                  READABLE:                     │\n│    ───────────                  ─────────                     │\n│    test('1', () => {...})      test('returns user when      │\n│    test('2', () => {...})       valid id provided')          │\n│                                                               │\n│    expect(u).toBe(e)           expect(gotUser).toEqual(      │\n│                                  expectedUser)                │\n│                                                               │\n│    No context                   Clear intent                  │\n│    Cryptic                     Self-documenting             │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Decision Framework\n\n### What Makes a Test Readable?\n\n| Aspect | Poor | Good |\n|--------|------|------|\n| Name | \"test 1\" | \"should return user when valid id provided\" |\n| Structure | Everything in one block | Arrange-Act-Assert |\n| Assertions | Cryptic | Self-documenting |\n| Context | Hidden | Explicit |\n| Intent | Hidden | Clear |\n\n### Test Name Patterns\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    TEST NAME PATTERNS                         │\n│                                                               │\n│    PATTERN 1: \"should [expected behavior]\"                  │\n│    \"should return user when valid id provided\"              │\n│                                                               │\n│    PATTERN 2: \"[action] [target] [expected result]\"         │\n│    \"returns user for valid id\"                              │\n│                                                               │\n│    PATTERN 3: \"[when\u002Fscenario] [expected]\"                  │\n│    \"when user not found throws error\"                       │\n│                                                               │\n│    AVOID: \"test 1\", \"test 2\", \"does thing\"                 │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Behavioral Specification\n\n### Phase 1: Test Structure\n\n#### 1.1 Arrange-Act-Assert Pattern\n\n```typescript\n\u002F\u002F CLASSIC: Arrange-Act-Assert\ndescribe('UserService', () => {\n  describe('getUserById', () => {\n    it('should return user when id exists', async () => {\n      \u002F\u002F ARRANGE: Set up test data\n      const existingUser = await createTestUser({ id: '123' });\n\n      \u002F\u002F ACT: Perform the action\n      const result = await userService.getUserById('123');\n\n      \u002F\u002F ASSERT: Verify the outcome\n      expect(result).toEqual(existingUser);\n    });\n  });\n});\n```\n\n#### 1.2 Given-When-Then Pattern\n\n```typescript\n\u002F\u002F BDD: Given-When-Then\ndescribe('OrderProcessor', () => {\n  describe('when order is valid', () => {\n    given('a valid order with in-stock items', () => {\n      const order = createOrder({ items: [{ inStock: true }] });\n\n      when('processOrder is called', () => {\n        const result = orderProcessor.process(order);\n\n        then('should mark order as processed', () => {\n          expect(result.status).toBe('processed');\n        });\n      });\n    });\n  });\n});\n```\n\n#### 1.3 Descriptive Block Structure\n\n```typescript\n\u002F\u002F ORGANIZED: Nested describe blocks\ndescribe('PaymentService', () => {\n  describe('processPayment', () => {\n    describe('when payment method is credit card', () => {\n      describe('and card is valid', () => {\n        it('should process payment successfully', () => {\n          \u002F\u002F Test for valid card\n        });\n\n        it('should charge correct amount', () => {\n          \u002F\u002F Test amount calculation\n        });\n      });\n\n      describe('and card is expired', () => {\n        it('should reject payment', () => {\n          \u002F\u002F Test expired card handling\n        });\n      });\n    });\n\n    describe('when payment method is PayPal', () => {\n      \u002F\u002F PayPal-specific tests\n    });\n  });\n});\n```\n\n### Phase 2: Test Naming\n\n#### 2.1 Good Test Names\n\n```typescript\n\u002F\u002F EXCELLENT: Self-documenting\nit('should return null when user does not exist', () => { ... });\nit('should throw ValidationError when email is invalid', () => { ... });\nit('should retry three times before failing on network error', () => { ... });\nit('should format currency correctly for USD locale', () => { ... });\n\n\u002F\u002F Each name tells you:\n\u002F\u002F 1. What triggers it (when)\n\u002F\u002F 2. What expected behavior (should)\n\u002F\u002F 3. No need to read the test body to understand\n```\n\n#### 2.2 Naming Templates\n\n```typescript\n\u002F\u002F TEMPLATE: should [expected result] when [condition]\n\nit('should return {value} when {condition}', () => { ... });\nit('should throw {error} when {condition}', () => { ... });\nit('should {action} when {condition}', () => { ... });\n\n\u002F\u002F Examples:\nit('should return empty array when user has no orders', () => { ... });\nit('should throw UnauthorizedError when token is expired', () => { ... });\nit('should redirect to dashboard when login succeeds', () => { ... });\n```\n\n#### 2.3 Names to Avoid\n\n```typescript\n\u002F\u002F BAD: Cryptic names\nit('test 1', () => { ... });\nit('process', () => { ... });\nit('works', () => { ... });\nit('edge case', () => { ... });\n\n\u002F\u002F BAD: Implementation details in name\nit('calls repository.findById', () => { ... });\nit('uses cache.get', () => { ... });\n\n\u002F\u002F BAD: Too vague\nit('handles error', () => { ... });\nit('works correctly', () => { ... });\n```\n\n### Phase 3: Self-Documenting Code\n\n#### 3.1 Clear Assertions\n\n```typescript\n\u002F\u002F BAD: Cryptic assertion\nexpect(res).toBe(true);\n\n\u002F\u002F GOOD: Descriptive assertion\nexpect(isValid).toBe(true);\nexpect(paymentProcessed).toBe(true);\n\n\u002F\u002F GREAT: Clear value in assertion\nexpect(result).toEqual({\n  status: 'success',\n  userId: 'user-123',\n  amount: 99.99,\n});\n\n\u002F\u002F EVEN BETTER: Named expected value\nconst expectedOrder = {\n  status: 'pending',\n  items: [expectedItem],\n};\nexpect(order).toEqual(expectedOrder);\n```\n\n#### 3.2 Helper Functions for Clarity\n\n```typescript\n\u002F\u002F GOOD: Descriptive helpers\nfunction createValidUser(overrides?: Partial\u003CUser>): User {\n  return {\n    id: 'user-123',\n    email: 'test@example.com',\n    name: 'Test User',\n    isActive: true,\n    ...overrides,\n  };\n}\n\n\u002F\u002F Usage in test\nit('should reject inactive user', async () => {\n  const inactiveUser = createValidUser({ isActive: false });\n  \u002F\u002F Clear what 'inactive' means in context\n});\n```\n\n#### 3.3 Comments for Context\n\n```typescript\n\u002F\u002F GOOD: Why, not what\nit('should handle race condition in concurrent updates', () => {\n  \u002F\u002F Race condition occurs when two requests try to update\n  \u002F\u002F the same resource simultaneously. The database should\n  \u002F\u002F use optimistic locking to handle this gracefully.\n});\n\n\u002F\u002F BAD: What, not why (code already says this)\n\u002F\u002F Increment counter\ncounter++;\n\n\u002F\u002F GOOD: Add context when non-obvious\n\u002F\u002F Use \u003C= not \u003C to match the API spec's inclusive bounds\nconst isInRange = value \u003C= MAX_VALUE;\n```\n\n### Phase 4: Test Organization\n\n#### 4.1 Grouping Related Tests\n\n```typescript\ndescribe('UserService', () => {\n  \u002F\u002F GROUP: Creation\n  describe('createUser', () => { ... });\n  describe('createAdmin', () => { ... });\n\n  \u002F\u002F GROUP: Retrieval\n  describe('getUserById', () => { ... });\n  describe('getUserByEmail', () => { ... });\n\n  \u002F\u002F GROUP: Updates\n  describe('updateUser', () => { ... });\n  describe('deleteUser', () => { ... });\n});\n```\n\n#### 4.2 Setup and Teardown\n\n```typescript\ndescribe('OrderService', () => {\n  let orderService: OrderService;\n  let mockOrderRepo: MockOrderRepository;\n\n  \u002F\u002F SHARED SETUP: Runs before each test\n  beforeEach(() => {\n    mockOrderRepo = createMockOrderRepository();\n    orderService = new OrderService(mockOrderRepo);\n  });\n\n  \u002F\u002F CLEANUP: Runs after each test\n  afterEach(() => {\n    vi.clearAllMocks();\n  });\n\n  it('should create order', () => { ... });\n  it('should cancel order', () => { ... });\n});\n```\n\n## Common Scenarios\n\n### Scenario 1: \"This test is too long\"\n\n```typescript\n\u002F\u002F BAD: 100 lines in one test\nit('should process full order flow', async () => {\n  \u002F\u002F Create user...\n  \u002F\u002F Create product...\n  \u002F\u002F Add to cart...\n  \u002F\u002F Apply discount...\n  \u002F\u002F Calculate total...\n  \u002F\u002F Create payment...\n  \u002F\u002F Verify email...\n  \u002F\u002F Update inventory...\n  \u002F\u002F 100 lines later...\n});\n\n\u002F\u002F GOOD: Split into focused tests\nit('should create order from cart', () => {\n  const cart = createCartWithItems();\n  const order = orderService.createOrder(cart);\n  expect(order.items).toEqual(cart.items);\n});\n\nit('should calculate total with tax', () => {\n  const order = createOrder({ subtotal: 100 });\n  const total = orderService.calculateTotal(order);\n  expect(total).toBe(110); \u002F\u002F 10% tax\n});\n\nit('should send confirmation email', () => {\n  const order = createCompletedOrder();\n  await orderService.sendConfirmation(order);\n  expect(emailService.send).toHaveBeenCalledWith(order.email);\n});\n```\n\n### Scenario 2: \"What is this test testing?\"\n\n```typescript\n\u002F\u002F BAD: Unclear context\nit('should handle 400 error', () => {\n  mockApi.post.mockRejectedValue({ status: 400 });\n  \u002F\u002F What endpoint? What causes 400?\n});\n\n\u002F\u002F GOOD: Clear context\nit('should return ValidationError when POST \u002Fusers has invalid email', async () => {\n  mockApi.post.mockRejectedValue({\n    status: 400,\n    message: 'Invalid email format',\n  });\n\n  await expect(createUser({ email: 'invalid' }))\n    .rejects.toThrow(ValidationError);\n});\n```\n\n### Scenario 3: \"Magic values everywhere\"\n\n```typescript\n\u002F\u002F BAD: Magic numbers\nit('should calculate', () => {\n  const result = calculate(100, 20, 5);\n  expect(result).toBe(25);\n  \u002F\u002F What do 100, 20, 5 mean?\n});\n\n\u002F\u002F GOOD: Named values\nit('should apply discount correctly', () => {\n  const price = 100;\n  const discountPercent = 20;\n  const taxRate = 5;\n\n  const result = calculate(price, discountPercent, taxRate);\n\n  const expected = (price * (1 - discountPercent \u002F 100)) * (1 + taxRate \u002F 100);\n  expect(result).toBeCloseTo(expected);\n});\n```\n\n## Test Readability Anti-Patterns\n\n### 1. Cryptic Test Names\n\n```typescript\n\u002F\u002F BAD\ntest('1', () => { ... });\ntest('a', () => { ... });\ntest('t', () => { ... });\n\n\u002F\u002F GOOD\ntest('should return user when id is valid', () => { ... });\n```\n\n### 2. No Structure\n\n```typescript\n\u002F\u002F BAD: Everything in one flat describe\ndescribe('Tests', () => {\n  it('test 1', () => { ... });\n  it('test 2', () => { ... });\n  it('test 3', () => { ... });\n});\n\n\u002F\u002F GOOD: Organized structure\ndescribe('UserService', () => {\n  describe('getUserById', () => {\n    it('should return user when exists', () => { ... });\n    it('should throw when not found', () => { ... });\n  });\n});\n```\n\n### 3. Unclear Assertions\n\n```typescript\n\u002F\u002F BAD: What is being checked?\nexpect(result).toBe(1);\n\n\u002F\u002F GOOD: Clear expectation\nexpect(userRole).toBe(Role.ADMIN);\nexpect(hasPermission).toBe(true);\nexpect(errorCode).toBe('INVALID_EMAIL');\n```\n\n### 4. Missing Context\n\n```typescript\n\u002F\u002F BAD: Assumes global state\nbeforeEach(() => {\n  db.clear(); \u002F\u002F What db?\n});\n\n\u002F\u002F GOOD: Clear setup\nbeforeEach(() => {\n  testDatabase.clear(); \u002F\u002F What is being cleared?\n});\n```\n\n## The Test Readability Checklist\n\n```\nTEST READABILITY CHECKLIST\n==========================\n\n□ 1. Does the test name describe WHAT it tests?\n□ 2. Is the scenario\u002Fcondition clear?\n□ 3. Is the expected behavior obvious?\n□ 4. Is there Arrange-Act-Assert structure?\n□ 5. Are assertions self-documenting?\n□ 6. Are there clear setup\u002Fteardown?\n□ 7. Can someone understand test without reading code?\n□ 8. Are helper functions used to reduce noise?\n□ 9. Are magic values named?\n□ 10. Is the test single-purpose?\n\nFOR TEST NAMES:\n□ \"should [expected] when [condition]\"\n□ Describes behavior, not implementation\n□ No cryptic abbreviations\n□ Clear scenario\n```\n\n## Key Principles\n\n### 1. Tests Document Behavior\n\nGood tests explain how the system should behave.\n\n### 2. Name = Documentation\n\nThe test name should summarize the test completely.\n\n### 3. Structure for Scannability\n\nAnyone should be able to scan and find tests they need.\n\n### 4. Assertions Should Self-Verify\n\nRead the assertion, understand what was checked.\n\n### 5. Reduce Cognitive Load\n\nReaders shouldn't have to hold context in their head.\n\n## Relationship to Other Skills\n\n- `test-think` — Determines what to test\n- `intelligent-test-creation` — Creates readable tests\n- `setup-test-data` — Data setup affects readability\n- `generate-mock` — Mock setup affects readability\n- `debug-test` — Unclear tests cause debugging difficulty\n",{"name":5,"category":41,"priority":48,"description":7,"trigger_patterns":49},"P2",[50,51,52,53,54,55],"readable tests","test structure","test naming","test organization","self-documenting tests","clear tests","main","b9a52d8e27455bdad953d64928696d028223ea1b","skills\u002Fcoding\u002Ftest-readability","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager","https:\u002F\u002Fgithub.com\u002FImaginerLabs","2026-04-18 16:27:13",{"source":8,"skillName":5,"commands":63,"prompt":73,"zipAvailable":74},[64,67,70],{"tool":65,"command":66},"npx","npx skills add ImaginerLabs\u002Fskill-manager --skill test-readability",{"tool":68,"command":69},"bunx","bunx skills add ImaginerLabs\u002Fskill-manager --skill test-readability",{"tool":71,"command":72},"pnpm","pnpm dlx skills add ImaginerLabs\u002Fskill-manager --skill test-readability","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fcoding\u002Ftest-readability\u002FSKILL.md",true,[],[77,108,128,156,189,214],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":91,"publishedAt":43},"01M6QJCB2SD5KHC41ZDQC0GA1T","meeting-minutes","Generate concise, actionable meeting minutes for internal meetings. Includes metadata, attendees, agenda, decisions, action items (owner + due date), and follow-up steps.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fwriting\u002Fmeeting-minutes\u002FSKILL.md",[83,86],{"categoryNo":84,"categoryName":85,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":87,"categoryName":88,"taxonomyType":89,"taxonomyTypeDesc":90},"01JBSEEDCAT000000000000034","行政与办公人员","PROFESSION","适用职业",[92,93,94,27,95,96,97,98,99,100,79,56,101,102,103,104,105,106,107,28],"meeting minutes","meeting","minutes","github","copilot","generate","decisions","meetings","up","agenda","actionable","concise","follow-up","tree","true","action",{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":43},"01M6QJC71RRGTGNNFEHJG6S20G","documentation-writer","Diátaxis Documentation Expert. An expert technical writer specializing in creating high-quality software documentation, guided by the principles and structure of the Diátaxis technical documentation authoring framework.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fwriting\u002Fdocumentation-writer\u002FSKILL.md",[],[115,116,117,27,95,96,118,119,120,121,122,123,56,36,124,125,126,105,106,127],"documentation","documentation writer","writer","https","quality","technical","technical writer","expert","documentation expert","authoring","software","principles","high",{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":141,"publishedAt":43},"01M6QJC0V3C7C4R9768J1AJYWY","doc-coauthoring","Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fwriting\u002Fdoc-coauthoring\u002FSKILL.md",[134,137,138],{"categoryNo":135,"categoryName":136,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":84,"categoryName":85,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":139,"categoryName":140,"taxonomyType":89,"taxonomyTypeDesc":90},"01JBSEEDCAT000000000000036","内容创作者",[142,143,27,144,145,115,146,147,148,149,150,151,56,152,153,124,154,155,105,28],"doc coauthoring","doc","workflow","official","tasks","decision","write","context","proposals","guide","refine","iteration","trigger","co",{"skillNo":157,"name":158,"nameZh":6,"description":159,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":160,"categories":161,"keywords":170,"publishedAt":43},"01M6QJBJ0YPVEWGEXZH3PJRRTT","code-review-workflow","Executes comprehensive 4-phase code review: basic review, quality check, bundle analysis, and test coverage. Should be used when the user mentions comprehensive code review, checking code quality, or reviewing staged changes with multi-phase analysis. This is the comprehensive review workflow, distinct from focused skills like frontend-code-review, staged-code-review, or code-change-test-designer.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Ftesting\u002Fcode-review-workflow\u002FSKILL.md",[162,165,166,167],{"categoryNo":163,"categoryName":164,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000007","代码审查",{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":84,"categoryName":85,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":168,"categoryName":169,"taxonomyType":89,"taxonomyTypeDesc":90},"01JBSEEDCAT000000000000030","开发工程师",[171,172,144,173,174,175,176,23,177,178,179,180,181,182,183,184,185,186,187,188],"code review","review","code","code review workflow","testing","frontend","change","code quality","code-review","analysis","check","coverage","quality check","basic","multi","comprehensive code review","with","phase",{"skillNo":190,"name":191,"nameZh":6,"description":192,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":193,"categories":194,"keywords":204,"publishedAt":43},"01M6QJB7XNHV3VEEQF4W7FMWF6","code-change-test-designer","Analyzes code changes and designs comprehensive test cases. Reads diffs, summarizes capability changes, and designs test cases covering main flows and edge cases. Should be used when the user mentions test coverage, designing tests for code changes, or analyzing diff\u002Fcommit for testing purposes. Distinguished from code-review-workflow which provides comprehensive review, this skill focuses on test case design for code changes.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Ftesting\u002Fcode-change-test-designer\u002FSKILL.md",[195,196,199,200,201],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":197,"categoryName":198,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":84,"categoryName":85,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":168,"categoryName":169,"taxonomyType":89,"taxonomyTypeDesc":90},{"categoryNo":202,"categoryName":203,"taxonomyType":89,"taxonomyTypeDesc":90},"01JBSEEDCAT000000000000032","设计师",[23,177,173,205,206,175,207,208,144,209,179,210,182,211,56,33,212,213,28,188],"designer","code change test designer","design","diffs","commit","edge","diff","flows","which",{"skillNo":215,"name":216,"nameZh":6,"description":217,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":218,"categories":219,"keywords":221,"publishedAt":43},"01M6QJB195WD7DCJWDMKWKB29S","skill-creator","Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fmeta-skills\u002Fskill-creator\u002FSKILL.md",[220],{"categoryNo":84,"categoryName":85,"taxonomyType":20,"taxonomyTypeDesc":21},[222,223,224,225,145,226,227,228,229,230,180,231,232,233,56,234,235,105,28,216],"skill creator","creator","performance","run evals","variance analysis","create","run","benchmark","Meta","improve","edit","evals","optimize","existing skill"]