agentleFS
davision0102davision0102/fabrik/.agents/skills/add-test/SKILL.md

add-test

Skill3 starsChanged 2 days agoMITView on GitHub

Écrire ou corriger un test (Vitest + Testing Library). À utiliser quand on ajoute de la logique, qu'on corrige un bug, ou qu'on demande des tests.

19 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use review-pr, triage and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • DockerSkill

    review-pr

    Review one or more incoming Docker documentation pull requests as a maintainer. Independently validate technical claims, assess editorial fit and information architecture, choose a verdict, and draft exact inline or PR-wide feedback behind a confirmation gate. Use for requests such as "review PR 123", "is this PR correct?", "does this information belong here?", "validate this PR", or "help review backlog PRs". Do not use to maintain or fix a PR you own; use maintain-pr for that.

    Also in 3 projects that use this

  • Google CloudSkill

    triage

    Gather context on a change or bug and plan the implementation.

    Also in 3 projects that use this

  • SentrySkill

    review

    Fixture review skill.

    Also in 3 projects that use this

The file

Files
SKILL.md

Écrire un test

Les tests utilisent Vitest (même configuration que Vite, dans vite.config.ts), jsdom et Testing Library. Les matchers toBeInTheDocument, toHaveClass… sont chargés par src/test/setup.ts.

Où et comment

  • Le fichier de test se place à côté du fichier testé : pricing-card.tsx → pricing-card.test.tsx.
  • Tester ce que voit et fait l'utilisateur, pas l'implémentation : chercher les éléments par rôle et par texte (getByRole('button', { name: 'Envoyer' })), interagir avec userEvent.
  • Un test = un comportement, avec un nom en français qui le décrit.

Modèle

import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { describe, expect, it } from 'vitest'
import { Counter } from './counter'

describe('Counter', () => {
  it('augmente la valeur au clic', async () => {
    const user = userEvent.setup()
    render(<Counter />)

    await user.click(screen.getByRole('button', { name: 'Ajouter' }))

    expect(screen.getByText('1')).toBeInTheDocument()
  })
})

Exemples réels dans le projet : src/components/theme-toggle.test.tsx, src/components/copy-command.test.tsx.

Lancer

  • npm test : une fois (c'est ce que lance la CI).
  • npm run test:watch : en continu pendant le développement.

Pour une correction de bug

Écrire d'abord le test qui reproduit le bug et vérifier qu'il échoue, puis corriger : le test garantit que le bug ne reviendra pas.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.