
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@nodeboot/node-test
Advanced tools
Node.js Test Runner integration for the NodeBoot Test Framework.
The @nodeboot/node-test package extends the core NodeBoot Test Framework with Node.js test runner-specific features:
node:test modulenode:assertnpm install @nodeboot/node-test @nodeboot/core
# or
pnpm add @nodeboot/node-test @nodeboot/core
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: "test@example.com"});
assert.equal(spy.callCount, 1);
assert.deepEqual(spy.calls[0].arguments[0], {
to: "test@example.com",
subject: "Welcome",
});
});
});
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();
});
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);
});
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("@");
};
})(),
});
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.
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));
});
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();
});
test("should handle delays", () => {
const {control} = useTimer();
let completed = false;
setTimeout(() => {
completed = true;
}, 1000);
// Fast-forward time
control().advanceTimeBy(1000);
assert.equal(completed, true);
});
MIT License - see LICENSE file for details.
FAQs
Test framework for Node_Boot projects using node:test
The npm package @nodeboot/node-test receives a total of 29 weekly downloads. As such, @nodeboot/node-test popularity was classified as not popular.
We found that @nodeboot/node-test demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.