@@ -3,7 +3,7 @@ import type { ExpectStatic } from '@vitest/expect'
3
3
import { GLOBAL_EXPECT , getState , setState } from '@vitest/expect'
4
4
import { getSnapshotClient } from '../../integrations/snapshot/chai'
5
5
import { vi } from '../../integrations/vi'
6
- import { getFullName , getNames , getWorkerState } from '../../utils'
6
+ import { getFullName , getNames , getTests , getWorkerState } from '../../utils'
7
7
import { createExpect } from '../../integrations/chai/index'
8
8
import type { ResolvedConfig } from '../../types/config'
9
9
import type { VitestExecutor } from '../execute'
@@ -32,6 +32,14 @@ export class VitestTestRunner implements VitestRunner {
32
32
suite . result ! . heap = process . memoryUsage ( ) . heapUsed
33
33
34
34
if ( suite . mode !== 'skip' && typeof suite . filepath !== 'undefined' ) {
35
+ // mark snapshots in skipped tests as not obsolete
36
+ for ( const test of getTests ( suite ) ) {
37
+ if ( test . mode === 'skip' ) {
38
+ const name = getNames ( test ) . slice ( 1 ) . join ( ' > ' )
39
+ this . snapshotClient . skipTestSnapshots ( name )
40
+ }
41
+ }
42
+
35
43
const result = await this . snapshotClient . finishCurrentRun ( )
36
44
if ( result )
37
45
await rpc ( ) . snapshotSaved ( result )
@@ -52,15 +60,11 @@ export class VitestTestRunner implements VitestRunner {
52
60
}
53
61
54
62
async onBeforeRunTask ( test : Test ) {
55
- const name = getNames ( test ) . slice ( 1 ) . join ( ' > ' )
56
-
57
63
if ( this . cancelRun )
58
64
test . mode = 'skip'
59
65
60
- if ( test . mode !== 'run' ) {
61
- this . snapshotClient . skipTestSnapshots ( name )
66
+ if ( test . mode !== 'run' )
62
67
return
63
- }
64
68
65
69
clearModuleMocks ( this . config )
66
70
0 commit comments