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

@stewie-js/testing

v0.1.0

Published

Test utilities for the Stewie framework — mount, DOM queries, signal and store assertions

Readme

@stewie-js/testing

Work in progress.

Stewie is under active development and not yet stable. APIs may change between releases. Not recommended for production use yet.

Test utilities for Stewie applications. Provides mount for rendering components into a real DOM (via jsdom or happy-dom), DOM query helpers, signal and store assertions, and an SSR helper for snapshot testing.

Designed for use with Vitest.

Part of the Stewie framework.

Install

pnpm add -D @stewie-js/testing

Mounting components

// my-component.test.ts
// @vitest-environment happy-dom
import { describe, it, expect } from 'vitest'
import { mount } from '@stewie-js/testing'
import { jsx, signal, createRoot } from '@stewie-js/core'

describe('Counter', () => {
  it('increments when clicked', () => {
    let count: ReturnType<typeof signal<number>>
    createRoot(() => { count = signal(0) })

    const result = mount(
      jsx('div', { children: () => String(count()) })
    )

    expect(result.getByTestId('count').textContent).toBe('0')
    count.set(1)
    expect(result.getByTestId('count').textContent).toBe('1')

    result.unmount()
  })
})

DOM queries

const result = mount(jsx(MyComponent, {}))

result.getByText('Submit')          // throws if not found
result.queryByText('Submit')        // returns null if not found
result.getByTestId('submit-btn')    // finds by data-testid
result.getByRole('button')          // finds by ARIA role
await result.findByText('Loaded')   // waits for async appearance

result.container   // the root HTMLElement
result.html        // container.innerHTML
result.unmount()   // clean up

Signal and store assertions

import { assertSignal, assertStore } from '@stewie-js/testing'
import { signal, store, createRoot } from '@stewie-js/core'

createRoot(() => {
  const count = signal(42)
  assertSignal(count, 42)   // passes
  assertSignal(count, 0)    // throws

  const state = store({ user: { name: 'Alice' } })
  assertStore(state, 'user.name', 'Alice')  // passes
  assertStore(state, 'user.name', 'Bob')    // throws
})

SSR snapshot testing

import { renderToString } from '@stewie-js/testing'
import { jsx } from '@stewie-js/core'

const { html } = await renderToString(jsx(MyComponent, {}))
expect(html).toContain('<h1>Hello</h1>')

Context injection

import { mount, withContext } from '@stewie-js/testing'

const ThemeCtx = createContext('light')

// Inject a context value into a mounted tree
const result = mount(jsx(MyComponent, {}), {
  contexts: [{ context: ThemeCtx, value: 'dark' }],
})

// Or run a callback with a context value
withContext(ThemeCtx, 'dark', () => {
  const theme = inject(ThemeCtx) // 'dark'
})

API

| Export | Description | |---|---| | mount(element, options?) | Render a JSX element into a detached DOM node | | MountResult | Type returned by mount — includes query helpers and unmount() | | assertSignal(sig, expected) | Assert a signal's current value | | assertStore(store, path, expected) | Assert a store property by dot-path | | flushEffects() | Returns a promise that resolves after pending reactive effects settle | | renderToString(element) | SSR helper — returns { html, stateScript } | | withContext(ctx, value, fn) | Run fn with a context value provided |