diff --git a/resources/shared/test-invoker.mjs b/resources/shared/test-invoker.mjs index b7bea1622..7bf105bdc 100644 --- a/resources/shared/test-invoker.mjs +++ b/resources/shared/test-invoker.mjs @@ -82,9 +82,5 @@ class AsyncRAFTestInvoker extends BaseRAFTestInvoker { export const TEST_INVOKER_LOOKUP = { __proto__: null, raf: RAFTestInvoker, -}; - -export const ASYNC_TEST_INVOKER_LOOKUP = { - __proto__: null, - raf: AsyncRAFTestInvoker, + async: AsyncRAFTestInvoker, }; diff --git a/resources/shared/test-runner.mjs b/resources/shared/test-runner.mjs index 5db876f1b..52defcb36 100644 --- a/resources/shared/test-runner.mjs +++ b/resources/shared/test-runner.mjs @@ -1,4 +1,4 @@ -import { TEST_INVOKER_LOOKUP, ASYNC_TEST_INVOKER_LOOKUP } from "./test-invoker.mjs"; +import { TEST_INVOKER_LOOKUP } from "./test-invoker.mjs"; export class TestRunner { #frame; @@ -7,14 +7,16 @@ export class TestRunner { #suite; #test; #callback; + #type; - constructor(frame, page, params, suite, test, callback) { + constructor(frame, page, params, suite, test, callback, type) { this.#suite = suite; this.#test = test; this.#params = params; this.#callback = callback; this.#page = page; this.#frame = frame; + this.#type = type; } get page() { @@ -52,7 +54,12 @@ export class TestRunner { } performance.mark(syncStartLabel); const syncStartTime = performance.now(); - await this._runSyncStep(this.test, this.page); + + if (this.#type === "async") + await this._runSyncStep(this.test, this.page); + else + this._runSyncStep(this.test, this.page); + const mark = performance.mark(syncEndLabel); const syncEndTime = mark.startTime; @@ -79,7 +86,8 @@ export class TestRunner { }; const report = () => this.#callback(this.#test, syncTime, asyncTime); - const invokerClass = this.#suite.type === "async" ? ASYNC_TEST_INVOKER_LOOKUP[this.#params.measurementMethod] : TEST_INVOKER_LOOKUP[this.#params.measurementMethod]; + const invokerType = this.#suite.type === "async" || this.#params.useAsyncSteps ? "async" : this.#params.measurementMethod; + const invokerClass = TEST_INVOKER_LOOKUP[invokerType]; const invoker = new invokerClass(runSync, measureAsync, report, this.#params); return invoker.start(); @@ -87,6 +95,10 @@ export class TestRunner { } export class AsyncTestRunner extends TestRunner { + constructor(frame, page, params, suite, test, callback, type) { + super(frame, page, params, suite, test, callback, type); + } + async _runSyncStep(test, page) { await test.run(page); } diff --git a/resources/suite-runner.mjs b/resources/suite-runner.mjs index 25304d371..6a6a953ff 100644 --- a/resources/suite-runner.mjs +++ b/resources/suite-runner.mjs @@ -75,8 +75,9 @@ export class SuiteRunner { if (this.#client?.willRunTest) await this.#client.willRunTest(this.#suite, test); - const testRunnerClass = TEST_RUNNER_LOOKUP[this.#suite.type ?? "default"]; - const testRunner = new testRunnerClass(this.#frame, this.#page, this.#params, this.#suite, test, this._recordTestResults); + const testRunnerType = this.#suite.type ?? this.params.useAsyncSteps ? "async" : "default"; + const testRunnerClass = TEST_RUNNER_LOOKUP[testRunnerType]; + const testRunner = new testRunnerClass(this.#frame, this.#page, this.#params, this.#suite, test, this._recordTestResults, testRunnerType); await testRunner.runTest(); } performance.mark(suiteEndLabel);