@ms-cloudpack/jest-path-snapshot
v0.1.51
Published
Allows for taking snapshots of file system content given a file path.
Downloads
662
Keywords
Readme
@ms-cloudpack/jest-path-snapshot
Allows paths, and optionally content, to be written in jest snapshots.
Usage
Initialize it in your test file:
import { pathSnapshotSerializer, fsPath } from '@ms-cloudpack/jest-path-snapshot';
expect.addSnapshotSerializer(pathSnapshotSerializer(options));
Then use in your tests by wrapping your path in the fsPath
helper and using the ordinary Jest snapshot api:
const someOutputPath = path.join(os.tmpdir(), 'my-stuff');
describe('file-thing', () => {
it('writes to the disk', () => {
fileThing(someOutputPath);
expect(
fsPath(someOutputPath), // wrap your string path in fsPath to identify it as a serialized path.
).toMatchSnapshot();
});
});
Options
| Name | Type | Description |
| ---------------------- | -------- | ---------------------------------------------------------------- |
| includeSourceMatches
| string[] | Array of glob strings to match for including source in snapshot. |