UNPKG

vaultace-cli

Version:

AI-powered security scanner that detects vulnerabilities in AI-generated code. Proactive scanning, autonomous fixing, and emergency response for modern development teams.

60 lines (52 loc) 1.33 kB
/** * Jest Test Setup * Global test configuration and utilities */ // Mock environment variables for tests process.env.VAULTACE_LOG_LEVEL = 'error'; // Reduce logging noise in tests process.env.NODE_ENV = 'test'; // Global test utilities global.mockAPIResponse = (data, status = 200) => ({ data, status, statusText: 'OK', headers: {}, config: {} }); global.mockAPIError = (message, status = 500) => { const error = new Error(message); error.response = { status, data: { detail: message }, headers: {} }; return error; }; // Mock console methods to avoid spam during tests const originalConsole = { ...console }; global.console = { ...console, log: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn() }; // Restore console for specific tests if needed global.restoreConsole = () => { global.console = originalConsole; }; // Mock file system operations jest.mock('fs-extra', () => ({ ensureDirSync: jest.fn(), appendFileSync: jest.fn(), writeFile: jest.fn(() => Promise.resolve()), readFile: jest.fn(() => Promise.resolve('{}')), existsSync: jest.fn(() => true), readFileSync: jest.fn(() => '{}') })); // Mock inquirer for CLI prompts jest.mock('inquirer', () => ({ prompt: jest.fn(() => Promise.resolve({})) })); // Common test timeout jest.setTimeout(10000);