Testing Library

Testing Library

  • Docs
  • Recipes
  • Help
  • Blog

›Svelte Testing Library

Getting Started

  • Introduction
  • Guiding Principles
  • Using Fake Timers

Frameworks

    DOM Testing Library

    • Introduction
    • Install
    • Example
    • Setup
    • Queries
    • Firing Events
    • Async Utilities
    • Helpers
    • Configuration
    • FAQ
    • Cheatsheet

    React Testing Library

    • Introduction
    • Example
    • Setup
    • API
    • Migrate from Enzyme
    • FAQ
    • Cheatsheet

    Reason Testing Library

    • Introduction
    • Examples

    React Native Testing Library

    • Introduction
    • Example
    • Setup

    Vue Testing Library

    • Introduction
    • Examples
    • Setup
    • API
    • Cheatsheet
    • FAQ

    Marko Testing Library

    • Introduction
    • Setup
    • API

    Angular Testing Library

    • Introduction
    • Examples
    • API

    Preact Testing Library

    • Introduction
    • Example
    • API
    • Learn

    Svelte Testing Library

    • Introduction
    • Setup
    • Example
    • API
  • Cypress Testing Library
  • Puppeteer Testing Library
  • Testcafe Testing Library
  • Nightwatch Testing Library

Ecosystem

  • user-event
  • jest-dom
  • bs-jest-dom
  • jest-native
  • react-select-event
  • eslint-plugin-testing-library
  • eslint-plugin-jest-dom
  • riot-testing-library
  • jasmine-dom
Edit

Intro

Svelte Testing Library on GitHub

npm install --save-dev @testing-library/svelte

This library is built on top of DOM Testing Library which is where most of the logic behind the queries is.

The Problem

You want to write tests for your Svelte components so that they avoid including implementation details, and are maintainable in the long run.

This Solution

The Svelte Testing Library is a very lightweight solution for testing Svelte components. It provides light utility functions on top of svelte, in a way that encourages better testing practices. Its primary guiding principle is:

The more your tests resemble the way your software is used, the more confidence they can give you.

So rather than dealing with instances of rendered Svelte components, your tests will work with actual DOM nodes. See the Dom Introduction for a more in-depth explanation.

What this library is not:

  1. A test runner or framework.
  2. Specific to a testing framework.

We recommend Jest as our preference.

Last updated on 10/8/2019
← LearnSetup →
  • The Problem
  • This Solution
Testing Library
Docs
Getting StartedExamplesAPIHelp
Community
BlogStack OverflowDiscord
More
StarGitHubEdit Docs on GitHubHosted by Netlify
Copyright © 2018-2020 Kent C. Dodds and contributors