Skip to main content

Intro

Solid Testing Library on GitHub

Inspired completely by preact-testing-library

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

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 Solid components so that they avoid including implementation details, and are maintainable in the long run.

This Solution​

The Solid Testing Library is a very lightweight solution for testing Solid components. Its primary guiding principle is:

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

See the Dom introduction and React introduction for a more in-depth explanation.

What this library is not:

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

If you using Jest we recommend using solid-jest to properly resolve the browser version of Solid as Jest will default to the server version when run in Node.

💡 If you are using Jest or vitest, you may also be interested in installing @testing-library/jest-dom so you can use the custom jest matchers.