Skip to content

Commit

Permalink
chore: make prettierPath optional in SnapshotState (#13149)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Aug 19, 2022
1 parent 7d8d01c commit d2ff18a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-snapshot/src/InlineSnapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export type InlineSnapshot = {

export function saveInlineSnapshots(
snapshots: Array<InlineSnapshot>,
prettierPath: string,
prettierPath: string | null,
): void {
let prettier: Prettier | null = null;
if (prettierPath) {
Expand All @@ -72,7 +72,7 @@ export function saveInlineSnapshots(
const saveSnapshotsForFile = (
snapshots: Array<InlineSnapshot>,
sourceFilePath: string,
prettier?: Prettier,
prettier: Prettier | undefined,
) => {
const sourceFile = fs.readFileSync(sourceFilePath, 'utf8');

Expand Down
6 changes: 3 additions & 3 deletions packages/jest-snapshot/src/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {

export type SnapshotStateOptions = {
updateSnapshot: Config.SnapshotUpdateState;
prettierPath: string;
prettierPath?: string | null;
expand?: boolean;
snapshotFormat: PrettyFormatOptions;
};
Expand Down Expand Up @@ -62,7 +62,7 @@ export default class SnapshotState {
private _snapshotPath: string;
private _inlineSnapshots: Array<InlineSnapshot>;
private _uncheckedKeys: Set<string>;
private _prettierPath: string;
private _prettierPath: string | null;
private _snapshotFormat: PrettyFormatOptions;

added: number;
Expand All @@ -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();
Expand Down

0 comments on commit d2ff18a

Please sign in to comment.