Skip to content

Commit 0e9fbe4

Browse files
authored
feat: allow webpack test setup to be async (#55)
1 parent 8905654 commit 0e9fbe4

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

app/main-view-model.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ export class TestBrokerViewModel extends Observable {
123123
.then((scriptsContents: IScriptInfo[]) => setTimeout(() => this.runTests(scriptsContents), 0));
124124
}
125125

126-
public runTests(scripts: IScriptInfo[]): void {
126+
public async runTests(scripts: IScriptInfo[]): Promise<void> {
127127
const errors = this.testExecutionService.runTests(scripts);
128128
errors.forEach(err => this.error(err.msg, err.url, err.line));
129129

130130
try {
131-
executeWebpackTests();
131+
await executeWebpackTests();
132132
} catch (e) {
133133
this.error(`${e?.message || e}`);
134134
}

app/main.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ export interface RunTestAppOptions {
1313

1414
export function runTestApp(options: RunTestAppOptions = {}) {
1515
if (options?.runTests) {
16-
registerTestRunner(() => {
17-
options.runTests();
18-
});
16+
registerTestRunner(options.runTests);
1917
}
2018
Application.run({ moduleName: "bundle-app-root" });
2119
}

app/services/webpack-test-runner.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
let runTests: () => unknown;
22

3-
export function registerTestRunner(testRunner: () => unknown) {
3+
export function registerTestRunner(testRunner: () => unknown | Promise<unknown>) {
44
runTests = testRunner;
55
}
66

77

8-
export function executeWebpackTests() {
9-
runTests?.();
8+
export async function executeWebpackTests() {
9+
await runTests?.();
1010
}

0 commit comments

Comments
 (0)