@ms-cloudpack/jest-path-snapshot
TypeScript icon, indicating that this package has built-in type declarations

0.1.54 • Public • Published

@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.

Readme

Keywords

none

Package Sidebar

Install

npm i @ms-cloudpack/jest-path-snapshot

Weekly Downloads

139

Version

0.1.54

License

MIT

Unpacked Size

16.4 kB

Total Files

23

Last publish

Collaborators

  • ecraig12345_msft
  • uifabricteam
  • dzearing