88import * as fs from 'graceful-fs' ;
99import type { Config } from '@jest/types' ;
1010import { getStackTraceLines , getTopFrame } from 'jest-message-util' ;
11- import type { OptionsReceived as PrettyFormatOptions } from 'pretty-format' ;
1211import { InlineSnapshot , saveInlineSnapshots } from './InlineSnapshots' ;
13- import type { SnapshotData } from './types' ;
12+ import type { SnapshotData , SnapshotFormat } from './types' ;
1413import {
1514 addExtraLineBreaks ,
1615 getSnapshotData ,
@@ -23,28 +22,28 @@ import {
2322} from './utils' ;
2423
2524export type SnapshotStateOptions = {
26- updateSnapshot : Config . SnapshotUpdateState ;
27- prettierPath ?: string | null ;
28- expand ?: boolean ;
29- snapshotFormat : PrettyFormatOptions ;
30- rootDir : string ;
25+ readonly updateSnapshot : Config . SnapshotUpdateState ;
26+ readonly prettierPath ?: string | null ;
27+ readonly expand ?: boolean ;
28+ readonly snapshotFormat : SnapshotFormat ;
29+ readonly rootDir : string ;
3130} ;
3231
3332export type SnapshotMatchOptions = {
34- testName : string ;
35- received : unknown ;
36- key ?: string ;
37- inlineSnapshot ?: string ;
38- isInline : boolean ;
39- error ?: Error ;
33+ readonly testName : string ;
34+ readonly received : unknown ;
35+ readonly key ?: string ;
36+ readonly inlineSnapshot ?: string ;
37+ readonly isInline : boolean ;
38+ readonly error ?: Error ;
4039} ;
4140
4241type SnapshotReturnOptions = {
43- actual : string ;
44- count : number ;
45- expected ?: string ;
46- key : string ;
47- pass : boolean ;
42+ readonly actual : string ;
43+ readonly count : number ;
44+ readonly expected ?: string ;
45+ readonly key : string ;
46+ readonly pass : boolean ;
4847} ;
4948
5049type SaveStatus = {
@@ -57,15 +56,16 @@ export default class SnapshotState {
5756 private _dirty : boolean ;
5857 // @ts -expect-error - seemingly unused?
5958 private _index : number ;
60- private _updateSnapshot : Config . SnapshotUpdateState ;
59+ private readonly _updateSnapshot : Config . SnapshotUpdateState ;
6160 private _snapshotData : SnapshotData ;
62- private _initialData : SnapshotData ;
63- private _snapshotPath : string ;
61+ private readonly _initialData : SnapshotData ;
62+ private readonly _snapshotPath : string ;
6463 private _inlineSnapshots : Array < InlineSnapshot > ;
65- private _uncheckedKeys : Set < string > ;
66- private _prettierPath : string | null ;
67- private _snapshotFormat : PrettyFormatOptions ;
68- private _rootDir : string ;
64+ private readonly _uncheckedKeys : Set < string > ;
65+ private readonly _prettierPath : string | null ;
66+ private readonly _rootDir : string ;
67+
68+ readonly snapshotFormat : SnapshotFormat ;
6969
7070 added : number ;
7171 expand : boolean ;
@@ -93,7 +93,7 @@ export default class SnapshotState {
9393 this . unmatched = 0 ;
9494 this . _updateSnapshot = options . updateSnapshot ;
9595 this . updated = 0 ;
96- this . _snapshotFormat = options . snapshotFormat ;
96+ this . snapshotFormat = options . snapshotFormat ;
9797 this . _rootDir = options . rootDir ;
9898 }
9999
@@ -213,7 +213,7 @@ export default class SnapshotState {
213213 }
214214
215215 const receivedSerialized = addExtraLineBreaks (
216- serialize ( received , undefined , this . _snapshotFormat ) ,
216+ serialize ( received , undefined , this . snapshotFormat ) ,
217217 ) ;
218218 const expected = isInline ? inlineSnapshot : this . _snapshotData [ key ] ;
219219 const pass = expected === receivedSerialized ;
0 commit comments