@ms-cloudpack/jest-path-snapshot v0.1.95
@ms-cloudpack/jest-path-snapshot
Allows file trees and 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);
// wrap your string path in fsPath to identify it as a serialized path.
expect(fsPath(someOutputPath)).toMatchInlineSnapshot();
});
});
Example output:
Folder contents of "test-project":
a/
├─ c/
│ └─ test-json.json
└─ test-png.png
b/
├─ test-ts.ts
└─ test-tsx.tsx
test-txt.txt
a/c/test-json.json:
------------------
{}
b/test-ts.ts:
------------
'ts';
b/test-tsx.tsx:
--------------
'tsx';
test-txt.txt:
------------
txt
Options
Name | Type | Default | Description |
---|---|---|---|
includeSourceMatches | string[] | '**/*.{txt,?([cm])[jt]s?(x),json}' | Array of globs to include contents in the snapshot (does not impact the path hierarchy tree). |
excludeSourceMatches | string[] | Array of globs to exclude from snapshot, despite matching includeSourceMatches (does not impact the path hierarchy tree). |
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago