Files
photoprism/frontend/tests/vitest/setup.js
Ömer Duran 4f04ffe133 Frontend: Integrate Vitest test framework #4990
- Includes fixtures and mocks system for API and models as well as npm scripts for running tests, watch mode, coverage and UI
- Adds test setup with JSDOM environment and utility function tests
- Converts marker model tests from Mocha/Chai to Vitest
2025-05-06 16:18:39 +02:00

60 lines
1.1 KiB
JavaScript

import "@testing-library/jest-dom";
import { cleanup } from "@testing-library/react";
import { afterEach, vi, beforeAll } from "vitest";
import { setupCommonMocks } from "./fixtures";
global.window = global.window || {};
global.window.__CONFIG__ = {
debug: false,
trace: false,
};
global.window.location = {
protocol: "https:",
};
global.navigator = {
userAgent: "node.js",
maxTouchPoints: 0,
};
afterEach(() => {
cleanup();
});
beforeAll(() => {
setupCommonMocks();
});
vi.mock("luxon", () => ({
DateTime: {
fromISO: vi.fn().mockReturnValue({
toLocaleString: vi.fn().mockReturnValue("2023-10-01 10:00:00"),
}),
DATETIME_MED: {},
DATETIME_MED_WITH_WEEKDAY: {},
DATE_MED: {},
TIME_24_SIMPLE: {},
},
Settings: {
defaultLocale: "en",
defaultZoneName: "UTC",
},
}));
vi.mock("common/gettext", () => ({
$gettext: vi.fn((text) => text),
}));
vi.mock("app/session", () => ({
$config: {},
}));
vi.mock("common/notify", () => ({
default: {
success: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
},
}));