···102102 })
103103 ```
104104105105+ You can also skip test by calling `skip` on its [context](/guide/test-context) dynamically:
106106+107107+ ```ts
108108+ import { assert, test } from 'vitest'
109109+110110+ test('skipped test', (context) => {
111111+ context.skip()
112112+ // Test skipped, no error
113113+ assert.equal(Math.sqrt(4), 3)
114114+ })
115115+ ```
116116+105117### test.skipIf
106118107119- **Type:** `(condition: any) => Test`
+36-1
docs/guide/test-context.md
···27272828#### `context.expect`
29293030-The `expect` API bound to the current test.
3030+The `expect` API bound to the current test:
3131+3232+```ts
3333+import { it } from 'vitest'
3434+3535+it('math is easy', ({ expect }) => {
3636+ expect(2 + 2).toBe(4)
3737+})
3838+```
3939+4040+This API is useful for running snapshot tests concurrently because global expect cannot track them:
4141+4242+```ts
4343+import { it } from 'vitest'
4444+4545+it.concurrent('math is easy', ({ expect }) => {
4646+ expect(2 + 2).toMatchInlineSnapshot()
4747+})
4848+4949+it.concurrent('math is hard', ({ expect }) => {
5050+ expect(2 * 2).toMatchInlineSnapshot()
5151+})
5252+```
5353+5454+#### `context.skip`
5555+5656+Skips subsequent test execution and marks test as skipped:
5757+5858+```ts
5959+import { expect, it } from 'vitest'
6060+6161+it('math is hard', ({ skip }) => {
6262+ skip()
6363+ expect(2 + 2).toBe(5)
6464+})
6565+```
31663267## Extend Test Context
3368
+6
packages/runner/src/context.ts
···22import { getSafeTimers } from '@vitest/utils'
33import type { RuntimeContext, SuiteCollector, Test, TestContext } from './types'
44import type { VitestRunner } from './types/runner'
55+import { PendingError } from './errors'
5667export const collectorContext: RuntimeContext = {
78 tasks: [],
···48494950 context.meta = test
5051 context.task = test
5252+5353+ context.skip = () => {
5454+ test.pending = true
5555+ throw new PendingError('test is skipped; abort execution', test)
5656+ }
51575258 context.onTestFailed = (fn) => {
5359 test.onFailed ||= []
+11
packages/runner/src/errors.ts
···11+import type { TaskBase } from './types'
22+33+export class PendingError extends Error {
44+ public code = 'VITEST_PENDING'
55+ public taskId: string
66+77+ constructor(public message: string, task: TaskBase) {
88+ super(message)
99+ this.taskId = task.id
1010+ }
1111+}