Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

SvelteKit docs
SvelteKit
Getting Started with SvelteKitProject StructureCore ConceptsData and StateTestingBuilding and Deployment
Discussions

SvelteKit guide · 5/6

Testing

SvelteKit projects are usually tested with two tools. Vitest, which shares your Vite configuration, covers functions and components, while Playwright checks that the whole app works in a real browser.

Adding the test tools

The sv add-ons set up both tools in one go.

npx sv add vitest playwright

npm run test:unit   # Vitest
npm run test:e2e    # Playwright

The vitest add-on installs the packages, adds package.json scripts and writes a Vite test configuration that runs server and client code separately. What it generates can change between sv releases, so open vite.config.ts and package.json afterwards to see what you got. The examples below follow the setup described in the official Svelte docs: jsdom with Testing Library.

Unit testing plain functions

Pure functions in src/lib can be imported and tested directly. Test files usually sit next to the code they test, named *.test.ts or *.spec.ts.

// src/lib/price.ts
export function formatPrice(cents: number) {
  return `$${(cents / 100).toFixed(2)}`;
}

// src/lib/price.test.ts
import { describe, expect, it } from 'vitest';
import { formatPrice } from './price.js';

describe('formatPrice', () => {
  it('formats cents as dollars', () => {
    expect(formatPrice(1250)).toBe('$12.50');
  });
});

Testing code that uses runes

Runes such as $state are only compiled inside .svelte and .svelte.ts files. To test logic that uses them, name the test file *.svelte.test.ts.

// src/lib/counter.svelte.ts
export function createCounter() {
  let count = $state(0);
  const double = $derived(count * 2);
  return {
    get count() { return count; },
    get double() { return double; },
    increment() { count += 1; }
  };
}
// src/lib/counter.svelte.test.ts
import { expect, test } from 'vitest';
import { createCounter } from './counter.svelte.js';

test('double follows count', () => {
  const counter = createCounter();
  expect(counter.double).toBe(0);

  counter.increment();
  expect(counter.count).toBe(1);
  expect(counter.double).toBe(2);
});

When the code under test uses $effect, wrap the test body in $effect.root, and call flushSync() from svelte to run pending effects synchronously.

Component tests

Render components in a jsdom environment with Testing Library, and query elements the way users see them: by role and by text.

npm install -D jsdom @testing-library/svelte @testing-library/user-event @testing-library/jest-dom
// part of vite.config.ts
export default defineConfig({
  plugins: [sveltekit({ adapter: adapter() })],
  test: {
    environment: 'jsdom',
    setupFiles: ['./vitest-setup.ts']
  },
  resolve: process.env.VITEST ? { conditions: ['browser'] } : undefined
});

The browser resolve condition makes Vitest load Svelte's browser build during tests. Put a single line, import '@testing-library/jest-dom/vitest';, in vitest-setup.ts to add matchers such as toHaveTextContent. Import defineConfig from vitest/config so the test block is typed as well.

// src/lib/components/Counter.test.ts
import { render, screen } from '@testing-library/svelte';
import userEvent from '@testing-library/user-event';
import { expect, test } from 'vitest';
import Counter from './Counter.svelte';

test('clicking the button increments the count', async () => {
  const user = userEvent.setup();
  render(Counter, { props: { initial: 1 } });

  const button = screen.getByRole('button');
  await user.click(button);
  expect(button).toHaveTextContent('2');
});

Load functions and form actions are ordinary async functions, so you can also call them with a stub event object that contains just the fields they use, and assert on the result.

End-to-end tests with Playwright

Playwright builds the app, serves it with the preview server and drives a real browser against it. The configuration created by sv add playwright looks much like this:

// playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
  webServer: {
    command: 'npm run build && npm run preview',
    port: 4173
  },
  testDir: 'tests'
});
// tests/home.test.ts
import { expect, test } from '@playwright/test';

test('home page shows a heading', async ({ page }) => {
  await page.goto('/');
  await expect(page.getByRole('heading', { level: 1 })).toBeVisible();
});

Run npx playwright install once to download the browsers. Flows that involve both server and browser, such as form actions with progressive enhancement, are best verified end to end.

Summary

  • Set up the test tools with npx sv add vitest playwright.
  • Test functions and rune-based logic with Vitest; name rune test files *.svelte.test.ts.
  • Test components from the user's point of view with jsdom and Testing Library.
  • Verify complete user flows with Playwright against a production build.
Questions about this chapter?
Previous chapterData and StateNext chapterBuilding and Deployment

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.