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:
Robbe Claessens 2023-01-12 10:17:08 +01:00 committed by GitHub
parent 78e26e980f
commit 2daf44af2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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`