Simple and complete Svelte DOM testing utilities that encourage good testing practices.
Svelte Testing Library is a testing utility library for Svelte components. It provides functions to render Svelte components in a test environment and query their DOM output, helping developers write tests that simulate real user interactions. It solves the problem of writing maintainable tests for Svelte applications by encouraging testing practices that focus on component behavior rather than implementation details.
Svelte developers who need to write unit and integration tests for their components, particularly those using test runners like Vitest or Jest.
Developers choose Svelte Testing Library because it follows the Testing Library philosophy of testing components the way users interact with them, leading to more reliable and maintainable tests. It's the official Svelte integration of the popular Testing Library ecosystem.
:chipmunk: Simple and complete Svelte DOM testing utilities that encourage good testing practices
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Builds on @testing-library/dom to provide essential testing utilities without unnecessary bloat, as outlined in the solution section of the README.
Offers auto-cleanup in Vitest and Jest via plugins, reducing test boilerplate and preventing state leakage, detailed in the Auto-cleanup section.
Supports Svelte versions 3, 4, and 5, ensuring it works with current and legacy projects, as stated in the Installation section.
Encourages tests that mimic real user interactions, leading to more reliable and maintainable test suites, following the guiding principle emphasized in the README.
Documentation is hosted separately on testing-library.com, not in the repo, which can fragment information and require external navigation for users.
Auto-cleanup only works out-of-the-box with Vitest and Jest; for other runners, manual setup is required, as mentioned in the Setup section.
Relies on @testing-library/dom for DOM queries, which might introduce compatibility issues or require additional learning for those unfamiliar with the Testing Library ecosystem.