
Security News
MCP Steering Committee Launches Official MCP Registry in Preview
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
@onigoetz/ntr-expect-snapshot
Advanced tools
Node.js Test Runner is great, Expect is great, Snapshots are great.
Node.js Test Runner is great, Expect is great, Snapshots are great.
But using them all together at the moment is ... not so great.
This package aims to provide an easy approach to use .toMatchSnapshot
with Node.js Test Runner.
yarn add @onigoetz/ntr-expect-snapshot expect
import { test } from "node:test";
import initializeSnapshot from "@onigoetz/ntr-expect-snapshot";
import { expect } from "expect";
initializeSnapshot(import.meta.url);
test("a snapshot", async () => {
const response = await fetch("http://example.com");
const actual = await response.text();
expect(actual).toMatchSnapshot();
});
Updating snapshots is enabled if the --test-update-snapshots (Possible statring with Node.js 22.3.0) flag is passed or the SNAPSHOT_UPDATE environment variable is set to "true"
Snapshot management is usually tightly integrated within the test runner to offer features such as partial updates when tests are skipped or removing snapshot files when they're no longer needed.
This package can't be integrated tightly with Node.js test runner and here are some things that will probably not be possible to implement:
Remove a snapshot file if the test file is deleted
We are only aware of the current running test files, not other test files so we don't know which other files are or are not present
Remove a snapshot after a test is removed
The fact that a snapshot isn't used in a test run can be due to the test being currently skipped, or tests being filtered. For this reason we can't decide to remove all snapshots for a test at this stage.
The initial implementation is for most parts a fork of AVA's implementation.
I also checked how other tools in the space work to build a coherent approach
FAQs
Node.js Test Runner is great, Expect is great, Snapshots are great.
We found that @onigoetz/ntr-expect-snapshot 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
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.