-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SyntaxError: The requested module '@vitest/browser/context' does not provide an export named 'page' #6525
Comments
You cannot use export default defineWorkspace([
'vite.config.ts',
// ^^ This is not browser mode
{
extends: 'vite.config.ts',
test: {
browser: {
enabled: true,
name: 'chromium',
provider: 'playwright',
// https://playwright.dev
providerOptions: {},
},
},
},
]); Does this work? export default defineWorkspace([
- 'vite.config.ts',
+ {
+ extends: 'vite.config.ts',
+ // Non-Browser mode tests are here:
+ include: ['tests/**'],
+ },
{
extends: 'vite.config.ts',
test: {
+ // Tests for browser mode are here
+ include: ['vitest-example/**'],
browser: {
enabled: true,
name: 'chromium',
provider: 'playwright',
// https://playwright.dev
providerOptions: {},
},
},
},
]); I didn't test this but that's my first guess. |
Thank you very much! Sorry for the confusion. I used the command
|
Looks like there is bug in this command. We need to fix the vitest/packages/vitest/src/create/browser/creator.ts Lines 257 to 280 in 2a50464
|
Hi, I also met the same problem. My workspace configuration now looks like this: // /vitest.workspace.ts
export default defineWorkspace([
// This will keep running your existing tests.
// If you don't need to run those in Node.js anymore,
// You can safely remove it from the workspace file
// Or move the browser test configuration to the config file.
{
// Non-Browser mode tests are here:
test: {
include: ['src/**/*.test.ts'],
name: 'unit',
environment: 'node',
},
},
{
test: {
// Tests for browser mode are here
setupFiles: ['./vitest.setup.ts'],
include: ['vitest-example/**/*.test.tsx', 'src/**/*.test.tsx'],
name: 'browser',
browser: {
enabled: true,
name: 'chromium',
provider: 'playwright',
// https://playwright.dev
providerOptions: {
launch: {
devtools: true,
}
},
},
},
},
]) and import '@testing-library/jest-dom/vitest'
import { cleanup } from '@testing-library/react'
import { afterEach } from 'vitest'
afterEach(() => {
cleanup()
})
afterEach(() => {
cleanup()
}) in each test file, but I haven't tested it. A repo with a full setup is available here: |
@rallets in your case there are browser tests included by this glob:
|
Hi @AriPerkkio why are you saying so? That |
Oh right, there is |
Describe the bug
When I try Browser Mode | Guide | Vitest in a react-ts template vite app, I got the error.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-8xj8ao?file=vite.config.ts
run
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: