Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 79c4008

Browse files
committed
fix: async test preparation
1 parent d932adc commit 79c4008

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

cortex-js/src/infrastructure/commanders/test/model-list.command.spec.ts

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,37 @@ import { mkdirSync, rmSync, writeFileSync } from 'fs';
88

99
let commandInstance: TestingModule;
1010

11-
beforeEach(async () => {
12-
commandInstance = await CommandTestFactory.createTestingCommand({
13-
imports: [CommandModule],
14-
})
15-
// .overrideProvider(LogService)
16-
// .useValue({})
17-
.compile();
18-
const fileService =
19-
commandInstance.resolve<FileManagerService>(FileManagerService);
20-
21-
// Attempt to create test folder
22-
(await fileService).writeConfigFile({
23-
dataFolderPath: join(__dirname, 'test_data'),
24-
});
25-
});
11+
beforeEach(
12+
() =>
13+
new Promise<void>(async (res) => {
14+
commandInstance = await CommandTestFactory.createTestingCommand({
15+
imports: [CommandModule],
16+
})
17+
// .overrideProvider(LogService)
18+
// .useValue({})
19+
.compile();
20+
const fileService =
21+
await commandInstance.resolve<FileManagerService>(FileManagerService);
2622

27-
afterEach(async () => {
28-
// Attempt to clean test folder
29-
try {
30-
await rmSync(join(__dirname, 'test_data'), {
31-
recursive: true,
32-
force: true,
33-
});
34-
} catch (e) {}
35-
});
23+
// Attempt to create test folder
24+
await fileService.writeConfigFile({
25+
dataFolderPath: join(__dirname, 'test_data'),
26+
});
27+
res();
28+
}),
29+
);
30+
31+
afterEach(
32+
() =>
33+
new Promise<void>(async (res) => {
34+
// Attempt to clean test folder
35+
rmSync(join(__dirname, 'test_data'), {
36+
recursive: true,
37+
force: true,
38+
});
39+
res();
40+
}),
41+
);
3642

3743
describe('models list returns array of models', () => {
3844
test('empty model list', async () => {

0 commit comments

Comments
 (0)