Migrate more jest tests to vitest (#33898)

* Migrate more jest tests to vitest

* Fix jest config

* Fix jest config

* Make remaining jest tests type-happy
This commit is contained in:
Michael Telatynski
2026-06-19 15:34:18 +00:00
committed by GitHub
parent fab71c80ed
commit 45234b9c94
62 changed files with 625 additions and 488 deletions
+6 -4
View File
@@ -6,11 +6,13 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
Please see LICENSE files in the repository root for full details.
*/
import { type MethodLikeKeys, mocked, type MockedObject } from "jest-mock";
import { type MethodLikeKeys } from "jest-mock";
import { type MockedObject } from "vitest";
import BasePlatform from "../../src/BasePlatform";
import PlatformPeg from "../../src/PlatformPeg";
import * as SessionLock from "../../src/utils/SessionLock";
import { vi } from "../setup/adapter.ts";
// doesn't implement abstract
// @ts-ignore
@@ -38,10 +40,10 @@ export const mockPlatformPeg = (
platformMocks: Partial<Record<MethodLikeKeys<BasePlatform>, unknown>> = {},
): MockedObject<BasePlatform> => {
const mockPlatform = new MockPlatform(platformMocks);
jest.spyOn(PlatformPeg, "get").mockReturnValue(mockPlatform);
return mocked(mockPlatform);
vi.spyOn(PlatformPeg, "get").mockReturnValue(mockPlatform);
return vi.mocked(mockPlatform);
};
export const unmockPlatformPeg = () => {
jest.spyOn(PlatformPeg, "get").mockRestore();
vi.spyOn(PlatformPeg, "get").mockRestore();
};