Skip to content

Commit

Permalink
fix: fix markSnapshotsAsCheckedForTest
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Oct 30, 2024
1 parent 5b1182b commit 940dbb3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/snapshot/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ export class SnapshotClient {
return result
}

skipTest(filepath: string, testId: string): void {
skipTest(filepath: string, testName: string): void {
const state = this.getSnapshotState(filepath)
state.markSnapshotsAsCheckedForTest(testId)
state.markSnapshotsAsCheckedForTest(testName)
}

clearTest(filepath: string, testId: string): void {
Expand Down
11 changes: 6 additions & 5 deletions packages/snapshot/src/port/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ export default class SnapshotState {
return this._environment
}

markSnapshotsAsCheckedForTest(testId: string): void {
// TODO: broken... for skipped test, we don't even have _testIdToKeys
for (const key of this._testIdToKeys.get(testId) ?? []) {
this._uncheckedKeys.delete(key)
}
markSnapshotsAsCheckedForTest(testName: string): void {
this._uncheckedKeys.forEach((uncheckedKey) => {
if (keyToTestName(uncheckedKey) === testName) {
this._uncheckedKeys.delete(uncheckedKey)
}
})
}

clearTest(testId: string): void {
Expand Down
5 changes: 3 additions & 2 deletions packages/vitest/src/runtime/runners/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
import type { SerializedConfig } from '../config'
import type { VitestExecutor } from '../execute'
import { getState, GLOBAL_EXPECT, setState } from '@vitest/expect'
import { getTestName, getTests } from '@vitest/runner/utils'
import { getNames, getTestName, getTests } from '@vitest/runner/utils'
import { createExpect } from '../../integrations/chai/index'
import { getSnapshotClient } from '../../integrations/snapshot/chai'
import { vi } from '../../integrations/vi'
Expand Down Expand Up @@ -58,7 +58,8 @@ export class VitestTestRunner implements VitestRunner {
// mark snapshots in skipped tests as not obsolete
for (const test of getTests(suite)) {
if (test.mode === 'skip') {
this.snapshotClient.skipTest(suite.file.filepath, test.id)
const name = getNames(test).slice(1).join(' > ')
this.snapshotClient.skipTest(suite.file.filepath, name)
}
}

Expand Down

0 comments on commit 940dbb3

Please sign in to comment.