Skip to content

Commit

Permalink
fix: fix retry partial
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Oct 30, 2024
1 parent 99abe4c commit c174615
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
13 changes: 6 additions & 7 deletions packages/snapshot/src/port/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
4 changes: 4 additions & 0 deletions test/core/test/__snapshots__/repro.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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"`;
3 changes: 1 addition & 2 deletions test/core/test/repro.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit c174615

Please sign in to comment.