···11+import type { TestCase } from 'vitest/node'
22+import { resolve } from 'node:path'
33+import { expect, test } from 'vitest'
44+import { runVitest } from '../../test-utils'
55+66+const root = resolve(import.meta.dirname, '../fixtures/skip-note')
77+88+test.for([
99+ { reporter: 'default', isTTY: true },
1010+ { reporter: 'verbose', isTTY: false },
1111+])('can leave a note when skipping in the $reporter reporter', async ({ reporter, isTTY }) => {
1212+ const { ctx, stdout, stderr } = await runVitest({
1313+ root,
1414+ reporters: [
1515+ [reporter, { isTTY }],
1616+ ],
1717+ })
1818+1919+ expect(stderr).toBe('')
2020+ expect(stdout).toContain('my skipped test [custom message]')
2121+2222+ expect(ctx).toBeDefined()
2323+ const testTask = ctx!.state.getFiles()[0].tasks[0]
2424+ const test = ctx!.state.getReportedEntity(testTask) as TestCase
2525+ const result = test.result()
2626+ expect(result).toEqual({
2727+ state: 'skipped',
2828+ note: 'custom message',
2929+ })
3030+})
+3-1
packages/runner/src/types/tasks.ts
···147147 * `repeats` option is set. This number also contains `retryCount`.
148148 */
149149 repeatCount?: number
150150+ /** @private */
151151+ note?: string
150152}
151153152154/**
···611613 * Mark tests as skipped. All execution after this call will be skipped.
612614 * This function throws an error, so make sure you are not catching it accidentally.
613615 */
614614- skip: () => void
616616+ skip: (note?: string) => void
615617}
616618617619export type ExtendedContext<T extends Custom | Test> = TaskContext<T> &