mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Standardize filename casing for services and Public API (no-changelog) (#10579)
This commit is contained in:
44
packages/cli/test/integration/shared/utils/test-command.ts
Normal file
44
packages/cli/test/integration/shared/utils/test-command.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import type { Config } from '@oclif/core';
|
||||
import type { Class } from 'n8n-core';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import type { BaseCommand } from '@/commands/base-command';
|
||||
import * as testDb from '../test-db';
|
||||
import { TelemetryEventRelay } from '@/events/telemetry-event-relay';
|
||||
import { mockInstance } from '@test/mocking';
|
||||
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
|
||||
|
||||
mockInstance(MessageEventBus);
|
||||
|
||||
export const setupTestCommand = <T extends BaseCommand>(Command: Class<T>) => {
|
||||
const config = mock<Config>();
|
||||
config.runHook.mockResolvedValue({ successes: [], failures: [] });
|
||||
|
||||
// mock SIGINT/SIGTERM registration
|
||||
process.once = jest.fn();
|
||||
process.exit = jest.fn() as never;
|
||||
|
||||
beforeAll(async () => {
|
||||
await testDb.init();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
mockInstance(TelemetryEventRelay);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await testDb.terminate();
|
||||
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
const run = async (argv: string[] = []) => {
|
||||
const command = new Command(argv, config);
|
||||
await command.init();
|
||||
await command.run();
|
||||
return command;
|
||||
};
|
||||
|
||||
return { run };
|
||||
};
|
||||
Reference in New Issue
Block a user