initial code commit
This commit is contained in:
commit
27bb45f7df
56 changed files with 15106 additions and 0 deletions
37
client/src/__tests__/setup.ts
Normal file
37
client/src/__tests__/setup.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import '@testing-library/jest-dom';
|
||||
import { webcrypto } from 'node:crypto';
|
||||
import { beforeEach } from 'vitest';
|
||||
|
||||
// jsdom lacks WebCrypto subtle — polyfill from Node
|
||||
if (!globalThis.crypto?.subtle) {
|
||||
Object.defineProperty(globalThis, 'crypto', { value: webcrypto });
|
||||
}
|
||||
|
||||
// jsdom lacks ResizeObserver (needed by Recharts)
|
||||
class ResizeObserverMock {
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
}
|
||||
globalThis.ResizeObserver = ResizeObserverMock as unknown as typeof ResizeObserver;
|
||||
|
||||
// structuredClone polyfill for older jsdom
|
||||
if (!globalThis.structuredClone) {
|
||||
globalThis.structuredClone = (o: unknown) => JSON.parse(JSON.stringify(o));
|
||||
}
|
||||
|
||||
// Silence "not implemented: navigation" warnings from jsdom
|
||||
const originalWarn = console.warn;
|
||||
console.warn = (...args: unknown[]) => {
|
||||
if (typeof args[0] === 'string' && args[0].includes('Not implemented')) return;
|
||||
originalWarn(...args);
|
||||
};
|
||||
|
||||
// Reset cookies between tests
|
||||
beforeEach(() => {
|
||||
document.cookie.split(';').forEach((c) => {
|
||||
const name = c.split('=')[0].trim();
|
||||
if (name) document.cookie = `${name}=; max-age=0; path=/`;
|
||||
});
|
||||
localStorage.clear();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue