CtrlK
BlogDocsLog inGet started
Tessl Logo

pantheon-ai/test-driven-development

Master Test-Driven Development with deterministic red-green-refactor workflows, test-first feature delivery, bug reproduction through failing tests, behavior-focused assertions, and refactoring safety; use when implementing new functions, changing APIs, fixing regressions, or restructuring code under test.

Does it follow best practices?

Evaluation86%

1.05x

Agent success when using this tile

Validation for skill structure

Overview
Skills
Evals
Files

assert-specific-assertions.mdreferences/

title:
Use Specific Assertions
impact:
MEDIUM
impactDescription:
2-5× faster debugging from better failure messages
tags:
assert, specific, matchers, clarity

Use Specific Assertions

Use the most specific assertion available for the check. Specific assertions provide better failure messages and document expected behavior more clearly.

Incorrect (generic assertions):

test('filters active users', () => {
  const users = [
    { id: '1', active: true },
    { id: '2', active: false }
  ]

  const result = filterActiveUsers(users)

  // Generic - failure message: "expected true to be false"
  expect(result.length === 1).toBe(true)
  expect(result[0].id === '1').toBe(true)
})

test('user has expected properties', () => {
  const user = getUser('123')

  // Generic - unhelpful failure message
  expect(user !== null).toBe(true)
  expect(typeof user.email === 'string').toBe(true)
})

Correct (specific assertions):

test('filters active users', () => {
  const users = [
    { id: '1', active: true },
    { id: '2', active: false }
  ]

  const result = filterActiveUsers(users)

  // Specific - failure: "expected [array] to have length 1, got 0"
  expect(result).toHaveLength(1)
  // Specific - failure: "expected {id: '2'} to match {id: '1'}"
  expect(result[0]).toMatchObject({ id: '1' })
})

test('user has expected properties', () => {
  const user = getUser('123')

  // Specific - failure: "expected null not to be null"
  expect(user).not.toBeNull()
  // Specific - failure: "expected 123 to be a string"
  expect(user.email).toEqual(expect.any(String))
})

Preferred matchers:

  • toHaveLength() over .length === n
  • toContain() over includes() === true
  • toMatchObject() over checking each property
  • toThrow() over try/catch with boolean
  • toBeGreaterThan() over > comparison === true

Reference: Jest Expect API

Install with Tessl CLI

npx tessl i pantheon-ai/test-driven-development

SKILL.md

tile.json