Files
hive/frontend/node_modules/@jest/reporters/build/CoverageWorker.mjs
anthonyrawlins aacb45156b Set up comprehensive frontend testing infrastructure
- 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>
2025-07-11 14:06:34 +10:00

67 lines
2.2 KiB
JavaScript

import exit from "exit-x";
import * as fs$1 from "graceful-fs";
import * as fs from "graceful-fs";
import { createFileCoverage } from "istanbul-lib-coverage";
import { readInitialCoverage } from "istanbul-lib-instrument";
import { createScriptTransformer, shouldInstrument } from "@jest/transform";
//#region src/generateEmptyCoverage.ts
async function generateEmptyCoverage(source, filename, globalConfig, config, changedFiles, sourcesRelatedToTestsInChangedFiles) {
const coverageOptions = {
changedFiles,
collectCoverage: globalConfig.collectCoverage,
collectCoverageFrom: globalConfig.collectCoverageFrom,
coverageProvider: globalConfig.coverageProvider,
sourcesRelatedToTestsInChangedFiles
};
let coverageWorkerResult = null;
if (shouldInstrument(filename, coverageOptions, config)) {
if (coverageOptions.coverageProvider === "v8") {
const stat = fs$1.statSync(filename);
return {
kind: "V8Coverage",
result: {
functions: [{
functionName: "(empty-report)",
isBlockCoverage: true,
ranges: [{
count: 0,
endOffset: stat.size,
startOffset: 0
}]
}],
scriptId: "0",
url: filename
}
};
}
const scriptTransformer = await createScriptTransformer(config);
const { code } = await scriptTransformer.transformSourceAsync(filename, source, {
instrument: true,
supportsDynamicImport: true,
supportsExportNamespaceFrom: true,
supportsStaticESM: true,
supportsTopLevelAwait: true
});
const extracted = readInitialCoverage(code);
if (extracted) coverageWorkerResult = {
coverage: createFileCoverage(extracted.coverageData),
kind: "BabelCoverage"
};
}
return coverageWorkerResult;
}
//#endregion
//#region src/CoverageWorker.ts
process.on("uncaughtException", (err) => {
if (err.stack) console.error(err.stack);
else console.error(err);
exit(1);
});
function worker({ config, globalConfig, path, context }) {
return generateEmptyCoverage(fs.readFileSync(path, "utf8"), path, globalConfig, config, context.changedFiles && new Set(context.changedFiles), context.sourcesRelatedToTestsInChangedFiles && new Set(context.sourcesRelatedToTestsInChangedFiles));
}
//#endregion
export { worker };