Skip to content

Commit

Permalink
fix: duplicate snapshots appearing on retries (#11)
Browse files Browse the repository at this point in the history
Signed-off-by: Chapman Pendery <cpendery@microsoft.com>
  • Loading branch information
cpendery authored Mar 4, 2024
1 parent 5fdfc3a commit b770b3f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/runner/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { expect } from "../test/test.js";
import { SnapshotStatus } from "../test/matchers/toMatchSnapshot.js";
import { BaseReporter } from "../reporter/base.js";
import { poll } from "../utils/poll.js";
import { flushSnapshotExecutionCache } from "../test/matchers/toMatchSnapshot.js";

type WorkerResult = {
error?: string;
Expand Down Expand Up @@ -239,6 +240,8 @@ const testWorker = async (
updateSnapshot: boolean,
importPath: string
): Promise<void> => {
flushSnapshotExecutionCache();

const startTime = Date.now();
workerpool.workerEmit({
startTime,
Expand Down
2 changes: 2 additions & 0 deletions src/test/matchers/toMatchSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ const generateSnapshot = (terminal: Terminal, includeColors: boolean) => {
return `${view}\n${JSON.stringify(Object.fromEntries(shifts), null, 2)}`;
};

export const flushSnapshotExecutionCache = () => snapshotsIdx.clear();

export async function toMatchSnapshot(
this: MatcherContext,
terminal: Terminal,
Expand Down

0 comments on commit b770b3f

Please sign in to comment.