Global test context #6222
-
I am currently looking into the test context documentation and I have two questions: 1- Importing an extended helper like this is a bit cumbersome: import { expect } from 'vitest'
import { myTest } from './my-test.js'
myTest('add items to todos', ({ todos }) => {
expect(todos.length).toBe(3)
todos.push(4)
expect(todos.length).toBe(4)
}) Is there a to make the extended context automatically available when importing directly from 2- The docs mention about extending |
Beta Was this translation helpful? Give feedback.
Answered by
sheremet-va
Jul 25, 2024
Replies: 1 comment
-
import { test as baseTest } from 'vitest'
export const test = baseTest.extend({
// ...
})
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
canassa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
test
fromvitest
. I don't see how importing it is cumbersome, it takes the same amount of steps - I would recommend exporting atest
function instead ofmyTest
:describe
doesn't care about the context so you can just use it.it
is an alias fortest
, they reference the same function, so it doesn't matter which one you use