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

@nodeboot/node-test

v2.14.0

Published

Test framework for Node_Boot projects using node:test

Readme

@nodeboot/node-test

Node.js Test Runner integration for the NodeBoot Test Framework.

Overview

The @nodeboot/node-test package extends the core NodeBoot Test Framework with Node.js test runner-specific features:

  • Native Node.js Testing: Uses the built-in node:test module
  • Spy/Mock Integration: Provides spy functionality for method tracking
  • Timer Control: Fake timer support for time-based testing
  • Assert Integration: Works seamlessly with node:assert

Installation

npm install @nodeboot/node-test @nodeboot/core
# or
pnpm add @nodeboot/node-test @nodeboot/core

Basic Usage

import {describe, test} from "node:test";
import assert from "node:assert/strict";
import {useNodeBoot} from "@nodeboot/node-test";
import {MyApp} from "./MyApp";

describe("My App Integration Tests", () => {
    const {useHttp, useService, useSpy} = useNodeBoot(MyApp, ({useConfig, useMock}) => {
        useConfig({
            app: {port: 3001},
            database: {url: "sqlite::memory:"},
        });

        useMock(EmailService, {
            sendEmail: () => Promise.resolve({messageId: "test-123"}),
        });
    });

    test("should handle API requests", async () => {
        const {get} = useHttp();
        const response = await get("/api/users");
        assert.equal(response.status, 200);
    });

    test("should spy on service methods", async () => {
        const userService = useService(UserService);
        const spy = useSpy(EmailService, "sendEmail");

        await userService.createUser({name: "Test", email: "[email protected]"});

        assert.equal(spy.callCount, 1);
        assert.deepEqual(spy.calls[0].arguments[0], {
            to: "[email protected]",
            subject: "Welcome",
        });
    });
});

Example features

Spy Functionality

The useSpy hook creates spies on service methods to track calls:

const {useSpy} = useNodeBoot(MyApp, setup);

test("should track method calls", async () => {
    const spy = useSpy(EmailService, "sendEmail");

    // Perform operations that should trigger the method
    const service = useService(UserService);
    await service.notifyUser("123");

    // Verify the spy was called
    assert.equal(spy.callCount, 1);
    assert.ok(Array.isArray(spy.calls));

    // Clean up (automatic cleanup happens after each test)
    spy.restore();
});

Timer Control

The useTimer hook provides fake timer control:

const {useTimer} = useNodeBoot(MyApp, setup);

test("should control timers", () => {
    const {control, tracking} = useTimer();
    const tracker = tracking();

    let fired = false;
    setTimeout(() => {
        fired = true;
    }, 5000);

    // Advance time without waiting
    control().advanceTimeBy(5000);
    assert.equal(fired, true);

    // Track elapsed time
    tracker.stop();
    assert.ok(tracker.elapsed() >= 0);
});

Mocking with Plain Functions

Unlike Jest, Node.js test runner uses plain functions for mocks:

useMock(EmailService, {
    // Simple mock
    sendEmail: () => Promise.resolve({messageId: "mock-123"}),

    // Mock with state tracking
    validateEmail: (() => {
        let callCount = 0;
        return email => {
            callCount++;
            return email.includes("@");
        };
    })(),
});

Available Hooks

All core hooks are available, plus Node.js test runner specific hooks. Please refer to the NodeBoot Test Framework documentation for a complete list of hooks and their usage.

Best Practices

1. Use Assert for Assertions

import assert from "node:assert/strict";

test("should validate response", async () => {
    const response = await get("/api/users");
    assert.equal(response.status, 200);
    assert.ok(Array.isArray(response.data));
});

2. Spy Management

test("should track calls", () => {
    const spy = useSpy(Service, "method");

    // Use the service
    service.doSomething();

    // Verify
    assert.equal(spy.callCount, 1);

    // Cleanup is automatic, but you can restore manually
    spy.restore();
});

3. Timer Testing

test("should handle delays", () => {
    const {control} = useTimer();

    let completed = false;
    setTimeout(() => {
        completed = true;
    }, 1000);

    // Fast-forward time
    control().advanceTimeBy(1000);
    assert.equal(completed, true);
});

Common Gotchas

  1. Async/Await: Node.js test runner requires explicit async/await handling
  2. Test Isolation: Each test runs in isolation - shared state won't persist
  3. Error Messages: Assert provides different error messages than expect
  4. Mock Cleanup: Mocks are automatically cleaned up between tests

License

MIT License - see LICENSE file for details.