Skip to content

Commit 0129d08

Browse files
committed
Upgrade vitest to v4
1 parent 1c5bb4d commit 0129d08

File tree

51 files changed

+1407
-1030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1407
-1030
lines changed

eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ const config = createConfig([
131131
// We should enable this instead, but the rule is unreleased.
132132
// See https://github.com/vitest-dev/eslint-plugin-vitest/issues/591
133133
// 'vitest/unbound-method': 'error',
134+
'vitest/no-alias-methods': 'off',
135+
'vitest/prefer-called-exactly-once-with': 'off',
134136
},
135137
},
136138

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
"@typescript-eslint/eslint-plugin": "^8.29.0",
7171
"@typescript-eslint/parser": "^8.29.0",
7272
"@typescript-eslint/utils": "^8.29.0",
73-
"@vitest/coverage-v8": "^3.2.4",
74-
"@vitest/eslint-plugin": "^1.3.4",
73+
"@vitest/coverage-v8": "^4.0.16",
74+
"@vitest/eslint-plugin": "^1.6.5",
7575
"@yarnpkg/types": "^4.0.1",
7676
"depcheck": "^1.4.7",
7777
"eslint": "^9.23.0",
@@ -97,9 +97,9 @@
9797
"typedoc": "^0.28.1",
9898
"typescript": "~5.8.2",
9999
"typescript-eslint": "^8.29.0",
100-
"vite": "^7.1.2",
101-
"vite-tsconfig-paths": "^5.1.4",
102-
"vitest": "^3.2.4",
100+
"vite": "^7.3.0",
101+
"vite-tsconfig-paths": "^6.0.3",
102+
"vitest": "^4.0.16",
103103
"vitest-fetch-mock": "^0.4.5"
104104
},
105105
"packageManager": "[email protected]",

packages/brow-2-brow/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"turbo": "^2.5.6",
7373
"typescript": "~5.8.2",
7474
"typescript-eslint": "^8.29.0",
75-
"vitest": "^3.2.4"
75+
"vitest": "^4.0.16"
7676
},
7777
"eslintConfig": {
7878
"extends": "ipfs",

packages/cli/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"@typescript-eslint/eslint-plugin": "^8.29.0",
7373
"@typescript-eslint/parser": "^8.29.0",
7474
"@typescript-eslint/utils": "^8.29.0",
75-
"@vitest/eslint-plugin": "^1.3.4",
75+
"@vitest/eslint-plugin": "^1.6.5",
7676
"depcheck": "^1.4.7",
7777
"eslint": "^9.23.0",
7878
"eslint-config-prettier": "^10.1.1",
@@ -82,16 +82,16 @@
8282
"eslint-plugin-n": "^17.17.0",
8383
"eslint-plugin-prettier": "^5.2.6",
8484
"eslint-plugin-promise": "^7.2.1",
85-
"jsdom": "^26.0.0",
85+
"jsdom": "^27.4.0",
8686
"prettier": "^3.5.3",
8787
"rimraf": "^6.0.1",
8888
"ses": "^1.14.0",
8989
"turbo": "^2.5.6",
9090
"typedoc": "^0.28.1",
9191
"typescript": "~5.8.2",
9292
"typescript-eslint": "^8.29.0",
93-
"vite": "^7.1.2",
94-
"vitest": "^3.2.4"
93+
"vite": "^7.3.0",
94+
"vitest": "^4.0.16"
9595
},
9696
"engines": {
9797
"node": "^20.11 || >=22"

packages/cli/src/commands/watch.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('watch', () => {
3838

3939
beforeEach(() => {
4040
logger = new Logger('test');
41+
vi.mocked(bundleFile).mockClear();
4142
});
4243

4344
describe('watchDir', () => {

packages/cli/src/file.test.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { dirname, join } from 'node:path';
2-
import { describe, it, expect, vi } from 'vitest';
2+
import { describe, it, expect, vi, beforeEach } from 'vitest';
33

44
import { cp, fileExists, isDirectory } from './file.ts';
55

@@ -24,6 +24,12 @@ const makeTestError = (code?: string): Error & { code?: string } => {
2424
};
2525

2626
describe('file', () => {
27+
beforeEach(() => {
28+
mocks.access.mockClear();
29+
mocks.lstat.mockClear();
30+
mocks.copyFile.mockClear();
31+
});
32+
2733
describe('isDirectory', () => {
2834
it('should return true if the path is a directory', async () => {
2935
mocks.lstat.mockResolvedValue({ isDirectory: () => true });
@@ -48,14 +54,14 @@ describe('file', () => {
4854
it('should throw an error if lstat throws an error with unknown code', async () => {
4955
const error = makeTestError('UNKNOWN');
5056
mocks.lstat.mockRejectedValue(error);
51-
await expect(isDirectory('test')).rejects.toThrow(error);
57+
await expect(isDirectory('test')).rejects.toThrowError(error);
5258
expect(mocks.lstat).toHaveBeenCalledOnce();
5359
});
5460

5561
it('should throw an error if lstat throws an error with no code', async () => {
5662
const error = makeTestError();
5763
mocks.lstat.mockRejectedValue(error);
58-
await expect(isDirectory('test')).rejects.toThrow(error);
64+
await expect(isDirectory('test')).rejects.toThrowError(error);
5965
expect(mocks.lstat).toHaveBeenCalledOnce();
6066
});
6167
});
@@ -70,7 +76,7 @@ describe('file', () => {
7076

7177
it('should throw an error if the source is a directory', async () => {
7278
mocks.lstat.mockResolvedValue({ isDirectory: () => true });
73-
await expect(cp('source', 'destination')).rejects.toThrow(
79+
await expect(cp('source', 'destination')).rejects.toThrowError(
7480
/not implemented/u,
7581
);
7682
});
@@ -98,14 +104,14 @@ describe('file', () => {
98104
it('should throw an error if access throws an error with unknown code', async () => {
99105
const error = makeTestError('UNKNOWN');
100106
mocks.access.mockRejectedValue(error);
101-
await expect(fileExists('source')).rejects.toThrow(error);
107+
await expect(fileExists('source')).rejects.toThrowError(error);
102108
expect(mocks.access).toHaveBeenCalledOnce();
103109
});
104110

105111
it('should throw an error if access throws an error with no code', async () => {
106112
const error = makeTestError();
107113
mocks.access.mockRejectedValue(error);
108-
await expect(fileExists('source')).rejects.toThrow(error);
114+
await expect(fileExists('source')).rejects.toThrowError(error);
109115
expect(mocks.access).toHaveBeenCalledOnce();
110116
});
111117
});

packages/create-package/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@typescript-eslint/eslint-plugin": "^8.29.0",
6060
"@typescript-eslint/parser": "^8.29.0",
6161
"@typescript-eslint/utils": "^8.29.0",
62-
"@vitest/eslint-plugin": "^1.3.4",
62+
"@vitest/eslint-plugin": "^1.6.5",
6363
"depcheck": "^1.4.7",
6464
"eslint": "^9.23.0",
6565
"eslint-config-prettier": "^10.1.1",
@@ -76,8 +76,8 @@
7676
"typedoc": "^0.28.1",
7777
"typescript": "~5.8.2",
7878
"typescript-eslint": "^8.29.0",
79-
"vite": "^7.1.2",
80-
"vitest": "^3.2.4",
79+
"vite": "^7.3.0",
80+
"vitest": "^4.0.16",
8181
"yargs": "^17.7.2"
8282
},
8383
"engines": {

packages/create-package/src/utils.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ describe('create-package/utils', () => {
9393

9494
beforeEach(() => {
9595
consoleErrorSpy = vi.spyOn(console, 'error');
96+
vi.mocked(execa).mockClear();
97+
vi.mocked(fs.writeFile).mockClear();
98+
vi.mocked(fs.mkdir).mockClear();
99+
vi.mocked(fs.access).mockClear();
100+
vi.mocked(fsUtils.writeFiles).mockClear();
96101
});
97102

98103
it('should write the expected files', async () => {
@@ -222,7 +227,7 @@ describe('create-package/utils', () => {
222227

223228
await expect(
224229
finalizeAndWriteData(packageData, monorepoFileData),
225-
).rejects.toThrow(/^The package directory already exists:/u);
230+
).rejects.toThrowError(/^The package directory already exists:/u);
226231

227232
expect(fs.mkdir).not.toHaveBeenCalled();
228233
expect(fs.writeFile).not.toHaveBeenCalled();
@@ -236,7 +241,7 @@ describe('create-package/utils', () => {
236241

237242
await expect(
238243
finalizeAndWriteData(packageData, monorepoFileData),
239-
).rejects.toThrow(/^foo$/u);
244+
).rejects.toThrowError(/^foo$/u);
240245
});
241246
});
242247
});

packages/extension/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
"@typescript-eslint/eslint-plugin": "^8.29.0",
7272
"@typescript-eslint/parser": "^8.29.0",
7373
"@typescript-eslint/utils": "^8.29.0",
74-
"@vitejs/plugin-react": "^4.3.4",
75-
"@vitest/eslint-plugin": "^1.3.4",
74+
"@vitejs/plugin-react": "^5.1.2",
75+
"@vitest/eslint-plugin": "^1.6.5",
7676
"depcheck": "^1.4.7",
7777
"eslint": "^9.23.0",
7878
"eslint-config-prettier": "^10.1.1",
@@ -82,7 +82,7 @@
8282
"eslint-plugin-n": "^17.17.0",
8383
"eslint-plugin-prettier": "^5.2.6",
8484
"eslint-plugin-promise": "^7.2.1",
85-
"jsdom": "^26.0.0",
85+
"jsdom": "^27.4.0",
8686
"playwright": "^1.54.2",
8787
"prettier": "^3.5.3",
8888
"rimraf": "^6.0.1",
@@ -91,10 +91,10 @@
9191
"typedoc": "^0.28.1",
9292
"typescript": "~5.8.2",
9393
"typescript-eslint": "^8.29.0",
94-
"vite": "^7.1.2",
94+
"vite": "^7.3.0",
9595
"vite-plugin-checker": "^0.9.1",
9696
"vite-plugin-static-copy": "^2.3.0",
97-
"vitest": "^3.2.4"
97+
"vitest": "^4.0.16"
9898
},
9999
"engines": {
100100
"node": "^20.11 || >=22"

packages/kernel-agents/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"@typescript-eslint/eslint-plugin": "^8.29.0",
8080
"@typescript-eslint/parser": "^8.29.0",
8181
"@typescript-eslint/utils": "^8.29.0",
82-
"@vitest/eslint-plugin": "^1.3.4",
82+
"@vitest/eslint-plugin": "^1.6.5",
8383
"depcheck": "^1.4.7",
8484
"eslint": "^9.23.0",
8585
"eslint-config-prettier": "^10.1.1",
@@ -95,8 +95,8 @@
9595
"typedoc": "^0.28.1",
9696
"typescript": "~5.8.2",
9797
"typescript-eslint": "^8.29.0",
98-
"vite": "^7.1.2",
99-
"vitest": "^3.2.4"
98+
"vite": "^7.3.0",
99+
"vitest": "^4.0.16"
100100
},
101101
"engines": {
102102
"node": "^20.11 || >=22"

0 commit comments

Comments
 (0)