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

@narrativetrace/vitest

v0.2.0

Published

Auto-traces Vitest tests, writing trace files, failure diagnostics, and clarity reports for each run

Readme

@narrativetrace/vitest

Auto-trace your Vitest tests — write scenarios against a real narrative context and get trace files, per-test failure diagnostics, and clarity reports for free.

Install

pnpm add -D @narrativetrace/vitest @narrativetrace/proxy vitest

vitest (any of 1.x, 2.x or 3.x) is the only peer dependency — the other four NarrativeTrace dependencies (core-node, clarity, diagrams, glossary) install automatically with this package, since they release in lockstep and are never independently versioned. @narrativetrace/proxy is listed explicitly because the example below imports traceObject from it directly: pnpm only exposes a package's own direct dependencies, not a dependency's dependencies, so anything you import yourself still needs to be your own dependency.

Usage

createNarrativeTest returns a Vitest test extended with a narrativeContext fixture. On each test it captures the trace, writes the requested formats, and prints a framed narrative on failure.

import { createNarrativeTest } from '@narrativetrace/vitest';
import { traceObject } from '@narrativetrace/proxy';

const test = createNarrativeTest({ formats: ['md', 'mmd', 'clarity-json'] });

test('places an order', ({ narrativeContext }) => {
  const service = traceObject(orderService, narrativeContext);
  service.placeOrder('C1', 'P1', 2);
});

Capture buffer size

Each test gets its own context over its own capture buffer, sized for a test rather than a server: bufferCapacity defaults to 8192 events (~4,000 traced calls), not the runtime's 65,536. That is an explicit argument from this package — the runtime never detects a test framework and changes behaviour.

If a test traces more than the buffer holds, the oldest events are dropped and the run says so, once, naming the number to raise to:

⚠️ NarrativeTrace dropped 40 events: the capture buffer (8192) overflowed, so
   this narrative is incomplete. Raise it with
   createNarrativeTest({ bufferCapacity: 16384 }).

The same sentence is appended as a footer to the Markdown and diagram artifacts, so a saved trace never looks complete when it is not. (The JSON artifacts are left untouched — their schema forbids extra fields.)

For suite-wide clarity, register ClaritySuiteReporter in your Vitest config, importing it from the /reporters subpath — not the package root, which also loads the narrativeTest fixture and, with it, vitest itself; importing vitest from inside vitest.config.ts fails with "Vitest failed to access its internal state" on every Vitest version:

// vitest.config.ts
import { defineConfig } from 'vitest/config';
import { ClaritySuiteReporter } from '@narrativetrace/vitest/reporters';

export default defineConfig({
  test: {
    reporters: ['default', new ClaritySuiteReporter()],
  },
});

It aggregates every test's clarity scenario across workers and emits a single clarity-results.json — the artifact narrativetrace-clarity gates on.

Learn more