Add experiment logs to the monitoring page #48
@@ -1,2 +1,46 @@
|
||||
// Adds jest-dom matchers for React testing library
|
||||
import '@testing-library/jest-dom';
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
// Minimal browser API mocks for the test environment.
|
||||
// Fetch
|
||||
if (!globalThis.fetch) {
|
||||
globalThis.fetch = jest.fn(async () => ({
|
||||
ok: true,
|
||||
status: 200,
|
||||
json: async () => [],
|
||||
text: async () => '',
|
||||
})) as unknown as typeof fetch;
|
||||
}
|
||||
|
||||
// EventSource
|
||||
if (!globalThis.EventSource) {
|
||||
class MockEventSource {
|
||||
url: string;
|
||||
readyState = 1;
|
||||
onmessage: ((event: MessageEvent) => void) | null = null;
|
||||
onerror: ((event: Event) => void) | null = null;
|
||||
onopen: ((event: Event) => void) | null = null;
|
||||
|
||||
constructor(url: string) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
close() {
|
||||
this.readyState = 2;
|
||||
}
|
||||
|
||||
addEventListener(type: string, listener: (event: MessageEvent) => void) {
|
||||
if (type === 'message') {
|
||||
this.onmessage = listener;
|
||||
}
|
||||
}
|
||||
|
||||
removeEventListener(type: string, listener: (event: MessageEvent) => void) {
|
||||
if (type === 'message' && this.onmessage === listener) {
|
||||
this.onmessage = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
globalThis.EventSource = MockEventSource as unknown as typeof EventSource;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user