component-testing-patterns

Component Testing Patterns

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "component-testing-patterns" with this command: npx skills add spences10/devhub-crm/spences10-devhub-crm-component-testing-patterns

Component Testing Patterns

Quick Start

import { page } from 'vitest/browser'; import { render } from 'vitest-browser-svelte';

render(Button, { label: 'Click' }); await page.getByRole('button', { name: 'Click' }).click(); await expect.element(page.getByRole('button')).toBeInTheDocument();

Core Principles

  • Locators, never containers: page.getByRole() auto-retries

  • Semantic queries: getByRole() , getByLabelText() for accessibility

  • Await assertions: await expect.element(el).toBeInTheDocument()

  • Real browsers: Tests run in Playwright, not jsdom

Common Patterns

  • Locators: page.getByRole('button') , .first() , .nth(0) , .last()

  • Interactions: await input.fill('text') , await button.click()

  • Runes: Use .test.svelte.ts files, flushSync() , untrack()

  • Files: *.svelte.test.ts (browser), *.ssr.test.ts (SSR), *.test.ts (server)

References

  • setup-configuration.md - Complete Vitest browser setup

  • testing-patterns.md - Comprehensive testing patterns

  • locator-strategies.md - Semantic locator guide

  • troubleshooting.md - Common issues and fixes

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

auth-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

reactive-ui-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

techdebt-finder

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

terminal-optimization

No summary provided by upstream source.

Repository SourceNeeds Review