frontend-testing
БесплатноБез исполняемых скриптовНе проверенUSE WHEN testing non-React UI (vanilla JavaScript or TypeScript DOM code, a web component, or a Vue, Svelte or Angular component) with DOM Testing Library in…
от mintuz★ 38 звёзд на GitHubОб этом скилле
Front-end testing with DOM Testing Library
Write behaviour-first DOM Testing Library tests for UI built without React. For React components, hooks and providers, load web:react-testing. For the TDD workflow, load tdd.
Scope
This skill covers tests that run against a DOM inside a test runner, such as Vitest or Jest with jsdom. Decline these parts of a request:
- End-to-end and cross-page journeys: cross-document navigation, redirects, real servers, downloads, extra browser tabs, and real cookie behaviour such as
HttpOnly,SecureandSameSite. Reasons: jsdom does not navigate between documents or open real tabs. A real server sets anHttpOnlycookie, and page scripts cannot read it, sodocument.cookiein jsdom cannot prove it. Exception: jsdom holds a URL and a cookie jar, so a client-side URL ordocument.cookiecheck inside one document is in scope. - Visual appearance: computed layout, real fonts, screenshots and visual-regression diffs. Reason: jsdom does not lay out or paint, so it cannot report a size, a position or a rendered colour.
To decline (principle-state-the-scope):
- For each declined part, write its reason from the list above. A named replacement tool is not a reason.
- Name the replacement: Playwright or Cypress for a journey; a screenshot or visual-regression comparison in a real browser for appearance.
- Offer the part of the request that fits in the DOM, if any.
Do not offer a jsdom test that fakes the navigation, the server or the rendering as an equivalent.
@testing-library/dom exports no render. Mount the markup yourself. When a framework wrapper such as @testing-library/vue supplies render, mount through it; this skill still governs the queries and the interactions.
Use the project's test libraries
Use the runner, matchers, network stub and helpers the project already has. Do not add a testing dependency or a lint plugin unasked (principle-reuse-before-building).
- Interactions: Use
userEventfrom@testing-library/user-event, created withuserEvent.setup()in each test. UsefireEventonly for an event thatuserEventdoes not support, or when the project shows thatuser-eventis not installed. In the second case, say thatuser-eventwould model the interaction more closely. - Matchers: Use jest-dom matchers such as
toBeInTheDocument()andtoBeDisabled(). Only when the project shows that its setup does not register jest-dom, assert absence withtoBeNull(), text withtextContent, and state with the element's own property, such asdisabled. - Network: Use the project's existing stub: its MSW
serverand handlers, otherwise its own stub helper. Override an MSW handler for one test withserver.use(...). When the project has an MSW server, do not add afetchoraxiosspy. When the code receives its request function by injection, pass a mock for that function. - Lint: When
eslint-plugin-testing-libraryandeslint-plugin-jest-domare missing, recommend them. Install them only when asked.
Test behaviour, not implementation
Test what users see and do through the DOM: clicks, typing and visible text (principle-test-behavior-not-implementation). For each assertion, ask which plausible wrong implementation would still pass. Write the assertion that fails on it.
Mount the real component under test. Let it own its markup and event wiring. Do not read or set its internal state. Do not write your own listener and then assert that it ran. Return a runnable test that imports the code under test. When the task does not give the module path, import from an assumed path beside the test file and say that the path is assumed.
Queries and interactions
- Choose the variant by timing:
getBy*for state already present,findBy*for state that appears later,queryBy*for absence. - Query through
screen. Usewithin(element)to scope a query to one region. Do not bind queries to a container, for example withgetQueriesForElement. Do not use a CSS class selector when an accessible query reaches the element. - Re-query an element by its new role or accessible name when you must prove it is discoverable under that identity, or when the update can replace the node. An existing reference stays valid when the same node is reused.
- Interact once, outside
waitForand every other retrying callback. Put only assertions inside a retrying callback. - Wait for an observable state with
findBy*orwaitFor. Do not put a fixed delay in place of that wait, such assetTimeout, a sleep promise or a fake-timer advance. - Reset markup that you mounted into
document.bodyyourself between tests, for example withdocument.body.innerHTML = ''inafterEach. Do not callcleanup()in a test file.
Accessible names come from the markup
A role query's name option matches the accessible name, not the text. These roles take a name only from aria-label or aria-labelledby, never from their conte
Установить frontend-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл frontend-testing?
USE WHEN testing non-React UI (vanilla JavaScript or TypeScript DOM code, a web component, or a Vue, Svelte or Angular component) with DOM Testing Library in Vitest or Jest with jsdom: writing, fixing or reviewing a test, or a request to add an end-to-end journey or a layout check to that suite; NOT WHEN the code or project uses React or React Testing Library (use web:react-testing), for XState actors (web:xstate), or for Playwright, Cypress or screenshot-comparison work in a real browser; covers queries, accessible names, userEvent, async results, network stubs and assertions that pass for the wrong reason, and declines what jsdom cannot prove while offering the part that fits.
Как установить скилл frontend-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл frontend-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic