@@ -3,7 +3,7 @@ import type { ExpectStatic } from '@vitest/expect'
33import { GLOBAL_EXPECT , getState , setState } from '@vitest/expect'
44import { getSnapshotClient } from '../../integrations/snapshot/chai'
55import { vi } from '../../integrations/vi'
6- import { getFullName , getNames , getWorkerState } from '../../utils'
6+ import { getFullName , getNames , getTests , getWorkerState } from '../../utils'
77import { createExpect } from '../../integrations/chai/index'
88import type { ResolvedConfig } from '../../types/config'
99import type { VitestExecutor } from '../execute'
@@ -32,6 +32,14 @@ export class VitestTestRunner implements VitestRunner {
3232 suite . result ! . heap = process . memoryUsage ( ) . heapUsed
3333
3434 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+
3543 const result = await this . snapshotClient . finishCurrentRun ( )
3644 if ( result )
3745 await rpc ( ) . snapshotSaved ( result )
@@ -52,15 +60,11 @@ export class VitestTestRunner implements VitestRunner {
5260 }
5361
5462 async onBeforeRunTask ( test : Test ) {
55- const name = getNames ( test ) . slice ( 1 ) . join ( ' > ' )
56-
5763 if ( this . cancelRun )
5864 test . mode = 'skip'
5965
60- if ( test . mode !== 'run' ) {
61- this . snapshotClient . skipTestSnapshots ( name )
66+ if ( test . mode !== 'run' )
6267 return
63- }
6468
6569 clearModuleMocks ( this . config )
6670
0 commit comments