diff --git a/packages/snapshot/src/client.ts b/packages/snapshot/src/client.ts index b15bee07baea..d651eeda6628 100644 --- a/packages/snapshot/src/client.ts +++ b/packages/snapshot/src/client.ts @@ -75,6 +75,26 @@ export class SnapshotClient { return result } + // TODO: summary also needs to be aggregated here + private testIdTosnapshotPath: Record = {} + private snapshotPathToState = new Map() + + async setupTest( + filepath: string, + testId: string, + options: SnapshotStateOptions, + ): Promise { + const snapshotPath = await options.snapshotEnvironment.resolvePath(filepath) + this.testIdTosnapshotPath[testId] = snapshotPath + if (!this.snapshotPathToState.has(snapshotPath)) { + const content = await options.snapshotEnvironment.readSnapshotFile(snapshotPath) + this.snapshotPathToState.set( + snapshotPath, + new SnapshotState(filepath, snapshotPath, content, options), + ) + } + } + skipTest(filepath: string, testName: string): void { const state = this.getSnapshotState(filepath) state.markSnapshotsAsCheckedForTest(testName) diff --git a/packages/snapshot/src/port/state.ts b/packages/snapshot/src/port/state.ts index c7a0f837932c..3475113d87e4 100644 --- a/packages/snapshot/src/port/state.ts +++ b/packages/snapshot/src/port/state.ts @@ -68,7 +68,7 @@ export default class SnapshotState { private updated = new CounterMap() expand: boolean - private constructor( + constructor( public testFilePath: string, public snapshotPath: string, snapshotContent: string | null,