Allows paths, and optionally content, to be written in jest snapshots.
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();
});
});
Name | Type | Description |
---|---|---|
includeSourceMatches |
string[] | Array of glob strings to match for including source in snapshot. |