mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-01-30 06:22:04 +00:00
- Add .mcp.json to .gitignore - Update database and test configurations - Add quick publish script 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
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 }; |