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

@rtif-sdk/test-kit

v3.3.0

Published

Builders and assertions for testing RTIF documents.

Readme

@rtif-sdk/test-kit

Document builders and assertions for testing RTIF. Framework-agnostic — every assertion throws a plain Error with a focused message, so it works under any test runner. Depends on @rtif-sdk/core only.

npm install -D @rtif-sdk/test-kit @rtif-sdk/core

30 seconds

import { doc, p, h1, b, sel, assertDocEqual } from '@rtif-sdk/test-kit';
import { apply, invert } from '@rtif-sdk/core';

const before = doc(p('Hello ', b('world')), h1('Title'), p());
const op = { type: 'split_block', at: 3, id: 'x1' } as const;

assertDocEqual(apply(apply(before, op), invert(before, op)), before);

doc() returns a finished Document directly — no .build() step.

Builders

| Builder | Produces | |---|---| | doc(...blocks) | Document; no args → one empty paragraph | | p(...) | paragraph block | | h1(...) / h2(...) / h3(...) | heading with attrs: { level: n } | | blockquote(...) | blockquote block | | codeBlock(...) | code_block block | | li(...) | list block (one block per item) | | hr(opts?) | horizontal_rule block (empty content) | | block(type, ...) | any block type | | t(text, marks?) | span with optional marks | | b / i / u / s / code | bold / italic / underline / strikethrough / code span | | link(text, href) | span with { link: { href } } | | sel(anchor, focus?) | Selection; focus defaults to anchor |

Block builders take strings (unmarked spans), spans, and an optional { id?, attrs? } object first or last:

block('paragraph', 'Hello ', b('world'), { id: 'intro' })
li('first', { kind: 'ordered' })   // a non-{id,attrs} trailing object IS the attrs
h2('Subtitle', { id: 'sub' })
doc(p({ id: 'a' }, 'one'), p('two'))  // unpinned blocks get b1, b2, ... (per doc() call)

Ids are assigned deterministically and skip pinned ones. Builder output satisfies the normalization invariants the builders can guarantee locally; adjacent equal-mark spans are emitted as written (builders never merge).

Assertions

assertDocEqual(actual, expected, opts?)

Structural equality. Block ids are ignored by default — parsers and round trips regenerate ids, and most tests shouldn't care. Pass { compareIds: true } to catch id drift. On mismatch the error names the first differing block and shows just that block side by side, never the whole document:

Documents differ at block 1:
actual:   {"type":"paragraph","spans":[{"text":"wrld"}]}
expected: {"type":"paragraph","spans":[{"text":"world"}]}

assertValidDoc(doc)

Checks all six normalization invariants (block/span shape, no stray empty spans, no adjacent equal-mark spans, no {} marks/attrs, unique ids, ≥ 1 block) and names the violated invariant and offending block.

docToText(doc)

Compact debug rendering: blocks joined by \n; unmarked spans are raw text; marked spans render as <keys>text</> with keys sorted and non-true values appended as =JSON:

docToText(doc(p('Hello ', b('world')), p(link('here', '/x'))));
// 'Hello <bold>world</>\n<link={"href":"/x"}>here</>'

Handy in failure messages and snapshot-ish comparisons:

expect(docToText(result)).toBe('Title\nHello <bold|italic>world</>');