Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make prettierPath optional in SnapshotState #13149

Merged
merged 3 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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