Index of every page on this site: llms.txt
All skills
fubits1 avatar

/testing-svelte

@a024d57
by Iljafubits1/svelte-skills11 stars
2
Run it yourself

Fix or write Svelte 5 tests with vitest-browser-svelte and Playwright. Use when debugging broken or flaky tests, 'Cannot connect to the iframe', strict mode violations, or writing unit/SSR/e2e tests.

Use this Skill: https://skilld.dev/gh/fubits1/svelte-skills/testing-svelte

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesfoundation-first.md

≈691 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Foundation-First Test Coverage

Foundation First Methodology

Aim for 100% test coverage by planning comprehensive test structure before implementation.

Step 1: Create Test Structure with .skip

// form.svelte.test.ts
import { test, describe } from 'vitest';

describe('ContactForm', () => {
	describe('Initial Rendering', () => {
		test.skip('renders with default props', () => {});
		test.skip('renders all form fields', () => {});
		test.skip('has proper ARIA labels', () => {});
	});

	describe('Form Validation', () => {
		test.skip('validates email format', () => {});
		test.skip('requires all fields', () => {});
		test.skip('shows validation errors', () => {});
		test.skip('validates on blur', () => {});
	});

	describe('User Interactions', () => {
		test.skip('handles input changes', () => {});
		test.skip('clears form on reset', () => {});
		test.skip('disables submit when invalid', () => {});
	});

	describe('Edge Cases', () => {
		test.skip('handles empty submission', () => {});
		test.skip('handles server errors', () => {});
		test.skip('shows loading state', () => {});
	});

	describe('Accessibility', () => {
		test.skip('supports keyboard navigation', () => {});
		test.skip('announces errors to screen readers', () => {});
	});
});

Step 2: Implement Tests Incrementally

Remove .skip as you implement each test:

import { describe, expect, test } from 'vitest';
import { page, userEvent } from 'vitest/browser';
import { render } from 'vitest-browser-svelte';
import ContactForm from './ContactForm.svelte';

describe('ContactForm', () => {
	describe('Initial Rendering', () => {
		test('renders with default props', async () => {
			await render(ContactForm);

			// exact accessible names: checks the labels, not just "something rendered"
			await expect
				.element(page.getByRole('textbox', { name: 'Email' }))
				.toBeInTheDocument();
			await expect
				.element(page.getByRole('textbox', { name: 'Message' }))
				.toBeInTheDocument();
			await expect
				.element(page.getByRole('button', { name: 'Send message' }))
				.toBeInTheDocument();
		});

		test.skip('renders all form fields', () => {});
		// Continue implementing...
	});

	// a file of render-only tests proves nothing: implement an interaction early
	describe('Form Validation', () => {
		test('validates email format on blur', async () => {
			await render(ContactForm);
			const email = page.getByRole('textbox', { name: 'Email' });

			await email.fill('not-an-email');
			await userEvent.tab(); // blur

			await expect.element(email).toHaveAttribute('aria-invalid', 'true');
			await expect
				.element(page.getByText('Enter a valid email address'))
				.toBeInTheDocument();
		});
	});
});

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill provides comprehensive instructions and best practices for testing Svelte 5 applications using Vitest and Playwright. It covers unit, SSR, and E2E testing, with a focus on resilient locators, accessibility, and the use of real web API objects like FormData and Request. No security issues were detected.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at a024d57. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated last month
user-invocable
true

README badge

README badge for fubits1/svelte-skills/testing-svelte