 aacb45156b
			
		
	
	aacb45156b
	
	
	
		
			
			- 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>
		
			
				
	
	
		
			73 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import module from 'node:module';
 | |
| import path from 'node:path';
 | |
| import { fileURLToPath } from 'node:url';
 | |
| import { parentPort, workerData, } from 'node:worker_threads';
 | |
| import { MODULE_REGISTER_SUPPORTED } from './constants.js';
 | |
| import { extractProperties, overrideStdio, startWorkerThread, } from './helpers.js';
 | |
| export * from './common.js';
 | |
| export * from './constants.js';
 | |
| export * from './helpers.js';
 | |
| export * from './types.js';
 | |
| let syncFnCache;
 | |
| export function createSyncFn(workerPath, timeoutOrOptions) {
 | |
|     syncFnCache ?? (syncFnCache = new Map());
 | |
|     if (typeof workerPath !== 'string' || workerPath.startsWith('file://')) {
 | |
|         workerPath = fileURLToPath(workerPath);
 | |
|     }
 | |
|     const cachedSyncFn = syncFnCache.get(workerPath);
 | |
|     if (cachedSyncFn) {
 | |
|         return cachedSyncFn;
 | |
|     }
 | |
|     if (!path.isAbsolute(workerPath)) {
 | |
|         throw new Error('`workerPath` must be absolute');
 | |
|     }
 | |
|     const syncFn = startWorkerThread(workerPath, typeof timeoutOrOptions === 'number'
 | |
|         ? { timeout: timeoutOrOptions }
 | |
|         : timeoutOrOptions);
 | |
|     syncFnCache.set(workerPath, syncFn);
 | |
|     return syncFn;
 | |
| }
 | |
| export function runAsWorker(fn) {
 | |
|     if (!workerData) {
 | |
|         return;
 | |
|     }
 | |
|     const stdio = [];
 | |
|     overrideStdio(stdio);
 | |
|     const { workerPort, sharedBufferView, pnpLoaderPath } = workerData;
 | |
|     if (pnpLoaderPath && MODULE_REGISTER_SUPPORTED) {
 | |
|         module.register(pnpLoaderPath);
 | |
|     }
 | |
|     parentPort.on('message', ({ id, args }) => {
 | |
|         ;
 | |
|         (async () => {
 | |
|             let isAborted = false;
 | |
|             const handleAbortMessage = (msg) => {
 | |
|                 if (msg.id === id && msg.cmd === 'abort') {
 | |
|                     isAborted = true;
 | |
|                 }
 | |
|             };
 | |
|             workerPort.on('message', handleAbortMessage);
 | |
|             let msg;
 | |
|             try {
 | |
|                 msg = { id, stdio, result: await fn(...args) };
 | |
|             }
 | |
|             catch (error) {
 | |
|                 msg = { id, stdio, error, properties: extractProperties(error) };
 | |
|             }
 | |
|             workerPort.off('message', handleAbortMessage);
 | |
|             if (isAborted) {
 | |
|                 stdio.length = 0;
 | |
|                 return;
 | |
|             }
 | |
|             try {
 | |
|                 workerPort.postMessage(msg);
 | |
|                 Atomics.add(sharedBufferView, 0, 1);
 | |
|                 Atomics.notify(sharedBufferView, 0);
 | |
|             }
 | |
|             finally {
 | |
|                 stdio.length = 0;
 | |
|             }
 | |
|         })();
 | |
|     });
 | |
| }
 | |
| //# sourceMappingURL=index.js.map
 |