Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

1.4 KB
Raw Blame
/**
 * Global test setup file
 * This file is run before all tests to configure the testing environment
 */

// Suppress noisy console methods in test output
// Vue dev mode prints info messages (devtools, production tips) that clutter results
global.console = {
  ...console,
  info: vi.fn(),
  // 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, // eslint-disable-line no-console
  error: console.error, // eslint-disable-line no-console
};

// Mock localStorage for tests
const localStorageMock = {
  getItem: vi.fn(),
  setItem: vi.fn(),
  removeItem: vi.fn(),
  clear: vi.fn(),
};
vi.stubGlobal('localStorage', localStorageMock);

// Mock sessionStorage for tests
const sessionStorageMock = {
  getItem: vi.fn(),
  setItem: vi.fn(),
  removeItem: vi.fn(),
  clear: vi.fn(),
};
vi.stubGlobal('sessionStorage', sessionStorageMock);

// Mock window.matchMedia (for responsive design tests, skipped in Node environment)
if (typeof window !== 'undefined') 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(),
  })),
});