From 4058743de4b36aba215f03d479f351b34ecbfd05 Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Mon, 6 Jan 2025 10:46:23 +0100 Subject: [PATCH] test: fix unit tests --- api/src/migration/migration.service.spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/src/migration/migration.service.spec.ts b/api/src/migration/migration.service.spec.ts index c9945c99..87a64ba3 100644 --- a/api/src/migration/migration.service.spec.ts +++ b/api/src/migration/migration.service.spec.ts @@ -82,6 +82,7 @@ describe('MigrationService', () => { describe('create', () => { beforeEach(() => { jest.spyOn(service, 'exit').mockImplementation(); // Mock exit to avoid Jest process termination + process.env.HEXABOT_CLI = 'true'; }); afterEach(jest.restoreAllMocks); @@ -163,6 +164,7 @@ describe('MigrationService', () => { afterEach(jest.restoreAllMocks); it('should call runUpgrades when version is not provided and isAutoMigrate is true', async () => { + process.env.HEXABOT_CLI = ''; const runUpgradesSpy = jest .spyOn(service as any, 'runUpgrades') .mockResolvedValue('v2.2.0'); @@ -177,6 +179,7 @@ describe('MigrationService', () => { }); it('should call runAll and exit when version is not provided and isAutoMigrate is false', async () => { + process.env.HEXABOT_CLI = 'true'; const runAllSpy = jest .spyOn(service as any, 'runAll') .mockResolvedValue('v2.2.0'); @@ -192,6 +195,7 @@ describe('MigrationService', () => { }); it('should call runOne and exit when version is provided', async () => { + process.env.HEXABOT_CLI = 'true'; const runOneSpy = jest .spyOn(service as any, 'runOne') .mockResolvedValue('v2.2.0');