Skip to content
Library
Testing

Preact Testing Library

Testing Library integration focused on user-centric testing for Preact components.

Native PreactActive

Native Preact

Built for Preact and does not require a React compatibility layer.

Package@testing-library/preact

Facts at a glance
Preact compatibility
Native Preact
Tested Preact versions
Not documented
TypeScript
Native TypeScript
SSR
SSR unsupported
Maintenance
Active
License
MIT
Last verified
Not yet verified
Terminal
npm install @testing-library/preact
Preact example
import { render, screen } from "@testing-library/preact";import { Counter } from "./Counter"; render(<Counter />);screen.getByRole("button", { name: /count/i });

Introduction

If you already like Testing Library's approach, this is the natural choice for Preact component tests.

Preact configuration

Works with Vitest or Jest-style environments that provide a DOM.

SSR notes

This package is test-only and usually runs in jsdom rather than on a real server renderer.

Islands notes

Very useful for testing interactive islands in isolation.

Alternatives