本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

SvelteKit ドキュメント
SvelteKit
Getting Started with SvelteKitProject StructureCore ConceptsData and StateTestingBuilding and Deployment
ディスカッション

SvelteKit ガイド · 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
この章について質問がありますか?
前の章Data and State次の章Building and Deployment
// 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.

コメント 0件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。