
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
snapshot-assertion
Advanced tools
Asserts a string matches a snapshot saved in a file. An environment variable can be used to save rather than assert snapshots.
Asserts a string matches a snapshot saved in a file. An environment variable can be used to save rather than assert snapshots.
To install snapshot-assertion with npm, run:
npm install snapshot-assertion --save-dev
Then, import and use the function assertSnapshot.
A snapshot assertion in a test-director test:
import fetch from "node-fetch";
import assertSnapshot from "snapshot-assertion";
import TestDirector from "test-director";
const tests = new TestDirector();
tests.add("Get a todo.", async () => {
const response = await fetch("https://jsonplaceholder.typicode.com/todos/1");
await assertSnapshot(await response.json(), "snapshots/todo.json");
});
tests.run();
Using the SAVE_SNAPSHOTS environment variable to save snapshots when running a package script:
SAVE_SNAPSHOTS=1 npm run test
Supported runtime environments:
^14.17.0 || ^16.0.0 || >= 18.0.0.Projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check comment:
compilerOptions.allowJs should be true.compilerOptions.maxNodeModuleJsDepth should be reasonably large, e.g. 10.compilerOptions.module should be "node16" or "nodenext".The npm package snapshot-assertion features optimal JavaScript module design. These ECMAScript modules are exported via the package.json field exports:
FAQs
Asserts a string matches a snapshot saved in a file. An environment variable can be used to save rather than assert snapshots.
We found that snapshot-assertion demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.