diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eaf6a8a436d..42521e9a13d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - `[jest-config]` Fix testing multiple projects with TypeScript config files ([#13099](https://github.com/facebook/jest/pull/13099)) - `[@jest/expect-utils]` Fix deep equality of ImmutableJS Record ([#13055](https://github.com/facebook/jest/pull/13055)) - `[jest-haste-map]` Increase the maximum possible file size that jest-haste-map can handle ([#13094](https://github.com/facebook/jest/pull/13094)) +- `[jest-snapshot]` Make `prettierPath` optional in `SnapshotState` ([#13149](https://github.com/facebook/jest/pull/13149)) - `[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)) ### Chore & Maintenance diff --git a/packages/jest-snapshot/src/InlineSnapshots.ts b/packages/jest-snapshot/src/InlineSnapshots.ts index 4c2d064da3e1..2ee07954f6da 100644 --- a/packages/jest-snapshot/src/InlineSnapshots.ts +++ b/packages/jest-snapshot/src/InlineSnapshots.ts @@ -46,7 +46,7 @@ export type InlineSnapshot = { export function saveInlineSnapshots( snapshots: Array, - prettierPath: string, + prettierPath: string | null, ): void { let prettier: Prettier | null = null; if (prettierPath) { @@ -72,7 +72,7 @@ export function saveInlineSnapshots( const saveSnapshotsForFile = ( snapshots: Array, sourceFilePath: string, - prettier?: Prettier, + prettier: Prettier | undefined, ) => { const sourceFile = fs.readFileSync(sourceFilePath, 'utf8'); diff --git a/packages/jest-snapshot/src/State.ts b/packages/jest-snapshot/src/State.ts index ef3aa5d72cfa..a065294b8d9a 100644 --- a/packages/jest-snapshot/src/State.ts +++ b/packages/jest-snapshot/src/State.ts @@ -24,7 +24,7 @@ import { export type SnapshotStateOptions = { updateSnapshot: Config.SnapshotUpdateState; - prettierPath: string; + prettierPath?: string | null; expand?: boolean; snapshotFormat: PrettyFormatOptions; }; @@ -62,7 +62,7 @@ export default class SnapshotState { private _snapshotPath: string; private _inlineSnapshots: Array; private _uncheckedKeys: Set; - private _prettierPath: string; + private _prettierPath: string | null; private _snapshotFormat: PrettyFormatOptions; added: number; @@ -80,7 +80,7 @@ export default class SnapshotState { this._initialData = data; this._snapshotData = data; this._dirty = dirty; - this._prettierPath = options.prettierPath; + this._prettierPath = options.prettierPath ?? null; this._inlineSnapshots = []; this._uncheckedKeys = new Set(Object.keys(this._snapshotData)); this._counters = new Map();