mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
d37e95918c
Three critical fixes for CI test failures: 1. Remove duplicate Logger mock - Deleted tests/cli/__mocks__/Logger.ts - Prevents 'duplicate manual mock found' error - Keep comprehensive mock in src/utils/__mocks__/ 2. Fix hardcoded DevPod path in jest.global-setup.ts - Changed from /workspaces/agentic-qe-cf to dynamic process.cwd() - Prevents ENOENT errors in GitHub Actions - Works in both DevPod and CI environments 3. Add workflow permissions for MCP Test Summary - Added pull-requests: write permission - Added checks: write permission - Fixes 403 'Resource not accessible by integration' error These fixes ensure MCP tests run properly in CI/CD pipeline. Addresses errors: - jest-haste-map: duplicate manual mock found: Logger - ENOENT: no such file or directory, chdir -> '/workspaces/agentic-qe-cf' - HttpError: Resource not accessible by integration (403)
35 lines
935 B
TypeScript
35 lines
935 B
TypeScript
/**
|
|
* Jest Global Setup
|
|
*
|
|
* Runs ONCE before ALL test suites begin execution.
|
|
* Sets up the test environment to prevent process.cwd() errors.
|
|
*/
|
|
|
|
const path = require('path');
|
|
|
|
module.exports = async () => {
|
|
// Determine workspace root dynamically
|
|
const WORKSPACE_ROOT = process.cwd();
|
|
|
|
console.log('✅ Global test environment initialized');
|
|
console.log(` Working directory: ${WORKSPACE_ROOT}`);
|
|
|
|
// Set environment variables
|
|
process.env.INIT_CWD = WORKSPACE_ROOT;
|
|
process.env.PWD = WORKSPACE_ROOT;
|
|
process.env.NODE_ENV = 'test';
|
|
process.env.LOG_LEVEL = 'error';
|
|
|
|
// Mock process.cwd globally before any modules load
|
|
const originalCwd = process.cwd.bind(process);
|
|
process.cwd = function() {
|
|
try {
|
|
const cwd = originalCwd();
|
|
return cwd && cwd !== '' ? cwd : WORKSPACE_ROOT;
|
|
} catch (error) {
|
|
// Fallback to workspace root if cwd fails
|
|
return WORKSPACE_ROOT;
|
|
}
|
|
};
|
|
};
|