File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -260,6 +260,14 @@ Unit tests use [vitest](https://vitest.dev)
260
260
pnpm test.unit
261
261
```
262
262
263
+ For tests that rely on browser APIs, run the DOM-focused build:
264
+
265
+ ``` shell
266
+ pnpm test.unit.browser
267
+ ```
268
+
269
+ This preset uses [ ` jsdom ` ] ( https://github.com/jsdom/jsdom ) under the hood, so ensure it is installed.
270
+
263
271
### E2E Tests Only
264
272
265
273
E2E tests use [ Playwright] ( https://playwright.dev/ ) .
Original file line number Diff line number Diff line change 256
256
"test.rust" : " make test" ,
257
257
"test.rust.update" : " make test-update" ,
258
258
"test.unit" : " vitest packages" ,
259
+ "test.unit.browser" : " vitest -c vitest.browser.config.ts packages" ,
259
260
"test.unit.debug" : " vitest --inspect-brk packages" ,
260
261
"test.vite" : " playwright test starters/e2e/qwikcity --browser=chromium --config starters/playwright.config.ts" ,
261
262
"tsc.check" : " tsc --noEmit" ,
Original file line number Diff line number Diff line change
1
+ import { mergeConfig , defineConfig } from 'vitest/config' ;
2
+ import baseConfig from './vitest.config' ;
3
+
4
+ // Browser-targeted Vitest config for tests requiring DOM APIs
5
+ export default mergeConfig (
6
+ baseConfig ,
7
+ defineConfig ( {
8
+ esbuild : {
9
+ platform : 'browser' ,
10
+ } ,
11
+ resolve : {
12
+ conditions : [ 'browser' ] ,
13
+ } ,
14
+ test : {
15
+ environment : 'jsdom' ,
16
+ } ,
17
+ } )
18
+ ) ;
Original file line number Diff line number Diff line change 1
1
import { defineWorkspace } from 'vitest/config' ;
2
2
3
3
// needed by the vscode vitest integration but it also speeds up vitest cli
4
- export default defineWorkspace ( [ './vitest.config.ts' ] ) ;
4
+ export default defineWorkspace ( [ './vitest.config.ts' , './vitest.browser.config.ts' ] ) ;
You can’t perform that action at this time.
0 commit comments