Testing Guide

Comprehensive testing strategies for the Refresh App Web.

Test Setup

Framework: Vitest 3.2 Component Testing: @testing-library/svelte 5.2 Environment: jsdom (client), node (server)

Configuration: vite.config.ts

test: {
	workspace: [
		{
			name: 'client',
			environment: 'jsdom',
			include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
			exclude: ['src/lib/server/**'],
			setupFiles: ['./vitest-setup-client.ts']
		},
		{
			name: 'server',
			environment: 'node',
			include: ['src/**/*.{test,spec}.{js,ts}'],
			exclude: ['src/**/*.svelte.{test,spec}.{js,ts}']
		}
	];
}

Running Tests

Component Testing

Example test file: Button.svelte.test.ts

Server-Side Testing

Test load functions:

Best Practices

  1. Test user behavior, not implementation

  2. Use semantic queries (getByRole, getByLabelText)

  3. Mock external dependencies

  4. Keep tests isolated

  5. Run tests before committing


Last updated: October 2025

Last updated