mirror of
https://github.com/vitest-dev/vitest.git
synced 2026-02-01 17:36:51 +00:00
docs: add describe.skipIf documentation (#2558)
* add describe.skipIf documentation * Update index.md * Apply suggestions from code review Co-authored-by: Anjorin Damilare <damilareanjorin1@gmail.com> Co-authored-by: Robbe <robbe@dexxter.be> Co-authored-by: Vladimir <sleuths.slews0s@icloud.com> Co-authored-by: Anjorin Damilare <damilareanjorin1@gmail.com>
This commit is contained in:
parent
78e26e980f
commit
2daf44af2e
@ -497,6 +497,26 @@ When you use `test` or `bench` in the top level of file, they are collected as p
|
||||
})
|
||||
```
|
||||
|
||||
### describe.skipIf
|
||||
|
||||
- **Type:** `(condition: any) => void`
|
||||
|
||||
In some cases, you might run suites multiple times with different environments, and some of the suites might be environment-specific. Instead of wrapping the suite with `if`, you can use `describe.skipIf` to skip the suite whenever the condition is truthy.
|
||||
|
||||
```ts
|
||||
import { assert, test } from 'vitest'
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development'
|
||||
|
||||
describe.skipIf(isDev)('prod only test', () => {
|
||||
// this test only runs in production
|
||||
})
|
||||
```
|
||||
|
||||
::: warning
|
||||
You cannot use this syntax when using Vitest as [type checker](/guide/testing-types).
|
||||
:::
|
||||
|
||||
### describe.only
|
||||
|
||||
- **Type:** `(name: string, fn: TestFunction, options?: number | TestOptions) => void`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user