409e92d6ae
Build and Push Docker Images / Build Docker Image (push) Has been cancelled
Build and Push Docker Images / Build Railway Docker Image (push) Has been cancelled
Build and Publish n8n Docker Image / test-image (push) Has been cancelled
Dependency Compatibility Check / Fresh Install Dependency Check (push) Has been cancelled
Build and Publish n8n Docker Image / build-and-push (push) Has been cancelled
Build and Publish n8n Docker Image / create-release (push) Has been cancelled
Automated Release / Detect Version Change (push) Has been cancelled
Automated Release / Generate Release Notes (push) Has been cancelled
Automated Release / Create GitHub Release (push) Has been cancelled
Automated Release / Package MCPB Bundle (push) Has been cancelled
Automated Release / Build and Verify (push) Has been cancelled
Automated Release / Publish to NPM (push) Has been cancelled
Automated Release / Build and Push Docker Images (push) Has been cancelled
Automated Release / Update Documentation (push) Has been cancelled
Automated Release / Notify Release Completion (push) Has been cancelled
Secret Scan / secretlint (push) Has been cancelled
Test Suite / test (push) Has been cancelled
Test Suite / cjs-runtime (push) Has been cancelled
Test Suite / publish-results (push) Has been cancelled
70 lines
1.9 KiB
TypeScript
70 lines
1.9 KiB
TypeScript
import { beforeEach, afterEach, vi } from 'vitest';
|
|
import { loadTestEnvironment, getTestConfig, getTestTimeout } from './test-env';
|
|
|
|
// CI Debug: Log environment loading in CI only
|
|
if (process.env.CI === 'true') {
|
|
console.log('[CI-DEBUG] Global setup starting, NODE_ENV:', process.env.NODE_ENV);
|
|
}
|
|
|
|
// Load test environment configuration
|
|
loadTestEnvironment();
|
|
|
|
if (process.env.CI === 'true') {
|
|
console.log('[CI-DEBUG] Global setup complete, N8N_API_URL:', process.env.N8N_API_URL);
|
|
}
|
|
|
|
// Get test configuration
|
|
const testConfig = getTestConfig();
|
|
|
|
// Reset mocks between tests
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
// Clean up after each test
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
|
|
// Perform cleanup if enabled
|
|
if (testConfig.cleanup.enabled) {
|
|
// Add cleanup logic here if needed
|
|
}
|
|
});
|
|
|
|
// Global test timeout from configuration
|
|
vi.setConfig({ testTimeout: getTestTimeout('global') });
|
|
|
|
// Configure console output based on test configuration
|
|
if (!testConfig.logging.debug) {
|
|
global.console = {
|
|
...console,
|
|
log: vi.fn(),
|
|
debug: vi.fn(),
|
|
info: vi.fn(),
|
|
warn: testConfig.logging.level === 'error' ? vi.fn() : console.warn,
|
|
error: console.error, // Always show errors
|
|
};
|
|
}
|
|
|
|
// Set up performance monitoring if enabled
|
|
if (testConfig.performance) {
|
|
// Use a high-resolution timer that maintains timing precision
|
|
let startTime = process.hrtime.bigint();
|
|
|
|
global.performance = global.performance || {
|
|
now: () => {
|
|
// Convert nanoseconds to milliseconds with high precision
|
|
const currentTime = process.hrtime.bigint();
|
|
return Number(currentTime - startTime) / 1000000; // Convert nanoseconds to milliseconds
|
|
},
|
|
mark: vi.fn(),
|
|
measure: vi.fn(),
|
|
getEntriesByName: vi.fn(() => []),
|
|
getEntriesByType: vi.fn(() => []),
|
|
clearMarks: vi.fn(),
|
|
clearMeasures: vi.fn(),
|
|
} as any;
|
|
}
|
|
|
|
// Export test configuration for use in tests
|
|
export { testConfig, getTestTimeout, getTestConfig }; |