diff --git a/packages/snapshot/src/port/state.ts b/packages/snapshot/src/port/state.ts index 795dfb2cd51e..35e2ee6de606 100644 --- a/packages/snapshot/src/port/state.ts +++ b/packages/snapshot/src/port/state.ts @@ -120,21 +120,20 @@ export default class SnapshotState { } clearTest(testName: string): void { - // TODO: key by test.id + // TODO: key by test.id (handle multiple tests with same title) // TODO: reset this.added, matched, etc.. this._inlineSnapshots = this._inlineSnapshots.filter(s => s.testName !== testName) this._inlineSnapshotStacks = this._inlineSnapshotStacks.filter(s => s.testName !== testName) if (this._counters.has(testName)) { - let counter = this._counters.get(testName)! - for (const key in this._snapshotData) { - if (keyToTestName(key) === testName) { - counter-- + const counter = this._counters.get(testName)! + for (let i = 1; i <= counter; i++) { + const key = testNameToKey(testName, counter) + if (key in this._snapshotData || key in this._initialData) { this._snapshotData[key] = this._initialData[key] - this._uncheckedKeys.add(key) } } - this._counters.set(testName, counter) + this._counters.delete(testName) } } diff --git a/test/core/test/__snapshots__/repro.test.ts.snap b/test/core/test/__snapshots__/repro.test.ts.snap index a368365c6eda..55fb93d2deec 100644 --- a/test/core/test/__snapshots__/repro.test.ts.snap +++ b/test/core/test/__snapshots__/repro.test.ts.snap @@ -11,3 +11,7 @@ exports[`file retry 1`] = `"foo"`; exports[`file retry many 1`] = `"foo"`; exports[`file retry many 2`] = `"bar"`; + +exports[`file retry partial 1`] = `"foo"`; + +exports[`file retry partial 2`] = `"bar"`; diff --git a/test/core/test/repro.test.ts b/test/core/test/repro.test.ts index fbb5e03ec9c0..ec0c8149fefe 100644 --- a/test/core/test/repro.test.ts +++ b/test/core/test/repro.test.ts @@ -39,8 +39,7 @@ test('file retry many', { retry: 1 }, (ctx) => { } }) -// TODO -test.skip('file retry partial', { retry: 1 }, (ctx) => { +test('file retry partial', { retry: 1 }, (ctx) => { expect('foo').toMatchSnapshot() if (ctx.task.result?.retryCount === 0) { throw new Error('boom')