diff --git a/app/main-view-model.ts b/app/main-view-model.ts index f74d2c1..5464412 100644 --- a/app/main-view-model.ts +++ b/app/main-view-model.ts @@ -123,12 +123,12 @@ export class TestBrokerViewModel extends Observable { .then((scriptsContents: IScriptInfo[]) => setTimeout(() => this.runTests(scriptsContents), 0)); } - public runTests(scripts: IScriptInfo[]): void { + public async runTests(scripts: IScriptInfo[]): Promise { const errors = this.testExecutionService.runTests(scripts); errors.forEach(err => this.error(err.msg, err.url, err.line)); try { - executeWebpackTests(); + await executeWebpackTests(); } catch (e) { this.error(`${e?.message || e}`); } diff --git a/app/main.ts b/app/main.ts index b97e49f..e1f934a 100644 --- a/app/main.ts +++ b/app/main.ts @@ -13,9 +13,7 @@ export interface RunTestAppOptions { export function runTestApp(options: RunTestAppOptions = {}) { if (options?.runTests) { - registerTestRunner(() => { - options.runTests(); - }); + registerTestRunner(options.runTests); } Application.run({ moduleName: "bundle-app-root" }); } diff --git a/app/services/webpack-test-runner.ts b/app/services/webpack-test-runner.ts index 71b9fc1..3cfa817 100644 --- a/app/services/webpack-test-runner.ts +++ b/app/services/webpack-test-runner.ts @@ -1,10 +1,10 @@ let runTests: () => unknown; -export function registerTestRunner(testRunner: () => unknown) { +export function registerTestRunner(testRunner: () => unknown | Promise) { runTests = testRunner; } -export function executeWebpackTests() { - runTests?.(); +export async function executeWebpackTests() { + await runTests?.(); }