skills/testing-javascript/SKILL.md
Testing Trophy philosophy for JS/TS. Use when: writing tests, deciding what/how to test, reviewing tests, choosing unit/integration/E2E, mocking decisions. Triggers: "write tests", "what should I test", "test this component", "review my tests", "testing strategy", "mock this", "test setup".
npx skillsauth add silvabyte/skills testing-javascriptInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
"Write tests. Not too many. Mostly integration." -- Guillermo Rauch
These principles are tool-agnostic. They apply whether you use Jest, Vitest, Playwright, Cypress, or any other testing tool.
Favor integration tests. They give the best confidence-to-cost ratio.
From bottom to top:
See references/testing-trophy.md for detailed guidance on choosing the right layer.
Test what users experience, not internal state, props, or method calls. If you refactor and tests break but behavior didn't change, the tests were wrong.
Do: Assert on visible output, screen text, HTTP responses, return values. Don't: Assert on internal state, component instance methods, or how many times a private function was called.
Use accessibility-first queries. This order applies to any DOM testing tool:
getByRole -- mirrors assistive technology, most robustgetByLabelText -- great for form inputs, ensures labels existgetByText -- visible text, good for buttons/linksgetByPlaceholderText, getByDisplayValue -- secondarygetByTestId -- last resort, not user-visibleSee references/query-priorities.md for rationale.
Mock at system boundaries: network, timers, randomness, third-party services. Don't mock what you own unless necessary. Over-mocking makes tests brittle and hides real bugs.
msw or similar for network mocking over mocking fetch directlySee references/mocking-guide.md for patterns and anti-patterns.
Don't chase 100%. Use coverage to find untested critical paths, not as a target. High coverage with bad tests gives false confidence.
Each test sets up its own state and cleans up after itself. No test should depend on another test's side effects. Use beforeEach/afterEach for shared setup, but keep test-specific setup in the test itself.
When deciding what to test, think through these questions (internally, not as a workflow):
This produces tests that verify real behavior and catch real regressions.
| Situation | Approach | |---|---| | Pure function / utility | Unit test | | Component rendering + user interaction | Integration test | | Multiple components working together | Integration test | | Form submission to API | Integration test (mock network) | | Critical user workflow (checkout, auth) | E2E test | | Styling / layout | Static analysis or visual regression | | Type safety | TypeScript strict mode | | Code style | ESLint + Prettier |
See references/glossary.md for definitions of assertion, mock, spy, stub, test double, and other testing terms.
tools
Weekend Business Shared Drive: Browse, search, upload, and manage files. Triggers: 'weekend business drive', 'wb drive', 'upload to brand', 'shared drive', 'WB shared drive', 'list WB files', 'find in drive'
documentation
--- name: unglaze description: Rewrite glazy, eye-glazing generated content into a tight, scannable, bullet-tight engineering voice. Use when the user says "unglaze", "ungloss this", "punch this up", "tighten this", "less glazy", "eyes glaze", "make my eyes not glaze", "cut the fluff", "rewrite punchier", "make it sharper", "less corporate", "de-fluff", "less LLM-flavored". Also auto-triggers on dissatisfaction signals like "ugh too long", "tldr this", "this is boring", "too much". Applies to PR
content-media
Transcribe audio and video files using Audetic whisper service. Use when: (1) User wants to transcribe an audio or video file (2) User has a recording and needs a text transcript (3) User wants transcript analysis (gaps, speech rate, silence detection) (4) User wants to transcribe all media files in a directory Triggers: "transcribe", "transcription", "transcript", "speech to text", "audio to text", "transcribe audio", "transcribe video", "transcribe recording"
tools
Drive a UI flow with chrome-devtools, capture a screenshot per step, then render a self-contained HTML report (report.html) showing each step with status pills, full console log, and full network log per step. Use when: (1) User asks to "QA this flow", "walk through X with screenshots", "verify [feature] end-to-end with a report" (2) User wants screenshot-backed evidence that a multi-step UI flow worked (3) User wants a single artifact they can attach to a PR or share as proof of a manual walkthrough Do NOT use for one-off "open this page and check console", for automated regression testing (a Playwright/Cypress suite is the right tool), or for single-screenshot bug repros. Triggers: "QA this flow", "qa flow report", "walk through X with screenshots", "verify end-to-end with a report", "screenshot-backed evidence", "manual QA report"