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

twd-js

v1.6.2

Published

Test While Developing (TWD) - in-browser testing

Readme

TWD

CI npm version license Maintainability Code Coverage

TWD (Testing Web Development) is a library designed to seamlessly integrate testing into your web development workflow. It streamlines the process of writing, running, and managing tests directly in your application, with a modern UI and powerful mocking capabilities.

📖 Full Documentation | 🚀 Getting Started | 📚 API Reference

Features

  • 🧪 In-browser test runner with a beautiful sidebar UI
  • Instant feedback as you develop
  • 🔥 Mock Service Worker integration for API/request mocking
  • 📝 Simple, readable test syntax (inspired by popular test frameworks)
  • 🧩 Automatic test discovery with Vite support
  • 🎯 Testing Library support - Use screenDom for semantic, accessible queries
  • 🛠️ Works with React (support for more frameworks coming)

Installation

npm install twd-js
# or
yarn add twd-js
# or
pnpm add twd-js

Quick Start

React / Vue / Angular / Other Frameworks (Bundled / recommended)

TWD now supports any framework via its bundled version.

// Only load the test sidebar and tests in development mode
if (import.meta.env.DEV) {
  const { initTWD } = await import('twd-js/bundled');
  const tests = import.meta.glob("./**/*.twd.test.ts");
  
  // Initialize TWD with tests and optional configuration
  // Request mocking is automatically initialized by default
  initTWD(tests, { 
    open: true, 
    position: 'left',
    serviceWorker: true,           // Enable request mocking (default: true)
    serviceWorkerUrl: '/mock-sw.js' // Custom service worker path (default: '/mock-sw.js')
  });
}

Set Up Mock Service Worker

If you plan to use API mocking, set up the mock service worker:

npx twd-js init public

Check the Framework Integration Guide for more details.

Writing Tests

// src/app.twd.test.ts
import { twd, userEvent, screenDom } from "twd-js";
import { describe, it } from "twd-js/runner";

describe("Hello World Page", () => {
  it("should display the welcome title and counter button", async () => {
    await twd.visit("/");
    
    // Use Testing Library queries (Recommended - semantic & accessible)
    const title = screenDom.getByRole("heading", { name: /welcome to twd/i });
    twd.should(title, "be.visible");
    twd.should(title, "have.text", "Welcome to TWD");
    
    const counterButton = screenDom.getByRole("button", { name: /count is/i });
    twd.should(counterButton, "be.visible");
    twd.should(counterButton, "have.text", "Count is 0");
    
    const user = userEvent.setup();
    await user.click(counterButton);
    twd.should(counterButton, "have.text", "Count is 1");

    // Alternative: Use TWD's native selectors for direct element access
    // const title = await twd.get("h1");
    // title.should("be.visible").should("have.text", "Welcome to TWD");
  });
});
  1. Run your app - The TWD sidebar will appear automatically in development mode!

Key Concepts

Element Selection

TWD supports two approaches:

Testing Library Queries (Recommended):

const button = screenDom.getByRole("button", { name: /submit/i });
twd.should(button, "be.visible");

Native Selectors:

const button = await twd.get("button");
button.should("be.visible");

User Interactions

const user = userEvent.setup();
await user.click(button);
await user.type(input, "Hello World");

API Mocking

twd.mockRequest("getUser", {
  method: "GET",
  url: "/api/user",
  response: { id: 1, name: "John" }
});

const rule = await twd.waitForRequest("getUser");

Documentation

Full documentation is available at twd.dev (coming soon) or in the docs folder.

Examples

Check out our working examples for various frameworks:

Each example includes a complete setup guide and demonstrates best practices for testing with TWD including ci integration.

Contributing

Contributions are welcome! Please open issues or pull requests on GitHub.

License

This project is licensed under the MIT License.