Files
Claude-Code-Monitor/client/src/test-setup.ts
T
nntrivi2001 9b8d9bbe39 feat(run): add TerminalView xterm.js component for the PTY transport
- TerminalView.tsx: xterm.js component with WebSocket attachment to /ws-pty/:runId
- Test: validates WS connection URL, incoming terminal data, and outgoing keystrokes
- Added ResizeObserver stub to test-setup.ts for jsdom environment
2026-08-12 10:19:10 +07:00

35 lines
1.1 KiB
TypeScript

/**
* @file test-setup.ts
* @description Vitest global setup for the React client test suite. Pulls in
* jest-dom matchers, initializes the real i18n bundle (same as production),
* forces English before each test for deterministic assertions, and runs
* Testing Library cleanup after every test to prevent DOM leakage between cases.
*
* Imported from `vitest.config.ts` via `setupFiles`.
*
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
import "@testing-library/jest-dom/vitest";
import { cleanup } from "@testing-library/react";
import { afterEach, beforeEach } from "vitest";
import "./i18n/index";
import i18n from "i18next";
/** jsdom does not implement ResizeObserver — stub it for components that use it. */
// @ts-expect-error global stub
global.ResizeObserver = class {
observe() {}
disconnect() {}
};
/** Pin locale to English — LanguageDetector may otherwise pick up zh/vi from the host OS. */
beforeEach(() => {
i18n.changeLanguage("en");
});
/** Unmount rendered trees and reset the document between tests. */
afterEach(() => {
cleanup();
});