npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mcansh/remix-testing-library

v0.0.1

Published

a small wrapper around DOM Testing Library for use with Remix v3

Readme

Remix Testing Library

a small wrapper around DOM Testing Library for use with Remix v3

Installation

npm install --save-dev @mcansh/remix-testing-library
pnpm add --save-dev @mcansh/remix-testing-library
yarn add --dev @mcansh/remix-testing-library

You will also need a DOM environment for your test runner. For example, with Vitest and happy-dom:

npm install --save-dev vitest happy-dom
// vitest.config.js
import { defineConfig } from "vitest/config"

export default defineConfig({
	test: {
		environment: "happy-dom",
		globals: true, // required for auto-cleanup after each test
	},
})

Usage

Basic render

import { render, screen } from "@mcansh/remix-testing-library"

it("renders a greeting", () => {
	function Greeting() {
		return (props: { name: string }) => <p>Hello, {props.name}!</p>
	}

	render(<Greeting name="world" />)

	screen.getByText("Hello, world!")
})

Rerendering

import { render, screen } from "@mcansh/remix-testing-library"

it("updates when rerendered with new props", () => {
	function Greeting() {
		return (props: { message: string }) => <div>{props.message}</div>
	}

	const { rerender } = render(<Greeting message="hi" />)
	screen.getByText("hi")

	rerender(<Greeting message="hey" />)
	screen.getByText("hey")
})

Interactive components

Note: The interactive example below uses @testing-library/user-event, which must be installed separately:

npm install --save-dev @testing-library/user-event
import { on, pressEvents, type Handle } from "@remix-run/component"
import { userEvent } from "@testing-library/user-event"
import { render, screen } from "@mcansh/remix-testing-library"

it("increments a counter on click", async () => {
	let user = userEvent.setup()

	function Counter(handle: Handle) {
		let count = 0
		return () => (
			<button
				mix={[
					pressEvents(),
					on(pressEvents.press, async () => {
						count += 1
						await handle.update()
					}),
				]}
			>
				Clicked {count} time{count === 1 ? "" : "s"}
			</button>
		)
	}

	render(<Counter />)

	const button = screen.getByRole("button")
	expect(button.textContent).toBe("Clicked 0 times")

	await user.click(button)

	expect(button.textContent).toBe("Clicked 1 time")
})

API

render(ui, options?)

Renders a Remix component into a container appended to document.body and returns an object with:

| Property | Description | | ---------------------------------- | -------------------------------------------------------------------------------------------------------- | | container | The div element the component was rendered into | | baseElement | document.body (or the custom baseElement option if provided) | | debug(el?, maxLength?, options?) | Logs a pretty-printed DOM snapshot to the console | | rerender(ui) | Re-renders the component with new props | | dispose() | Unmounts the component | | asFragment() | Returns a DocumentFragment snapshot of the current DOM | | ...queries | All DOM Testing Library queries bound to baseElement |

Options:

| Option | Type | Description | | -------------------- | -------------------- | ---------------------------------------------------------------------------------------- | | container | HTMLElement | Custom container element (defaults to a new div appended to baseElement) | | baseElement | HTMLElement | Custom base element for queries (defaults to document.body) | | wrapper | component | Wraps the rendered UI with the given component | | queries | Queries | Custom queries to bind to baseElement (defaults to all @testing-library/dom queries) | | virtualRootOptions | VirtualRootOptions | Options forwarded to createRoot from @remix-run/component |

cleanup()

Unmounts all components rendered with render and removes their containers from document.body. This is called automatically after each test only when a global afterEach or teardown function is available on globalThis. Jest provides this by default; in Vitest, you must enable test.globals: true in your Vitest config — simply importing afterEach in a test file is not sufficient. Import from @mcansh/remix-testing-library/pure to opt out of auto-cleanup.

Pure imports (no auto-cleanup)

If you prefer to manage cleanup yourself, import from the pure entry point:

import { render, cleanup } from "@mcansh/remix-testing-library/pure"

You can also disable auto-cleanup globally by setting the RTL_SKIP_AUTO_CLEANUP environment variable to "true".

Re-exports

@mcansh/remix-testing-library re-exports everything from @testing-library/dom, including all queries (e.g. screen, getByText, findByRole) and utilities (e.g. waitFor, fireEvent).