import '@testing-library/jest-dom/vitest' import { cleanup } from '@testing-library/react' import { afterEach } from 'vitest' afterEach(cleanup) // Conveniences kept in the browser, such as the sidebar's state, would carry over between tests. afterEach(() => localStorage.clear()) // index.html carries the app name, filled in by the server. const appName = document.createElement('meta') appName.name = 'application-name' appName.content = 'SCN Chat' document.head.append(appName) // jsdom has no ResizeObserver. Tests that need resize callbacks stub their own. globalThis.ResizeObserver ??= class { observe() {} unobserve() {} disconnect() {} } as unknown as typeof ResizeObserver // jsdom has no scrolling. The router restores scroll positions on navigation. window.scrollTo = () => {} // Node's object URLs take only Node's blobs, not jsdom's files. The composer previews attached // images with them. URL.createObjectURL = () => 'blob:preview' URL.revokeObjectURL = () => {}