Skip to content

Commit 8b66f99

Browse files
committed
feat: migrate to vitest v4
Signed-off-by: Denis Golovin <dgolovin@redhat.com>
1 parent 4229b5b commit 8b66f99

File tree

5 files changed

+173
-315
lines changed

5 files changed

+173
-315
lines changed
Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,65 +15,75 @@
1515
*
1616
* SPDX-License-Identifier: Apache-2.0
1717
***********************************************************************/
18+
/* eslint-disable @typescript-eslint/no-implicit-any */
19+
20+
import { ProgressOptions } from "@podman-desktop/api";
21+
import { vi } from "vitest";
1822

1923
/**
2024
* Mock the extension API for vitest.
2125
* This file is referenced from vitest.config.js file.
2226
*/
23-
const plugin = {
24-
EventEmitter: vi.fn().mockImplementation(() => {
25-
return {
26-
fire: vi.fn(),
27-
};
28-
}),
29-
registry: {
27+
28+
export const registry = {
3029
suggestRegistry: vi.fn(),
3130
unregisterRegistry: vi.fn(),
32-
},
33-
authentication: {
34-
registerAuthenticationProvider: vi.fn(),
35-
getSession: vi.fn(),
36-
onDidChangeSessions: vi.fn(),
37-
},
38-
commands: {
31+
};
32+
export const commands = {
3933
registerCommand: vi.fn(),
4034
executeCommand: vi.fn(),
41-
},
42-
window: {
43-
createStatusBarItem: () => ({
44-
show: vi.fn(),
45-
iconClass: '',
46-
}),
47-
withProgress: (_options, callback) => {
35+
};
36+
export const window = {
37+
createStatusBarItem: () => {
38+
return {
39+
show: vi.fn(),
40+
iconClass: '',
41+
};
42+
},
43+
withProgress: (_options: ProgressOptions, callback: (option: any) => void) => {
4844
return callback({
4945
report: () => {},
5046
});
5147
},
5248
showInformationMessage: vi.fn(),
53-
},
54-
env: {
55-
createTelemetryLogger: vi.fn().mockImplementation(() => ({
56-
logUsage: vi.fn(),
57-
logError: vi.fn(),
58-
})),
59-
},
60-
StatusBarAlignLeft: 'LEFT',
61-
ProgressLocation: {
49+
};
50+
51+
export const StatusBarAlignLeft = 'LEFT';
52+
export const ProgressLocation = {
6253
TASK_WIDGET: 2,
63-
},
64-
process: {
54+
};
55+
export const process = {
6556
exec: vi.fn(),
66-
},
67-
configuration: {
57+
};
58+
59+
export const configuration = {
6860
getConfiguration: () => {
6961
return {
7062
get: vi.fn(),
7163
};
7264
},
73-
},
74-
extensions: {
65+
};
66+
67+
export const extensions = {
7568
getExtension: vi.fn(),
76-
}
69+
};
70+
71+
export const env = {
72+
createTelemetryLogger: vi.fn().mockImplementation(() => ({
73+
logUsage: vi.fn(),
74+
logError: vi.fn(),
75+
})),
76+
};
77+
78+
export const authentication = {
79+
registerAuthenticationProvider: vi.fn(),
80+
getSession: vi.fn(),
81+
onDidChangeSessions: vi.fn(),
82+
};
83+
84+
export class EventEmitter {
85+
constructor() {};
86+
fire = vi.fn();
7787
};
7888

79-
module.exports = plugin;
89+

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"@types/node": "^25",
6565
"@typescript-eslint/eslint-plugin": "^8.50.0",
6666
"@typescript-eslint/parser": "^6.21.0",
67-
"@vitest/coverage-v8": "^3.2.4",
67+
"@vitest/coverage-v8": "^4.0.16",
6868
"byline": "^5.0.0",
6969
"copyfiles": "^2.4.1",
7070
"cross-env": "^10.1.0",
@@ -84,7 +84,7 @@
8484
"tslib": "^2.8.1",
8585
"typescript": "^5.9.3",
8686
"vite": "^7.3.0",
87-
"vitest": "^3.2.4",
87+
"vitest": "^4.0.16",
8888
"xvfb-maybe": "^0.2.1",
8989
"adm-zip": "^0.5.16"
9090
},

0 commit comments

Comments
 (0)