Vitest Browser : How to get viewport size during test execution ? #9300
Closed
theocerutti
started this conversation in
General
Replies: 1 comment
-
|
There are several way to get the project's name: import { server } from 'vitest/browser'
test('My Test', ({ task }) => {
console.log(server.config.name) // you can also read other config values
console.log(task.file.projectName)
})You can also provide any value to the project and read it in your tests: {
test: {
name: 'desktop',
provide: {
desktopValue: 'hello world'
},
}
}Inside the test you can either read the value directly: import { inject } from 'vitest'
const desktopValue = inject('desktopValue')Or you can inject it automatically to your test context: import { test as baseTest } from 'vitest'
const test = baseTest.extend({
desktopValue: ['default', { injected: true }],
})
test('My Test', ({ desktopValue }) => {
console.log(desktopValue)
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey!
Currently I've two test instance (one for desktop and another for mobile)
Is there a way to know which instance is run during a test ?
e.g:
Beta Was this translation helpful? Give feedback.
All reactions