Skip to content

Commit b8a91b1

Browse files
Vitest 4 upgrade
1 parent 2f8b30c commit b8a91b1

File tree

10 files changed

+471
-191
lines changed

10 files changed

+471
-191
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,17 @@
3838
"@rollup/plugin-commonjs": "^25.0.7",
3939
"@rollup/plugin-node-resolve": "15.2.3",
4040
"@rollup/plugin-typescript": "^12.1.4",
41-
"@vitest/browser": "^3.2.4",
41+
"@vitest/browser": "^4.0.5",
42+
"@vitest/browser-playwright": "^4.0.5",
4243
"husky": "^9.0.11",
4344
"lint-staged": "^15.2.2",
44-
"playwright": "^1.51.0",
45+
"playwright": "^1.56.0",
4546
"prettier": "^3.2.5",
4647
"prettier-plugin-embed": "^0.4.15",
4748
"prettier-plugin-sql": "^0.18.1",
4849
"rollup": "4.14.3",
4950
"rollup-plugin-dts": "^6.2.1",
5051
"typescript": "^5.7.2",
51-
"vitest": "^3.2.4"
52+
"vitest": "^4.0.5"
5253
}
5354
}

packages/adapter-sql-js/vitest.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { playwright } from '@vitest/browser-playwright';
12
import topLevelAwait from 'vite-plugin-top-level-await';
23
import wasm from 'vite-plugin-wasm';
3-
import { defineConfig, UserConfigExport } from 'vitest/config';
4+
import { defineConfig, ViteUserConfigExport } from 'vitest/config';
45

5-
const config: UserConfigExport = {
6+
const config: ViteUserConfigExport = {
67
worker: {
78
format: 'es',
89
plugins: () => [wasm(), topLevelAwait()]
@@ -21,7 +22,7 @@ const config: UserConfigExport = {
2122
browser: {
2223
enabled: true,
2324
headless: true,
24-
provider: 'playwright',
25+
provider: playwright(),
2526
instances: [
2627
{
2728
browser: 'chromium'

packages/attachments/vitest.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
import { playwright } from '@vitest/browser-playwright';
12
import topLevelAwait from 'vite-plugin-top-level-await';
2-
import { defineConfig, UserConfigExport } from 'vitest/config';
3+
import wasm from 'vite-plugin-wasm';
4+
import { defineConfig, ViteUserConfigExport } from 'vitest/config';
35

4-
const config: UserConfigExport = {
5-
plugins: [topLevelAwait()],
6+
const config: ViteUserConfigExport = {
7+
plugins: [wasm(), topLevelAwait()],
68
test: {
79
isolate: false,
810
globals: true,
911
include: ['tests/**/*.test.ts'],
1012
browser: {
1113
enabled: true,
1214
headless: true,
13-
provider: 'playwright',
15+
provider: playwright(),
1416
instances: [
1517
{
1618
browser: 'chromium'

packages/drizzle-driver/vitest.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { playwright } from '@vitest/browser-playwright';
12
import topLevelAwait from 'vite-plugin-top-level-await';
23
import wasm from 'vite-plugin-wasm';
3-
import { defineConfig, UserConfigExport } from 'vitest/config';
4+
import { defineConfig, ViteUserConfigExport } from 'vitest/config';
45

5-
const config: UserConfigExport = {
6+
const config: ViteUserConfigExport = {
67
worker: {
78
format: 'es',
89
plugins: () => [wasm(), topLevelAwait()]
@@ -21,7 +22,7 @@ const config: UserConfigExport = {
2122
browser: {
2223
enabled: true,
2324
headless: true,
24-
provider: 'playwright',
25+
provider: playwright(),
2526
instances: [
2627
{
2728
browser: 'chromium'

packages/kysely-driver/vitest.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { playwright } from '@vitest/browser-playwright';
12
import topLevelAwait from 'vite-plugin-top-level-await';
23
import wasm from 'vite-plugin-wasm';
3-
import { defineConfig, UserConfigExport } from 'vitest/config';
4+
import { defineConfig, ViteUserConfigExport } from 'vitest/config';
45

5-
const config: UserConfigExport = {
6+
const config: ViteUserConfigExport = {
67
worker: {
78
format: 'es',
89
plugins: () => [wasm(), topLevelAwait()]
@@ -21,7 +22,7 @@ const config: UserConfigExport = {
2122
browser: {
2223
enabled: true,
2324
headless: true,
24-
provider: 'playwright',
25+
provider: playwright(),
2526
instances: [
2627
{
2728
browser: 'chromium'

packages/react/vitest.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { defineConfig, UserConfigExport } from 'vitest/config';
1+
import { playwright } from '@vitest/browser-playwright';
2+
import { defineConfig, ViteUserConfigExport } from 'vitest/config';
23

34
import topLevelAwait from 'vite-plugin-top-level-await';
45
import wasm from 'vite-plugin-wasm';
56

6-
const config: UserConfigExport = {
7+
const config: ViteUserConfigExport = {
78
// This is only needed for local tests to resolve the package name correctly
89
worker: {
910
format: 'es',
@@ -31,7 +32,7 @@ const config: UserConfigExport = {
3132
* Starts each test in a new iFrame
3233
*/
3334
isolate: true,
34-
provider: 'playwright',
35+
provider: playwright(),
3536
headless: true,
3637
instances: [
3738
{

packages/vue/vitest.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { defineConfig, UserConfigExport } from 'vitest/config';
1+
import { playwright } from '@vitest/browser-playwright';
2+
import { defineConfig, ViteUserConfigExport } from 'vitest/config';
23

34
import topLevelAwait from 'vite-plugin-top-level-await';
45
import wasm from 'vite-plugin-wasm';
56

6-
const config: UserConfigExport = {
7+
const config: ViteUserConfigExport = {
78
// This is only needed for local tests to resolve the package name correctly
89
worker: {
910
format: 'es',
@@ -31,7 +32,7 @@ const config: UserConfigExport = {
3132
* Starts each test in a new iFrame
3233
*/
3334
isolate: true,
34-
provider: 'playwright',
35+
provider: playwright(),
3536
headless: true,
3637
instances: [
3738
{

packages/web/vitest.config.ts

Lines changed: 67 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,73 @@
11
import path from 'path';
22
import topLevelAwait from 'vite-plugin-top-level-await';
33
import wasm from 'vite-plugin-wasm';
4-
import { defineConfig, UserConfigExport } from 'vitest/config';
4+
import { defineConfig, ViteUserConfigExport } from 'vitest/config';
55

6-
const config: UserConfigExport = {
7-
server: {
8-
headers: {
9-
'Cross-Origin-Opener-Policy': 'same-origin',
10-
'Cross-Origin-Embedder-Policy': 'require-corp'
11-
}
12-
},
13-
// This is only needed for local tests to resolve the package name correctly
14-
resolve: {
15-
alias: {
16-
/**
17-
* Note that this requires the Typescript to be compiled with `tsc`
18-
* first. This is required due to the format of Webworker URIs
19-
* they link to `.js` files.
20-
*/
21-
'@powersync/web': path.resolve(__dirname, './lib/src'),
22-
// https://jira.mongodb.org/browse/NODE-5773
23-
bson: require.resolve('bson')
24-
}
25-
},
26-
worker: {
27-
format: 'es',
28-
plugins: () => [wasm(), topLevelAwait()]
29-
},
30-
optimizeDeps: {
31-
// Don't optimise these packages as they contain web workers and WASM files.
32-
// https://github.com/vitejs/vite/issues/11672#issuecomment-1415820673
33-
exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
34-
include: ['bson', 'comlink', 'async-mutex']
35-
},
36-
plugins: [wasm(), topLevelAwait()],
37-
test: {
38-
globals: true,
39-
include: ['tests/**/*.test.ts'],
40-
maxConcurrency: 1,
41-
// This doesn't currently seem to work in browser mode, but setting this for one day when it does
42-
sequence: {
43-
shuffle: false, // Disable shuffling of test files
44-
concurrent: false // Run test files sequentially
6+
export default defineConfig(async () => {
7+
// Import of an ES module is not directly supported since we don't yet define this package directly as an ES module
8+
const { playwright } = await import('@vitest/browser-playwright');
9+
10+
return {
11+
server: {
12+
headers: {
13+
'Cross-Origin-Opener-Policy': 'same-origin',
14+
'Cross-Origin-Embedder-Policy': 'require-corp'
15+
}
16+
},
17+
// This is only needed for local tests to resolve the package name correctly
18+
resolve: {
19+
alias: {
20+
/**
21+
* Note that this requires the Typescript to be compiled with `tsc`
22+
* first. This is required due to the format of Webworker URIs
23+
* they link to `.js` files.
24+
*/
25+
'@powersync/web': path.resolve(__dirname, './lib/src'),
26+
// https://jira.mongodb.org/browse/NODE-5773
27+
bson: require.resolve('bson')
28+
}
4529
},
46-
browser: {
47-
enabled: true,
48-
/**
49-
* Starts each test in a new iFrame
50-
*/
51-
isolate: true,
52-
provider: 'playwright',
53-
headless: true,
54-
instances: [
55-
{
56-
browser: 'chromium'
57-
}
58-
// {
59-
// browser: 'firefox'
60-
// }
61-
// This requires some additional work to get all tests passing
62-
// {
63-
// browser: 'webkit'
64-
// }
65-
]
30+
worker: {
31+
format: 'es',
32+
plugins: () => [wasm(), topLevelAwait()]
33+
},
34+
optimizeDeps: {
35+
// Don't optimise these packages as they contain web workers and WASM files.
36+
// https://github.com/vitejs/vite/issues/11672#issuecomment-1415820673
37+
exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
38+
include: ['bson', 'comlink', 'async-mutex']
39+
},
40+
plugins: [wasm(), topLevelAwait()],
41+
test: {
42+
globals: true,
43+
include: ['tests/**/*.test.ts'],
44+
maxConcurrency: 1,
45+
// This doesn't currently seem to work in browser mode, but setting this for one day when it does
46+
sequence: {
47+
shuffle: false, // Disable shuffling of test files
48+
concurrent: false // Run test files sequentially
49+
},
50+
browser: {
51+
enabled: true,
52+
/**
53+
* Starts each test in a new iFrame
54+
*/
55+
isolate: true,
56+
provider: playwright(),
57+
headless: true,
58+
instances: [
59+
{
60+
browser: 'chromium'
61+
}
62+
// {
63+
// browser: 'firefox'
64+
// }
65+
// This requires some additional work to get all tests passing
66+
// {
67+
// browser: 'webkit'
68+
// }
69+
]
70+
}
6671
}
67-
}
68-
};
69-
70-
export default defineConfig(config);
72+
} satisfies ViteUserConfigExport;
73+
});

0 commit comments

Comments
 (0)