Installations
npm install jest-fs-snapshot
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
14.21.3
NPM Version
6.14.18
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (99.9%)
CSS (0.1%)
Developer
Download Statistics
Total Downloads
295,654
Last Day
253
Last Week
1,111
Last Month
7,479
Last Year
130,503
GitHub Statistics
7 Stars
54 Commits
1 Forks
4 Watching
4 Branches
3 Contributors
Bundle Size
404.64 kB
Minified
200.44 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.3.0
Package Id
jest-fs-snapshot@0.3.0
Unpacked Size
50.39 kB
Size
12.04 kB
File Count
10
NPM Version
6.14.18
Node Version
14.21.3
Publised On
11 Mar 2024
Total Downloads
Cumulative downloads
Total Downloads
295,654
Last day
14%
253
Compared to previous day
Last week
-39%
1,111
Compared to previous week
Last month
-0.4%
7,479
Compared to previous month
Last year
7.3%
130,503
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
jest-fs-snapshot ·
Jest matcher for filesystem snapshotting.
Table of Contents
Installation
1yarn add jest-fs-snapshot
Getting Started
- Extend Jest's
expect
1import { toMatchFilesystemSnapshot } from 'jest-fs-snapshot'; 2 3expect.extend({ toMatchFilesystemSnapshot });
- Use it in your tests!
1test('if build directory matches snapshot', () => { 2 const pathToBuildDir = path.resolve(process.cwd(), '.build'); 3 expect(pathToBuildDir).toMatchFilesystemSnapshot(); 4});
This will create a __fs_snapshots__
folder next to your test file with a snapshot file. On next runs it will chech if
the snapshot against the source directory and with throw on mismatches.
API
.toMatchFilesystemSnapshot([pathToSnapshot, options])
Arguments
pathToSnapshot
(String): An optional full path to a snapshot file.options
(Object): An optional object with additional configurations.customCompare
({check: Function, compare: Function}[]): Any custom compare function will be applied only if the check method returns true. If multiple checks return true, the first hit will be used.
Example
1const diff = require('jest-diff'); 2 3const snapshotOptions = { 4 customCompare: [ 5 { 6 check: path => path.endsWith('package.json'), 7 compare: (actualBuffer, expectedBuffer) => { 8 const actual = JSON.parse(actualBuffer); 9 const expected = JSON.parse(expectedBuffer); 10 11 // we want to ignore the peerModules 12 delete actual.peerModules; 13 delete expected.peerModules; 14 15 return diff(actual, expected); 16 }, 17 }, 18 { 19 // test.js files will be ignored 20 check: path => path.endsWith('.test.js'), 21 compare: () => true, 22 }, 23 ], 24}; 25 26describe('...', () => { 27 it('...', () => { 28 /** 29 * ... 30 */ 31 expect(pathToBuildDir).toMatchFilesystemSnapshot(undefined, snapshotOptions); 32 }); 33});
Credits
Many files for encodings
fixture have been taken from https://github.com/mbbill/fencview.
License
This package is released using the MIT license. For more information see the license file.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
5 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/6 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'develop'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 24 are checked with a SAST tool
Score
2.4
/10
Last Scanned on 2024-12-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More