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

spark-html-test-utils

v1.0.1

Published

Test helpers for spark-html: mount a component on linkedom, inspect its reactive scope, and fire realistic DOM events — no browser.

Readme

spark-html-test-utils

Test helpers for spark-html: mount a component on linkedom, inspect its reactive scope, and fire realistic DOM events — no browser, no build step.

This is the harness every spark-html debugging session hand-rolls, made reusable. For component-level logic it's all you need. For hydration and real-DOM-lifecycle behavior (detached hosts, event delegation timing), test in a real browser.

npm i -D spark-html-test-utils   # linkedom comes with it; spark-html is a peer

mount(fixture) → handle

import { mount, fireClick } from 'spark-html-test-utils';

const h = await mount({
  root: '<div import="counter"></div>',
  components: {
    counter: '<button onclick={inc}>{n}</button><script>let n = 0; function inc(){ n++; }</script>',
  },
});

fireClick(h.query('button'));
await h.settle();
console.assert(h.query('button').textContent === '1');
h.cleanup();

fixture is a markup string (the <body>), or { root, components?, url? }:

| field | meaning | |---|---| | root | markup placed in <body> — usually a <div import="…"> host | | components | { name: source } registered with component() before mount | | url | the location the runtime sees (default http://localhost/) |

The handle:

| member | what it gives you | |---|---| | query(sel) / queryAll(sel) | document.querySelector[All] over the mounted tree | | el | the first booted component host (its name element) | | scope(el?) | the reactive scope proxy — read and write it to drive/inspect state | | deps(node) | the node's tracked dependency keys (Set or null) | | html() | current <body> HTML — the serialized render | | settle() | drain microtasks + rAF timers so reactive updates land before you assert | | cleanup() | tear down components (drop store subscriptions) and restore globals |

scope and deps are the core inspect API (also re-exported), reading the same __spark* internals as spark-html-devtools — a supported window.

Event helpers

The runtime binds handlers with addEventListener, so a dispatched event with the right type fires them; extra props ride on the event object the handler receives, and events bubble (so document-delegated handlers fire too).

import { fire, fireClick, fireInput, fireChange, fireToggle, fireKey, fireSubmit, fireDrag } from 'spark-html-test-utils';

fireClick(el);
fireInput(input, 'typed');       // sets value, fires input (drives bind:value)
fireToggle(checkbox, true);      // sets checked, fires change (drives bind:checked)
fireKey(input, 'Enter');         // keydown with event.key = 'Enter'
fireDrag(box, { from: { x: 0, y: 0 }, to: { x: 40, y: 8 } }); // pointerdown→move→up (+mouse), with clientX/Y
fire(el, 'focus', { detail: 1 });// anything else

Recipe

  • Component logic — linkedom mount here. Fast, deterministic, no browser.
  • SSR / hydration — run the real server and drive a real browser (see the spark-html repo's debugging workflow); linkedom can't model everything a hydrating page does.

License

MIT