Skip to content

Commit

Permalink
docs: add describe.skipIf documentation (#2558)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
4 people authored Jan 12, 2023
1 parent 78e26e9 commit 2daf44a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit 2daf44a

Please sign in to comment.