- 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>
55 lines
3.1 KiB
TypeScript
55 lines
3.1 KiB
TypeScript
import "jest-runtime";
|
|
import { SerializableError, Test, Test as Test$1, TestEvents, TestEvents as TestEvents$1, TestResult } from "@jest/test-result";
|
|
import { TestWatcher, TestWatcher as TestWatcher$1 } from "jest-watcher";
|
|
import { Config, Config as Config$1 } from "@jest/types";
|
|
|
|
//#region src/types.d.ts
|
|
|
|
type OnTestStart = (test: Test$1) => Promise<void>;
|
|
type OnTestFailure = (test: Test$1, serializableError: SerializableError) => Promise<void>;
|
|
type OnTestSuccess = (test: Test$1, testResult: TestResult) => Promise<void>;
|
|
type TestRunnerOptions = {
|
|
serial: boolean;
|
|
};
|
|
type TestRunnerContext = {
|
|
changedFiles?: Set<string>;
|
|
sourcesRelatedToTestsInChangedFiles?: Set<string>;
|
|
};
|
|
type UnsubscribeFn = () => void;
|
|
interface CallbackTestRunnerInterface {
|
|
readonly isSerial?: boolean;
|
|
readonly supportsEventEmitters?: boolean;
|
|
runTests(tests: Array<Test$1>, watcher: TestWatcher$1, onStart: OnTestStart, onResult: OnTestSuccess, onFailure: OnTestFailure, options: TestRunnerOptions): Promise<void>;
|
|
}
|
|
interface EmittingTestRunnerInterface {
|
|
readonly isSerial?: boolean;
|
|
readonly supportsEventEmitters: true;
|
|
runTests(tests: Array<Test$1>, watcher: TestWatcher$1, options: TestRunnerOptions): Promise<void>;
|
|
on<Name extends keyof TestEvents$1>(eventName: Name, listener: (eventData: TestEvents$1[Name]) => void | Promise<void>): UnsubscribeFn;
|
|
}
|
|
declare abstract class BaseTestRunner {
|
|
protected readonly _globalConfig: Config$1.GlobalConfig;
|
|
protected readonly _context: TestRunnerContext;
|
|
readonly isSerial?: boolean;
|
|
abstract readonly supportsEventEmitters: boolean;
|
|
constructor(_globalConfig: Config$1.GlobalConfig, _context: TestRunnerContext);
|
|
}
|
|
declare abstract class CallbackTestRunner extends BaseTestRunner implements CallbackTestRunnerInterface {
|
|
readonly supportsEventEmitters = false;
|
|
abstract runTests(tests: Array<Test$1>, watcher: TestWatcher$1, onStart: OnTestStart, onResult: OnTestSuccess, onFailure: OnTestFailure, options: TestRunnerOptions): Promise<void>;
|
|
}
|
|
declare abstract class EmittingTestRunner extends BaseTestRunner implements EmittingTestRunnerInterface {
|
|
readonly supportsEventEmitters = true;
|
|
abstract runTests(tests: Array<Test$1>, watcher: TestWatcher$1, options: TestRunnerOptions): Promise<void>;
|
|
abstract on<Name extends keyof TestEvents$1>(eventName: Name, listener: (eventData: TestEvents$1[Name]) => void | Promise<void>): UnsubscribeFn;
|
|
}
|
|
type JestTestRunner = CallbackTestRunner | EmittingTestRunner;
|
|
//#endregion
|
|
//#region src/index.d.ts
|
|
declare class TestRunner extends EmittingTestRunner {
|
|
#private;
|
|
runTests(tests: Array<Test$1>, watcher: TestWatcher$1, options: TestRunnerOptions): Promise<void>;
|
|
on<Name extends keyof TestEvents$1>(eventName: Name, listener: (eventData: TestEvents$1[Name]) => void | Promise<void>): UnsubscribeFn;
|
|
}
|
|
//#endregion
|
|
export { CallbackTestRunner, CallbackTestRunnerInterface, Config, EmittingTestRunner, EmittingTestRunnerInterface, JestTestRunner, OnTestFailure, OnTestStart, OnTestSuccess, Test, TestEvents, TestRunnerContext, TestRunnerOptions, TestWatcher, UnsubscribeFn, TestRunner as default }; |