Skip to content

Commit

Permalink
fix(runner): reset current test state on dynamic "skip"
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 28, 2023
1 parent 039814b commit 10cb17a
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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 10cb17a

Please sign in to comment.