# Testing Conventions > Nota interna del proyecto no-mistakes. Se usa al añadir o cambiar tests, el harness e2e, el aislamiento de procesos de test o el sharding de tests en CI. Fuente: https://skillsagentes.com/skills/kunchenguid/no-mistakes/testing-conventions Markdown: https://skillsagentes.com/skills/kunchenguid/no-mistakes/testing-conventions.md Repositorio: https://github.com/kunchenguid/no-mistakes Autor: kunchenguid Licencia: MIT Actualizado: anteayer Coste de contexto: 24 tok instalada, 1.1k tok al activarse, 1.1k tok con todos los archivos del bundle Bundle: 1 archivo, 4 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add kunchenguid/no-mistakes --skill testing-conventions --agent claude-code # Cursor npx -y skills add kunchenguid/no-mistakes --skill testing-conventions --agent cursor # Codex npx -y skills add kunchenguid/no-mistakes --skill testing-conventions --agent codex # Gemini CLI npx -y skills add kunchenguid/no-mistakes --skill testing-conventions --agent gemini # Windsurf npx -y skills add kunchenguid/no-mistakes --skill testing-conventions --agent windsurf # Cline npx -y skills add kunchenguid/no-mistakes --skill testing-conventions --agent cline ``` ## Qué hace - Se prefieren tests e2e para el comportamiento que cruza un límite de proceso o de I/O y unit tests para helpers puros; se prefieren repos git reales en directorios temporales antes que mocking pesado. - La suite e2e está tras el build tag `e2e`; `make e2e` corre `scripts/e2e.sh`, que barre `./internal/e2e/...` y `./internal/pipeline/steps/...`. - Los daemons e2e temporales los posee `internal/e2edaemon` con inventario exacto, cap de concurrencia y reapers; nunca se apunta el reaping de inventario al servicio compartido `~/.no-mistakes`. - `paths.New()` rechaza el root por defecto `~/.no-mistakes` bajo `go test`; los tests que tocan estado de app deben poner `NM_HOME` a un directorio temporal. - Un archivo `*_windows_test.go` compila solo en esa plataforma por la restricción implícita de GOOS, así que los tests agnósticos sobre Windows se nombran de otra forma; la pierna de CI de Windows se reparte en shards. ## Cuándo usarla - Se añaden o cambian tests, el harness e2e, el aislamiento de procesos de test o el sharding de tests en CI. ## Qué la activa - "Voy a añadir un test e2e nuevo en no-mistakes" - "Revisa el aislamiento de NM_HOME en los tests" - "Cambia el sharding de los tests de Windows en CI" ## Archivos - SKILL.md — 4 KB ## SKILL.md Reproducido tal cual desde kunchenguid/no-mistakes bajo MIT. Esta sección es el documento original y está en inglés. **Testing Conventions** - Prefer e2e tests for behavior that crosses a process or I/O boundary (CLI flags, config loading, git operations, agent spawning, daemon coordination, stdout/stderr, recorded fixtures); unit-test pure helpers where speed and failure localization matter. Prefer creating real git repos in temp dirs over heavy mocking. - The e2e suite is behind the `e2e` build tag; `make e2e` runs `scripts/e2e.sh`, which sweeps `./internal/e2e/...` and `./internal/pipeline/steps/...`, so keep new step-local e2e tests behind the tag too. - Temporary e2e daemons (`NM_TEST_START_DAEMON=1` / harness) are owned by `internal/e2edaemon`: exact inventory, concurrency cap (`NM_E2E_DAEMON_MAX`, default 2), bounded argv checks, and reapers in harness Cleanup, package `TestMain`, and `scripts/e2e.sh` EXIT/INT/TERM. A SIGKILL of the wrapper shell does not run its trap; next-run inventory recovery covers that. External sleep-loop keepalives are out of scope. Never point inventory reaping at the shared `~/.no-mistakes` service. Regressions: `internal/e2edaemon/*_test.go`. - Packages whose tests shell out to git unset `GIT_CONFIG_COUNT` in `TestMain` so ambient `GIT_CONFIG_*` injection from agent harnesses cannot leak in; a test exercising injected config re-sets it with `t.Setenv` (see `internal/git`, `internal/gate`, `internal/daemon`, `internal/pipeline/steps`, `internal/pipeline/steps/citest`). - Packages whose tests can start a daemon or touch ambient state (`cmd/no-mistakes`, `internal/cli`, `internal/update`) use a package-wide `TestMain` that points `NM_HOME` and `HOME` at fresh temp dirs and disables telemetry/update-check env vars, so a full test run never touches a real `~/.no-mistakes`. Follow the same pattern in new such packages. - `paths.New()` refuses the default `~/.no-mistakes` root under `go test`; tests that touch app state must set `NM_HOME` to a temp dir, and only the production-default path test may opt in with `NO_MISTAKES_ALLOW_DEFAULT_ROOT_IN_TESTS=1`. - Isolate filesystem and environment state with `t.TempDir()` and `t.Setenv()`. - Pipeline-step tests put a tiny non-race helper (`internal/pipeline/fakecli`, built once by `stepstest.Init`) on PATH as `gh`/`glab`/`git`. Never re-link the race-instrumented test binary as those names. - The Windows CI leg is process-spawn bound, not compute bound: git-backed packages cost roughly 10x their Linux time (`internal/git` 5.7s -> 53s, `internal/branchsync` 31s -> 415s). The Windows matrix is split into a git-heavy shard and a core remainder so each job's wall stays inside `timeout-minutes: 40` and a hang still surfaces as `go test -timeout` (15m) rather than an evidence-free job cancel. Keep long git-heavy packages off the serial critical path (`internal/branchsync` runs `t.Parallel()` for exactly that reason) and keep the Defender scan-exclusion step in `ci.yml`, whose comment owns the rationale. The git-heavy shard runs `./internal/pipeline/steps/...` so CI-monitor tests in `steps/citest` stay on that shard. Regressions: `TestCIWorkflow_WindowsTestsRunWithScanExclusions`, `TestCIWorkflow_WindowsHangSurfacesAsGoTimeoutNotJobCancellation`. - Go applies an implicit GOOS constraint from a filename suffix, so a test file named `*_windows_test.go` (or `_linux`, `_darwin`) silently compiles only on that platform. Name platform-agnostic tests about Windows something else. - On macOS a git-heavy package under `-race` intermittently reports `git : signal: segmentation fault`. That is not a git or repo bug: `~/Library/Logs/DiagnosticReports/*.ips` records the crash as `procName: .test, parentProc: .test, asi: "crashed on child side of fork pre-exec"` - the forked child dies before `execve`. Confirm there before chasing it in Go code; the CI legs are Linux and Windows. The same fork mechanic explains a stray `.test -test.timeout=...` process at high CPU that appears to ignore its own deadline: a pre-exec child inherits the parent's name, argv, and cwd, so it is not a running test binary and no test-side timeout applies to it. `internal/procreap` reaps those by cwd. ## Dónde encaja - Categoría: [Testing y QA](https://skillsagentes.com/categorias/testing-qa.md) — Flujos de testing unitario, de integración y end-to-end. - Creador: [kunchenguid](https://skillsagentes.com/creators/kunchenguid.md) — 16 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [No Mistakes](https://skillsagentes.com/skills/kunchenguid/no-mistakes/no-mistakes.md): Valida tus cambios de código por el pipeline de no-mistakes (review de código automatizado, tests, lint, docs, push, PR y CI) antes de que lleguen al destino de push configurado. Se activa con `/no-mistakes`. - [Pipeline Review And Agents](https://skillsagentes.com/skills/kunchenguid/no-mistakes/pipeline-review-and-agents.md): Nota interna del proyecto no-mistakes. Se usa al cambiar las sesiones de review, las decisiones sobre findings, los timeouts de agente, el comportamiento del Test local o la conformidad con la intención. - [Ci Monitor](https://skillsagentes.com/skills/kunchenguid/no-mistakes/ci-monitor.md): Nota interna del proyecto no-mistakes. Se usa al cambiar la readiness de CI, la recogida de checks del forge, los reruns, los timeouts de CI o la monitorización del ciclo de vida del PR. - [Pr Publication Safety](https://skillsagentes.com/skills/kunchenguid/no-mistakes/pr-publication-safety.md): Nota interna de seguridad del proyecto no-mistakes. Se usa al cambiar el render del cuerpo del PR, la redacción de rutas de home, la publicación de rutas de artefacto o los marcadores de attestation de pipeline. - [Test Evidence Storage](https://skillsagentes.com/skills/kunchenguid/no-mistakes/test-evidence-storage.md): Nota interna del proyecto no-mistakes. Se usa al cambiar la recogida de evidencia de test, su publicación en una rama huérfana, sus rutas bajo el app root, la retención o la limpieza del scratch. ## Skills relacionadas - [Systematic Debugging](https://skillsagentes.com/skills/obra/superpowers/systematic-debugging.md): Úsalo ante cualquier bug, fallo de test o comportamiento inesperado, antes de proponer arreglos. - [Tdd](https://skillsagentes.com/skills/mattpocock/skills/tdd.md): Desarrollo guiado por tests. Úsalo cuando quieras construir features o arreglar bugs test-first, cuando menciones "red-green-refactor", o cuando quieras tests de integración. - [Migrate To Shoehorn](https://skillsagentes.com/skills/mattpocock/skills/migrate-to-shoehorn.md): Migra archivos de test de aserciones de tipo `as` a @total-typescript/shoehorn. Úsalo cuando menciones shoehorn, quieras reemplazar `as` en tests, o necesites datos de test parciales. - [Webapp Testing](https://skillsagentes.com/skills/anthropics/skills/webapp-testing.md): Kit para interactuar con aplicaciones web locales y probarlas con Playwright. Permite verificar el frontend, depurar la UI, capturar pantallazos del navegador y ver sus logs. - [Sandbox Bench](https://skillsagentes.com/skills/vercel/next.js/sandbox-bench.md): Compara el rendimiento de cambios de React o Next.js en VMs de Vercel Sandbox con estadística A/B pareada: rps, latencia, p95, TTFB, RSS y bytes de documento y Flight. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)