Skip to content

Commit

Permalink
fix(runner): reset "current test" state on dynamic skip (#4814)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 28, 2023
1 parent e8ca643 commit 19faf00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/runner/src/run.ts
Expand Up @@ -183,6 +183,7 @@ export async function runTest(test: Test | Custom, runner: VitestRunner) {
test.mode = 'skip'
test.result = { state: 'skip' }
updateTask(test, runner)
setCurrentTest(undefined)
return
}

Expand Down
11 changes: 11 additions & 0 deletions test/core/test/skip-reset-state.test.ts
@@ -0,0 +1,11 @@
import { getCurrentTest } from '@vitest/runner'
import { afterAll, expect, test } from 'vitest'

afterAll(() => {
// verify "current test" resets after "skip"
expect(getCurrentTest()).toBeUndefined()
})

test('single skipped test', ({ skip }) => {
skip()
})

0 comments on commit 19faf00

Please sign in to comment.