Skip to content

Commit ba6bc04

Browse files
authored
chore: Migrate to Vitest 4 (#2330)
1 parent 01f8d5c commit ba6bc04

File tree

22 files changed

+587
-652
lines changed

22 files changed

+587
-652
lines changed

apps/treeshake-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"unplugin-typegpu": "workspace:*"
1414
},
1515
"devDependencies": {
16-
"@types/node": "^20.0.0",
16+
"@types/node": "catalog:types",
1717
"arktype": "1.0.29-alpha",
1818
"esbuild": "^0.25.10",
1919
"ts-loader": "^9.5.4",

apps/typegpu-docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@
7373
"@types/babel__standalone": "^7.1.9",
7474
"@types/babel__template": "^7.4.4",
7575
"@types/babel__traverse": "^7.20.7",
76-
"@types/node": "^24.7.0",
76+
"@types/node": "catalog:types",
7777
"@types/three": "catalog:types",
7878
"@vitejs/plugin-basic-ssl": "^2.1.0",
79+
"@vitest/browser-preview": "^4.1.2",
7980
"@webgpu/types": "catalog:types",
8081
"astro-vtbot": "^2.1.10",
8182
"autoprefixer": "^10.4.21",

apps/typegpu-docs/tests/individual-example-tests/utils/commonMocks.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ export function mockFonts() {
7575
export function mockResizeObserver() {
7676
vi.stubGlobal(
7777
'ResizeObserver',
78-
vi.fn(() => ({
79-
observe: vi.fn(),
80-
unobserve: vi.fn(),
81-
disconnect: vi.fn(),
82-
})),
78+
vi.fn(function () {
79+
return {
80+
observe: vi.fn(),
81+
unobserve: vi.fn(),
82+
disconnect: vi.fn(),
83+
};
84+
}),
8385
);
8486
}
8587

@@ -158,12 +160,14 @@ const mockAudioBufferSourceNode = {
158160
export function mockAudioLoading() {
159161
vi.stubGlobal(
160162
'AudioContext',
161-
vi.fn(() => ({
162-
createGain: vi.fn(() => mockGainNode),
163-
destination: {},
164-
createBufferSource: vi.fn(() => mockAudioBufferSourceNode),
165-
decodeAudioData: vi.fn(async () => null),
166-
})),
163+
vi.fn(function () {
164+
return {
165+
createGain: vi.fn(() => mockGainNode),
166+
destination: {},
167+
createBufferSource: vi.fn(() => mockAudioBufferSourceNode),
168+
decodeAudioData: vi.fn(async () => null),
169+
};
170+
}),
167171
);
168172

169173
if (fetchMockMap.has(audioRegExp)) return;

apps/typegpu-docs/tests/individual-example-tests/utils/testUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export function getExampleURLs(
66
ts: string;
77
} {
88
return {
9-
html: `../../../../../apps/typegpu-docs/src/examples/${category}/${name}/index.html?raw`,
10-
ts: `../../../../../apps/typegpu-docs/src/examples/${category}/${name}/index.ts`,
9+
html: `../../../src/examples/${category}/${name}/index.html?raw`,
10+
ts: `../../../src/examples/${category}/${name}/index.ts`,
1111
};
1212
}
1313

apps/typegpu-docs/vitest.config.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createJiti } from 'jiti';
22
import type TypeGPUPlugin from 'unplugin-typegpu/vite';
33
import { imagetools } from 'vite-imagetools';
44
import { defineConfig, type Plugin } from 'vitest/config';
5+
import { preview } from '@vitest/browser-preview';
56

67
const jiti = createJiti(import.meta.url);
78
const typegpu = await jiti.import<typeof TypeGPUPlugin>('unplugin-typegpu/vite', { default: true });
@@ -25,7 +26,7 @@ export default defineConfig({
2526
name: 'browser',
2627
include: ['**/*.{test,spec}.browser.ts'],
2728
browser: {
28-
provider: 'preview',
29+
provider: preview(),
2930
instances: [{ browser: 'chromium' }],
3031
},
3132
},

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"rollup": "catalog:build",
7171
"vite": "8.0.2",
7272
"@babel/types": "catalog:",
73+
"@types/node": "catalog:types",
7374
"typescript": "catalog:types",
7475
"three": "catalog:example",
7576
"@typescript-eslint/utils": "^8.57.2"

packages/eslint-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@typescript-eslint/utils": "^8.57.2"
5151
},
5252
"devDependencies": {
53-
"@types/node": "^25.0.10",
53+
"@types/node": "catalog:types",
5454
"@typescript-eslint/rule-tester": "^8.57.2",
5555
"eslint": "^9.39.2",
5656
"eslint-doc-generator": "^3.3.2",

packages/typegpu-gl/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"scripts": {
2828
"build": "tsdown",
29-
"test:types": "pnpm tsc --p ./tsconfig.json --noEmit",
29+
"test:types": "pnpm tsc --p ./tsconfig.json --noEmit && pnpm tsc --p ./tsconfig.test.json --noEmit",
3030
"prepublishOnly": "tgpu-dev-cli prepack"
3131
},
3232
"devDependencies": {
@@ -35,6 +35,7 @@
3535
"tinyest": "workspace:^0.3.0",
3636
"tsdown": "catalog:build",
3737
"typegpu": "workspace:*",
38+
"typegpu-testing-utility": "workspace:*",
3839
"typescript": "catalog:types",
3940
"unbuild": "catalog:build",
4041
"unplugin-typegpu": "workspace:*"

packages/typegpu-gl/tests/utils/extendedTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { it as base, vi } from 'vitest';
1+
import { test as base, vi } from 'vitest';
22
// oxlint-disable-next-line import/no-unassigned-import -- imported for side effects
3-
import './webgpuGlobals.ts';
3+
import 'typegpu-testing-utility';
44

55
function createMockOffscreenCanvas(width = 256, height = 256) {
66
const canvas = {

packages/typegpu-gl/tests/utils/webgpuGlobals.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)