Skip to content

Commit d2ff18a

Browse files
authored
chore: make prettierPath optional in SnapshotState (#13149)
1 parent 7d8d01c commit d2ff18a

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- `[jest-config]` Fix testing multiple projects with TypeScript config files ([#13099](https://github.com/facebook/jest/pull/13099))
1818
- `[@jest/expect-utils]` Fix deep equality of ImmutableJS Record ([#13055](https://github.com/facebook/jest/pull/13055))
1919
- `[jest-haste-map]` Increase the maximum possible file size that jest-haste-map can handle ([#13094](https://github.com/facebook/jest/pull/13094))
20+
- `[jest-snapshot]` Make `prettierPath` optional in `SnapshotState` ([#13149](https://github.com/facebook/jest/pull/13149))
2021
- `[jest-worker]` When a process runs out of memory worker exits correctly and doesn't spin indefinitely ([#13054](https://github.com/facebook/jest/pull/13054))
2122

2223
### Chore & Maintenance

packages/jest-snapshot/src/InlineSnapshots.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export type InlineSnapshot = {
4646

4747
export function saveInlineSnapshots(
4848
snapshots: Array<InlineSnapshot>,
49-
prettierPath: string,
49+
prettierPath: string | null,
5050
): void {
5151
let prettier: Prettier | null = null;
5252
if (prettierPath) {
@@ -72,7 +72,7 @@ export function saveInlineSnapshots(
7272
const saveSnapshotsForFile = (
7373
snapshots: Array<InlineSnapshot>,
7474
sourceFilePath: string,
75-
prettier?: Prettier,
75+
prettier: Prettier | undefined,
7676
) => {
7777
const sourceFile = fs.readFileSync(sourceFilePath, 'utf8');
7878

packages/jest-snapshot/src/State.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424

2525
export type SnapshotStateOptions = {
2626
updateSnapshot: Config.SnapshotUpdateState;
27-
prettierPath: string;
27+
prettierPath?: string | null;
2828
expand?: boolean;
2929
snapshotFormat: PrettyFormatOptions;
3030
};
@@ -62,7 +62,7 @@ export default class SnapshotState {
6262
private _snapshotPath: string;
6363
private _inlineSnapshots: Array<InlineSnapshot>;
6464
private _uncheckedKeys: Set<string>;
65-
private _prettierPath: string;
65+
private _prettierPath: string | null;
6666
private _snapshotFormat: PrettyFormatOptions;
6767

6868
added: number;
@@ -80,7 +80,7 @@ export default class SnapshotState {
8080
this._initialData = data;
8181
this._snapshotData = data;
8282
this._dirty = dirty;
83-
this._prettierPath = options.prettierPath;
83+
this._prettierPath = options.prettierPath ?? null;
8484
this._inlineSnapshots = [];
8585
this._uncheckedKeys = new Set(Object.keys(this._snapshotData));
8686
this._counters = new Map();

0 commit comments

Comments
 (0)