-
-
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(vitest): allow calling
skip
dynamically (#3966)
- Loading branch information
1 parent
3073b9a
commit 5c88d8e
Showing
9 changed files
with
139 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { TaskBase } from './types' | ||
|
||
export class PendingError extends Error { | ||
public code = 'VITEST_PENDING' | ||
public taskId: string | ||
|
||
constructor(public message: string, task: TaskBase) { | ||
super(message) | ||
this.taskId = task.id | ||
} | ||
} |
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,39 @@ | ||
import EventEmitter from 'node:events' | ||
import { expect, it } from 'vitest' | ||
|
||
const sleep = (ms?: number) => new Promise(resolve => setTimeout(resolve, ms)) | ||
|
||
it('correctly skips sync tests', ({ skip }) => { | ||
skip() | ||
expect(1).toBe(2) | ||
}) | ||
|
||
it('correctly skips async tests with skip before async', async ({ skip }) => { | ||
await sleep(100) | ||
skip() | ||
expect(1).toBe(2) | ||
}) | ||
|
||
it('correctly skips async tests with async after skip', async ({ skip }) => { | ||
skip() | ||
await sleep(100) | ||
expect(1).toBe(2) | ||
}) | ||
|
||
it('correctly skips tests with callback', ({ skip }) => { | ||
const emitter = new EventEmitter() | ||
emitter.on('test', () => { | ||
skip() | ||
}) | ||
emitter.emit('test') | ||
expect(1).toBe(2) | ||
}) | ||
|
||
it('correctly skips tests with async callback', ({ skip }) => { | ||
const emitter = new EventEmitter() | ||
emitter.on('test', async () => { | ||
skip() | ||
}) | ||
emitter.emit('test') | ||
expect(1).toBe(2) | ||
}) |