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

@opentf/afw-test

v1.33.0

Published

Render, query and interact with AFW components in tests.

Readme

@opentf/afw-test

Render, query and interact with AFW components in tests

Docs | API | Changelog | GitHub

An Open Tech Foundation project

Mount a compiled component or a page, query it the way a user would with Testing Library, and let the setup module tear it down after each test, lifecycle and reactive scopes included.

import { expect, test } from "runtime:test";
import { render, userEvent } from "@opentf/afw-test";
import Counter from "./Counter.jsx";

test("increments on click", async () => {
  const { getByRole } = render(Counter);
  const button = getByRole("button", { name: "Count: 0" });

  await userEvent.setup().click(button);

  expect(button.textContent).toBe("Count: 1");
});
esdev test --config=esdev.test.json --dom

[!NOTE] Alpha. The API can change between minor versions; see the changelog.

Install

pnpm add -D @opentf/afw-test @opentf/esdev-plugin-afw

Requires esdev 0.17 or newer. The test runner supplies the DOM; this package adds no DOM library and no compiler of its own.

Configure

Create esdev.test.json, which compiles JSX imports for tests and registers automatic cleanup:

{
  "plugins": [{
    "module": "@opentf/esdev-plugin-afw",
    "export": "createAfwPlugin",
    "options": { "target": "csr", "failOnError": true }
  }],
  "test": { "setup": ["@opentf/afw-test/setup"] }
}

With Vitest

In the Vite + Node workflow, run the same tests under Vitest. @opentf/vite-plugin-afw compiles components for the test's DOM, and the @opentf/afw-test/vitest setup file registers cleanup after each test:

pnpm add -D @opentf/afw-test @opentf/vite-plugin-afw vite vitest happy-dom
// vite.config.js
import afw from "@opentf/vite-plugin-afw";

export default {
  plugins: [afw()],
  test: {
    environment: "happy-dom", // or "jsdom"
    setupFiles: ["@opentf/afw-test/vitest"],
  },
};

Import test and expect from vitest; render and userEvent work as above.

Two engines

| Command | Runs in | Use for | | --- | --- | --- | | esdev test --config=esdev.test.json --dom | esdev's native DOM | Most component tests: fast, no browser needed | | esdev test --config=esdev.test.json --browser | A real browser engine | Layout, CSS and real event timing |

--browser needs a supported browser and its matching driver; see esdev browser testing.

API

| Export | Purpose | | --- | --- | | render(Component, props?) | Mount a compiled component, a page factory or a tag name; props are set before connection. Returns container, unmount() and bound Testing Library queries | | cleanup() | Unmount everything render() created; the setup module runs it after each test | | userEvent | @testing-library/user-event: clicks, typing, keyboard and selection | | @opentf/afw-test/setup | Registers afterEach(cleanup) for every test file |

unmount() disposes the view's lifecycle hooks and reactive scopes and removes its container; calling it twice is safe. Custom-element disconnect callbacks can settle asynchronously, so await the effect you assert on when testing teardown.

Documentation

| Doc | Purpose | | --- | --- | | Setup | Configuration in detail | | Writing tests | Structure, props and async updates | | Queries | Finding elements by role, label and text | | User events | Simulating real interaction | | Strategies | When to use the native DOM or a real browser |

License

MIT — see LICENSE.