You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/test.md
+38-29Lines changed: 38 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -261,47 +261,42 @@ Whether the test is expected to fail. If it does, the test will pass, otherwise
261
261
262
262
-**Alias:**`it.extend`
263
263
264
-
Use`test.extend`toextendthetestcontextwithcustomfixtures. Thiswillreturnanew`test`andit's also extendable, so you can compose more fixtures or override existing ones by extending it as you need. See [Extend Test Context](/guide/test-context.html#test-extend) for more information.
264
+
Use`test.extend`toextendthetestcontextwithcustomfixtures. Thiswillreturnanew`test`andit's also extendable, so you can compose more fixtures or override existing ones by extending it as you need. See [Extend Test Context](/guide/test-context#extend-test-context) for more information.
265
265
266
266
```ts
267
267
import { test as baseTest, expect } from 'vitest'
268
268
269
-
const todos = []
270
-
const archive = []
271
-
272
-
const test = baseTest.extend({
273
-
todos: async ({ task }, use) => {
274
-
todos.push(1, 2, 3)
275
-
await use(todos)
276
-
todos.length = 0
277
-
},
278
-
archive,
279
-
})
280
-
281
-
test('add item', ({ todos }) => {
282
-
expect(todos.length).toBe(3)
269
+
export const test = baseTest
270
+
// Simple value - type is inferred as { port: number; host: string }
Use`test.scoped`tooverridefixturevaluesforalltestswithinthecurrentsuiteanditsnestedsuites. Thismustbecalledatthetoplevelofa`describe`block. See [ScopingValuestoSuite](/guide/test-context.html#scoping-values-to-suite) formoreinformation.
289
+
Use `test.override` to override fixture values for all tests within the current suite and its nested suites. This must be called at the top level of a `describe` block. See [Overriding Fixture Values](/guide/test-context.html#overriding-fixture-values) for more information.
0 commit comments