Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
jest-file-snapshot
Advanced tools
Readme
Jest matcher to write snapshots to a separate file instead of the default snapshot file used by Jest. Writing a snapshot to a separate file means you have proper syntax highlighting in the output file, and better readability without those pesky escape characters. It's also useful if you have binary content.
npm install --save-dev jest-file-snapshot
or
yarn add --dev jest-file-snapshot
Extend Jest's expect
:
import { toMatchFile } from 'jest-file-snapshot';
expect.extend({ toMatchFile });
Then use it in your tests:
it('matches content of file on disk', () => {
expect(content).toMatchFile();
});
The content passed can be of type string
or a Buffer
. The comparison be done using Buffer.equals()
instead of ===
if a Buffer
is passed.
The matcher takes two optional arguments:
filepath
: path to the file whose content should be matched, e.g. expect(content).toMatchFile(path.join(__dirname, 'output.md'))
options
: additional options object for the matcher, with following properties:
diff
: options for jest-diff
You should also exclude the output files from Jest's watcher so that updating the snapshot doesn't re-run the tests again.
For example, by default toMatchFile
uses a folder named __file_snapshots__
which you can exclude by adding the following under the jest
key in package.json
:
"watchPathIgnorePatterns": [
"__file_snapshots__"
]
FAQs
Jest matcher to write snapshots to a separate file instead of the default snapshot file used by Jest
We found that jest-file-snapshot 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.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).