
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.
vitest-directory-snapshot
Advanced tools
vitest-directory-snapshot is a testing utility for Vitest that enables snapshot testing of directory structures. It provides an extended version of Vitest's test function, along with a custom matcher, to assert that a directory (its structure and file contents) matches a stored snapshot. This allows you to easily compare changes in file system hierarchies during testing.
Install the package along with Vitest (if not already installed) using your package manager. For example, using pnpm:
pnpm install vitest-directory-snapshot
pnpm install vitest --save-dev
The package "vitest-directory-snapshot" exposes the following public API:
test
• An extended version of Vitest's test function.
• It automatically supports directory snapshot testing via a temporary directory fixture.
toMatchDirSnapshot(received: unknown)
• A custom Vitest matcher that compares a given directory against a stored snapshot.
• It expects an absolute path (string) to a directory and verifies that its structure and file contents match the stored snapshot.
import { describe, expect } from "vitest";
import { test, toMatchDirSnapshot } from "vitest-directory-snapshot";
describe("Directory Snapshot Tests", () => {
test("snapshot comparison", () => {
// Provide an absolute path to the directory you want to verify
expect("/absolute/path/to/directory").toMatchDirSnapshot();
});
});
To register the custom matcher in Vitest, add a setup file (e.g. setupFile.ts) with the following content:
import { createToMatchDirSnapshot } from "vitest-directory-snapshot";
expect.extend({
toMatchDirSnapshot: createToMatchDirSnapshot({ snapshotDirName: "custom_snapshots" }),
});
You can also configure the custom snapshot directory name by setting the environment variable VITEST_DIR_SNAPSHOT_DIR when running tests.
FAQs
## Overview
We found that vitest-directory-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.

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.