Gathering detailed insights and metrics for vitest-directory-snapshot
Gathering detailed insights and metrics for vitest-directory-snapshot
npm install vitest-directory-snapshot
Typescript
Module System
Node Version
NPM Version
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
937
Last Day
37
Last Week
37
Last Month
134
Last Year
937
Minified
Minified + Gzipped
Latest Version
0.5.0
Package Id
vitest-directory-snapshot@0.5.0
Unpacked Size
36.80 kB
Size
7.42 kB
File Count
44
NPM Version
10.9.0
Node Version
22.11.0
Published on
Feb 13, 2025
Cumulative downloads
Total Downloads
Last Day
1,750%
37
Compared to previous day
Last Week
516.7%
37
Compared to previous week
Last Month
0.8%
134
Compared to previous month
Last Year
0%
937
Compared to previous year
1
4
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:
1import { createToMatchDirSnapshot } from "vitest-directory-snapshot"; 2 3expect.extend({ 4 toMatchDirSnapshot: createToMatchDirSnapshot({ snapshotDirName: "custom_snapshots" }), 5});
You can also configure the custom snapshot directory name by setting the environment variable VITEST_DIR_SNAPSHOT_DIR
when running tests.
No vulnerabilities found.
No security vulnerabilities found.