Skip to content

Commit 6b05ebd

Browse files
ColiZeijmcdo29
authored andcommitted
feat: runWithoutClosing for testing
1 parent 867d472 commit 6b05ebd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/nest-commander-testing/src/command-test.factory.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,22 @@ export class CommandTestFactory {
6767
}
6868

6969
static async run(app: TestingModule, args: string[] = []) {
70+
const application = await this.runApplication(app, args);
71+
await application.close();
72+
}
73+
74+
static async runWithoutClosing(app: TestingModule, args: string[] = []) {
75+
return this.runApplication(app, args);
76+
}
77+
78+
private static async runApplication(app: TestingModule, args: string[] = []) {
7079
if (args?.length && args[0] !== 'node') {
7180
args = ['node', randomBytes(8).toString('hex') + '.js'].concat(args);
7281
}
7382
await app.init();
7483
const runner = app.get(CommandRunnerService);
7584
await runner.run(args);
76-
await app.close();
85+
return app;
7786
}
7887

7988
static setAnswers(value: any | any[]): void {

0 commit comments

Comments
 (0)