testing-patterns
Skill0 starsChanged 8 months agoMITView on GitHub
Patterns de tests Fidely : Vitest + @nuxt/test-utils + fake-indexeddb + happy-dom. Déclencher quand : écriture de test, ajout composable (useDB, useClient), nouveau composant Vue, modification d'une fonction dans utils/, isolation IndexedDB, mock Nuxt (useToast, navigateTo). Mots-clés : describe, it, expect, beforeEach, IDBFactory, resetDB, mountSuspended, mockNuxtImport, fake-indexeddb, useDB.test.ts, CardItem.test.ts, CardForm.test.ts, updatePoints, consumeReward, addCard, getOrCreateClientId.
- Installs packages
44 other projects use a version of this.
Adopted by
Most recently taken up by
- xsovad06/sovatheir own version, first seen Nov 8, 2026
- gopalparashar421/agent-skillstheir own version, first seen Nov 8, 2026
- soilmass/motion-design-agenttheir own version, first seen Nov 8, 2026
- seandkendall/kiro-configtheir own version, first seen Nov 1, 2026
- svngoku/coding-agents-skillstheir own version, first seen Nov 1, 2026
- piomin/claude-ai-spring-boottheir own version, first seen Oct 25, 2026
Used with
Projects with it also use intelligent-routing, bash-linux and 10 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.
SKB3002Skillintelligent-routing
Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.
Also in 5 projects that use this
xenitV1Skillbash-linux
Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.
Also in 6 projects that use this
xenitV1Skillred-team-tactics
Red team tactics principles based on MITRE ATT&CK. Attack phases, detection evasion, reporting.
Also in 6 projects that use this
ChrisWilesSkillformik-patterns
Formik form handling with validation patterns. Use when building forms, implementing validation, or handling form submission.
Also in 3 projects that use this
SKB3002Skillnextjs-react-expert
React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations.
Also in 3 projects that use this
adybaSkillsafe-workflow
SAFe Agentic Workflow orchestrator. Teaches the full SAFe methodology adapted for AI agents: pattern discovery, exit states, quality gates, agent personas, and specs-driven development. Use when setting up a project with SAFe workflow, understanding the multi-agent methodology, or coordinating work across agent personas. Triggers: "SAFe workflow", "agent workflow", "safe harness", "specs-driven", "exit states", "quality gates", "multi-agent workflow".
Also in 3 projects that use this
- +4 more from xenitV1
Other versions44 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 44
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- ChrisWiles/claude-code-showcase★ 6.1ksame name
- ag2ai/faststream★ 5.4ksame name
- piomin/claude-ai-spring-boot★ 1.4ksame name
- bybren-llc/safe-agentic-workflow★ 405same name
- dilolabs/nosia★ 211same name
- xenitV1/Antigravity-Workflows★ 130same name
- langchain-ai/skills-benchmarks★ 116same name
- leather-io/mono★ 28same name
34 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- nuxt-uiSkill
- coding-standardsSkill
- nuxt-standardsSkill
- security-checksSkill
- specs-checkerSkill
- vue-componentSkill
The file
Files
Skill : Écrire et exécuter des tests pour Fidely
Ressources disponibles
templates/composable.test.ts— template complet pour tester un composable IndexedDBtemplates/component.test.ts— template complet pour tester un composant Vuereference/test-examples.md— exemples réels tirés des tests du projet
Règles obligatoires
Toujours lancer les tests après toute modification de code
pnpm vitest run # lancer tous les tests
pnpm vitest run app/composables/useDB.test.ts # lancer un fichier spécifiqueToute nouvelle feature doit être accompagnée de tests :
- Nouveau composable ou nouvelle fonction → fichier
.test.tsco-localisé dansapp/composables/ - Nouveau composant avec logique → fichier
.test.tsco-localisé dansapp/components/ - Nouvelle règle métier → test du cas nominal + cas limite
Quand lancer les tests :
- Après chaque modification d'un composable (
useDB.ts,useClient.ts) - Après chaque modification d'un composant (
CardItem.vue,CardForm.vue) - Après chaque ajout ou modification d'une fonction dans
utils/ - Avant de marquer une tâche comme ✅ dans
TASKS.md
Seuil d'acceptation :
- 0 test en échec — jamais valider une tâche avec des tests rouges
- Si un test échoue suite à un changement intentionnel, mettre à jour le test en même temps que le code
Setup (déjà configuré)
pnpm add -D @nuxt/test-utils vitest @vue/test-utils fake-indexeddb happy-domvitest.config.ts à la racine :
import { defineVitestConfig } from '@nuxt/test-utils/config'
export default defineVitestConfig({
test: {
environment: 'nuxt',
setupFiles: ['./app/setup.ts'] // ← app/setup.ts (pas setup.test.ts)
}
})app/setup.ts :
import 'fake-indexeddb/auto'Structure des fichiers de test
Les tests sont co-localisés avec les sources — même dossier que le fichier testé, suffixe .test.ts :
app/
├── composables/
│ ├── useDB.ts
│ ├── useDB.test.ts ← test co-localisé
│ ├── useClient.ts
│ └── useClient.test.ts
├── components/
│ ├── CardItem.vue
│ ├── CardItem.test.ts ← test co-localisé
│ ├── CardForm.vue
│ └── CardForm.test.ts
└── utils/
├── uuid.ts
└── uuid.test.tsNe jamais créer de dossier
tests/séparé — les tests vivent à côté du code qu'ils testent.
Isolation IndexedDB entre les tests
Obligatoire : créer une nouvelle instance IDBFactory dans beforeEach pour que chaque test parte d'une DB vide :
import { IDBFactory } from 'fake-indexeddb'
import { resetDB } from '~/composables/useDB'
beforeEach(() => {
globalThis.indexedDB = new IDBFactory()
resetDB() // reset le cache de connexion dans useDB.ts
})Ne jamais appeler
indexedDB.deleteDatabase()— cette API est asynchrone et peut provoquer des timeouts si non attendue correctement.
Pattern pour tester les composables (useDB, useClient)
import { describe, it, expect, beforeEach } from 'vitest'
import { IDBFactory } from 'fake-indexeddb'
import { resetDB, useDB } from '~/composables/useDB'
beforeEach(() => {
globalThis.indexedDB = new IDBFactory()
resetDB()
})
describe('getAllCards', () => {
it('retourne un tableau vide par défaut', async () => {
const { getAllCards } = useDB()
const cards = await getAllCards()
expect(cards).toEqual([])
})
})
describe('updatePoints', () => {
it('ne descend jamais en dessous de 0', async () => {
const { addCard, updatePoints } = useDB()
const card = await addCard({ title: 'T', reward_points: 5, reward: 'R' })
const points = await updatePoints('client-1', card.id, -99)
expect(points).toBe(0)
})
})Pattern pour tester les composants Vue
import { describe, it, expect } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import CardItem from '~/components/CardItem.vue'
import type { Card } from '~/composables/useDB'
const card: Card = {
id: 'card-1',
title: 'Carte café',
reward_points: 10,
reward: '1 café offert',
created_at: Date.now()
}
describe('CardItem — merchant mode', () => {
it('affiche le titre', async () => {
const wrapper = await mountSuspended(CardItem, {
props: { card, merchantMode: true }
})
expect(wrapper.text()).toContain('Carte café')
})
it('émet deleted avec le cardId au clic supprimer', async () => {
const wrapper = await mountSuspended(CardItem, {
props: { card, merchantMode: true }
})
await wrapper.find('[aria-label="Supprimer"]').trigger('click')
expect(wrapper.emitted('deleted')?.[0]).toEqual(['card-1'])
})
})Structure describe / it standardisée
describe('NomDuSujet')
describe('nomDeLaFonction ou contexte')
it('fait X dans le cas normal')
it('gère le cas limite Y')
it('lance une erreur si Z')Phrases it : toujours en anglais, décrivent le comportement attendu (pas l'implémentation).
Cas à toujours couvrir
Composables :
- Happy path (cas nominal)
- Valeurs limites (0 points, tableau vide, client inexistant)
- Comportement idempotent (appels multiples retournent le même résultat)
- Erreurs attendues (
rejects.toThrow(...))
Composants :
- Rendu avec les props minimales
- Chaque emit déclenché par l'action utilisateur correspondante
- États désactivés / conditionnels (
:disabled,v-if) - Props optionnelles non fournies (comportement par défaut)
Mocking des APIs Nuxt
// useToast et navigateTo sont auto-mockés par @nuxt/test-utils dans l'environment 'nuxt'
// Pas besoin de mock manuel dans la plupart des cas
// Si besoin de vérifier un appel toast ou navigateTo :
import { mockNuxtImport } from '@nuxt/test-utils/runtime'
const toastMock = vi.fn()
mockNuxtImport('useToast', () => () => ({ add: toastMock }))Confirmation en fin de tâche
✅ testing-patterns appliqués
- Isolation : [beforeEach IDBFactory + resetDB en place]
- Couverture : [happy path + cas limite + erreurs attendues]
- Structure : [describe/it en anglais, comportemental]
- Résultat : [pnpm vitest run → 0 test en échec]
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
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.

