-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow a custom note when calling
ctx.skip()
dynamically (#6805)
- Loading branch information
1 parent
8d179af
commit 697c35c
Showing
10 changed files
with
71 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { test } from 'vitest'; | ||
|
||
test('my skipped test', ctx => { | ||
ctx.skip('custom message') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { TestCase } from 'vitest/node' | ||
import { resolve } from 'node:path' | ||
import { expect, test } from 'vitest' | ||
import { runVitest } from '../../test-utils' | ||
|
||
const root = resolve(import.meta.dirname, '../fixtures/skip-note') | ||
|
||
test.for([ | ||
{ reporter: 'default', isTTY: true }, | ||
{ reporter: 'verbose', isTTY: false }, | ||
])('can leave a note when skipping in the $reporter reporter', async ({ reporter, isTTY }) => { | ||
const { ctx, stdout, stderr } = await runVitest({ | ||
root, | ||
reporters: [ | ||
[reporter, { isTTY }], | ||
], | ||
}) | ||
|
||
expect(stderr).toBe('') | ||
expect(stdout).toContain('my skipped test [custom message]') | ||
|
||
expect(ctx).toBeDefined() | ||
const testTask = ctx!.state.getFiles()[0].tasks[0] | ||
const test = ctx!.state.getReportedEntity(testTask) as TestCase | ||
const result = test.result() | ||
expect(result).toEqual({ | ||
state: 'skipped', | ||
note: 'custom message', | ||
}) | ||
}) |