mirror of
https://github.com/Lissy93/dashy.git
synced 2026-01-22 15:51:47 +01:00
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
/**
|
|
* Global test setup file
|
|
* This file is run before all tests to configure the testing environment
|
|
*/
|
|
|
|
import { config } from '@vue/test-utils';
|
|
|
|
// Suppress Vue warnings in tests
|
|
config.silent = true;
|
|
|
|
// Mock console methods to avoid noise in test output
|
|
global.console = {
|
|
...console,
|
|
// Uncomment to suppress console.log in tests
|
|
// log: vi.fn(),
|
|
// Uncomment to suppress console.debug in tests
|
|
// debug: vi.fn(),
|
|
// Keep warnings and errors visible
|
|
warn: console.warn,
|
|
error: console.error,
|
|
};
|
|
|
|
// Mock localStorage for tests
|
|
const localStorageMock = {
|
|
getItem: vi.fn(),
|
|
setItem: vi.fn(),
|
|
removeItem: vi.fn(),
|
|
clear: vi.fn(),
|
|
};
|
|
global.localStorage = localStorageMock;
|
|
|
|
// Mock sessionStorage for tests
|
|
const sessionStorageMock = {
|
|
getItem: vi.fn(),
|
|
setItem: vi.fn(),
|
|
removeItem: vi.fn(),
|
|
clear: vi.fn(),
|
|
};
|
|
global.sessionStorage = sessionStorageMock;
|
|
|
|
// Mock window.matchMedia (for responsive design tests)
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: vi.fn().mockImplementation(query => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: vi.fn(),
|
|
removeListener: vi.fn(),
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
})),
|
|
});
|