Vai al contenuto principale
ProdottiStrumenti desktopTASTECADVisualizzazione disegniTASTEFILESGestione fileTASTEFTPTrasferimento fileTASTESSHSpazio di lavoro remotoTASTEZIPCompressione ed estrazioneTASTEWINMGestione fileStrumenti per sviluppatoriTASTECODEAmbiente di sviluppo integrato per RustTASTESTUDIOAmbiente integrato di sviluppo e testTASTEETLIntegrazione dati (ETL)ServerTASTEREMOTEServer di desktop remotoTASTEGEOServer geospazialeTASTEMAILSpazio di lavoro emailInvestimentiTASTESTOCKApp desktop di trading automatico azionarioIniziaDownloadDocumentazioneAcquistaTutti i prodotti
Marketplace
Notizie
TecnologiaNotizieNotizie di sviluppo di oggiDocumentazioneLinguaggi di programmazioneRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartFramework frontend webNext.jsReactVue.js · NuxtSvelteKitAngularFramework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressFramework per app e desktopTauriFlutterReact NativeElectronAlgoritmiBasi degli algoritmiAlgoritmi fondamentaliAlgoritmi avanzatiAlgoritmi pratici
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrinaGuida alla community
CollaboraTrasferimento tecnicoRealizzazione del sito webRealizzazione di app desktopPipeline di rilascio e pagamentoPartner commercialeContatti
ServiziDesktop remotoPacchetti di installazione su misura
TASTEDEV
Prodotti

Strumenti desktop

TASTECADApri con leggerezza anche i disegni più complessiTASTEFILESSolo i file che servono, alla massima velocitàTASTEFTPLa via più ordinata per i tuoi fileTASTESSHUn legame più solido tra te e i tuoi serverTASTEZIPComprimi più veloce, estrai più sicuroTASTEWINMUn file manager a due pannelli pensato per la tastiera

Strumenti per sviluppatori

TASTECODEModifica, compila, esegui il debug e testa app Rust in un'unica finestraTASTESTUDIODalla modifica ai test remoti e alle correzioni IA approvateTASTEETLSposta i dati guardando i valori

Server

TASTEREMOTEUn desktop remoto che gira sul tuo serverTASTEGEOUn server geospaziale compatibile con GeoServer, ricostruito in RustTASTEMAILRiprendi il controllo della tua posta

Investimenti

TASTESTOCKTrading automatico azionario secondo le regole che decidi tu: quando e che cosa

Inizia

DownloadUltime versioni di ogni prodottoDocsCome usare ogni prodottoAcquistaAbbonamenti e licenze perpetueTutti i prodottiTutti i prodotti a colpo d’occhio
Tutti i prodotti
MarketplaceNotizie
Tecnologia

Notizie

Notizie di sviluppo di oggiAnnunci ufficiali su linguaggi, framework, GitHub e IADocumentazioneGuide a linguaggi, framework e algoritmi

Linguaggi di programmazione

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Framework

Framework frontend webNext.jsReactVue.js · NuxtSvelteKitAngular
Framework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
Framework per app e desktopTauriFlutterReact NativeElectron

Algoritmi

Basi degli algoritmiAnalisi della complessità · Ordinamento · Ricerca · Strutture dati di base · Alberi e heapAlgoritmi fondamentaliVisita dei grafi · Cammini minimi e alberi ricoprenti · Programmazione dinamica · Algoritmi greedy · Divide et impera · BacktrackingAlgoritmi avanzatiAlgoritmi sulle stringhe · Matematica e teoria dei numeri · Manipolazione dei bit · Alberi di segmenti · Union-FindAlgoritmi praticiStrategia per colloqui di programmazione · Cache LRU · Rate limiting · Hashing consistente
Tutta la documentazione di sviluppo
Community
ProgettiScopri sviluppatori e lavoriLog di sviluppoDecisioni e lezioni appresePromptIstruzioni riutilizzabiliProblemi degli strumenti di IAProblemi e alternative di Claude, Codex, GeminiVetrinaRisultati completatiGuida alla communityCome sviluppiamo in modo aperto
Collabora
Trasferimento tecnicoApp native in Rust ed eguiRealizzazione del sito web10 lingue, account, documentazione e downloadRealizzazione di app desktopRust ed egui, senza WebViewPipeline di rilascio e pagamentoFirma, MSI, deb, rpm, AppImage, hashPartner commercialeConsigliaci e ricevi il 30%ContattiSviluppo, partnership e investimenti
Servizi
Desktop remotoRaggiungi il tuo computer dal browserPacchetti di installazione su misuraSolo il necessario, impostazioni precaricate
Acquista
IT
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Accedi
Accedi
TASTEDEV

Dai piccoli strumenti a uno sviluppo migliore.

support@tastedev.netSostieni TASTEDEV
ProdottiGamma di prodottiAcquistaDocsDownloadMarketplaceAssistenza
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrina
NormeChi siamoInformativa sulla privacyTermini di servizioCondizioni di abbonamentoRimborsiLinee guida della community
AccountAccediRegistrati
Visitatori
Oggi
Ieri
Visualizzazioni totali
Società
GXSOFT
Rappresentante
CHOI YOUNG GU
Numero di registrazione
853-44-00368
Indirizzo
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefono
+82-10-4404-1523
E-mail
whitecalvin@tastedev.net
Responsabile privacy
CHOI YOUNG GU

© 2026 TASTEDEVLe informazioni sui prodotti si basano su fonti di sviluppo verificate.Rilasciato · in miglioramento

Documentazione di SvelteKit
SvelteKit
Getting Started with SvelteKitProject StructureCore ConceptsData and StateTestingBuilding and Deployment
Discussioni

Guida a SvelteKit · 5/6

Testing

Per ora questo capitolo è disponibile solo in inglese.

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
Domande su questo capitolo?
Capitolo precedenteData and StateCapitolo successivoBuilding 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 commenti

Commenti principaliPrima i più recenti

Accedi · Accedi per lasciare un commento.