[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

docs: show both test options examples (#7786)

authored by

Vladimir and committed by
GitHub
(Apr 3, 2025, 10:54 AM +0900) 6373ecc8 14409088

+43 -5
+43 -5
docs/api/index.md
··· 38 38 In Jest, `TestFunction` can also be of type `(done: DoneCallback) => void`. If this form is used, the test will not be concluded until `done` is called. You can achieve the same using an `async` function, see the [Migration guide Done Callback section](/guide/migration#done-callback). 39 39 ::: 40 40 41 - Most options support both dot-syntax and object-syntax allowing you to use whatever style you prefer. 41 + You can define options by chaining properties on a function: 42 42 43 - :::code-group 44 - ```ts [dot-syntax] 43 + ```ts 45 44 import { test } from 'vitest' 46 45 47 46 test.skip('skipped test', () => { 48 47 // some logic that fails right now 49 48 }) 49 + 50 + test.concurrent.skip('skipped concurrent test', () => { 51 + // some logic that fails right now 52 + }) 50 53 ``` 51 - ```ts [object-syntax] 54 + 55 + But you can also provide an object as a second argument instead: 56 + 57 + ```ts 52 58 import { test } from 'vitest' 53 59 54 60 test('skipped test', { skip: true }, () => { 55 61 // some logic that fails right now 56 62 }) 63 + 64 + test('skipped concurrent test', { skip: true, concurrent: true }, () => { 65 + // some logic that fails right now 66 + }) 57 67 ``` 58 - ::: 68 + 69 + They both work in exactly the same way. To use either one is purely a stylistic choice. 70 + 71 + Note that if you are providing timeout as the last argument, you cannot use options anymore: 72 + 73 + ```ts 74 + import { test } from 'vitest' 75 + 76 + // ✅ this works 77 + test.skip('heavy test', () => { 78 + // ... 79 + }, 10_000) 80 + 81 + // ❌ this doesn't work 82 + test('heavy test', { skip: true }, () => { 83 + // ... 84 + }, 10_000) 85 + ``` 86 + 87 + However, you can provide a timeout inside the object: 88 + 89 + ```ts 90 + import { test } from 'vitest' 91 + 92 + // ✅ this works 93 + test('heavy test', { skip: true, timeout: 10_000 }, () => { 94 + // ... 95 + }) 96 + ``` 59 97 60 98 ## test 61 99