- Install Jest for unit testing with React Testing Library - Install Playwright for end-to-end testing - Configure Jest with proper TypeScript support and module mapping - Create test setup files and utilities for both unit and e2e tests Components: * Jest configuration with coverage thresholds * Playwright configuration with browser automation * Unit tests for LoginForm, AuthContext, and useSocketIO hook * E2E tests for authentication, dashboard, and agents workflows * GitHub Actions workflow for automated testing * Mock data and API utilities for consistent testing * Test documentation with best practices Testing features: - Unit tests with 70% coverage threshold - E2E tests with API mocking and user journey testing - CI/CD integration for automated test runs - Cross-browser testing support with Playwright - Authentication system testing end-to-end 🚀 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { FileCoverage } from "istanbul-lib-coverage";
|
|
import { Config } from "@jest/types";
|
|
import { V8Coverage } from "collect-v8-coverage";
|
|
|
|
//#region src/generateEmptyCoverage.d.ts
|
|
|
|
type SingleV8Coverage = V8Coverage[number];
|
|
type CoverageWorkerResult = {
|
|
kind: 'BabelCoverage';
|
|
coverage: FileCoverage;
|
|
} | {
|
|
kind: 'V8Coverage';
|
|
result: SingleV8Coverage;
|
|
};
|
|
//#endregion
|
|
//#region src/types.d.ts
|
|
|
|
type ReporterContext = {
|
|
firstRun: boolean;
|
|
previousSuccess: boolean;
|
|
changedFiles?: Set<string>;
|
|
sourcesRelatedToTestsInChangedFiles?: Set<string>;
|
|
startRun?: (globalConfig: Config.GlobalConfig) => unknown;
|
|
};
|
|
//#endregion
|
|
//#region src/CoverageWorker.d.ts
|
|
type SerializeSet<T> = T extends Set<infer U> ? Array<U> : T;
|
|
type CoverageReporterContext = Pick<ReporterContext, 'changedFiles' | 'sourcesRelatedToTestsInChangedFiles'>;
|
|
type CoverageReporterSerializedContext = { [K in keyof CoverageReporterContext]: SerializeSet<ReporterContext[K]> };
|
|
type CoverageWorkerData = {
|
|
config: Config.ProjectConfig;
|
|
context: CoverageReporterSerializedContext;
|
|
globalConfig: Config.GlobalConfig;
|
|
path: string;
|
|
};
|
|
declare function worker({
|
|
config,
|
|
globalConfig,
|
|
path,
|
|
context
|
|
}: CoverageWorkerData): Promise<CoverageWorkerResult | null>;
|
|
//#endregion
|
|
export { CoverageWorkerData, worker }; |