Skip to content

Commit

Permalink
fix params and pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
flashdesignory committed Jan 15, 2025
1 parent 69350a9 commit 064e1cc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
6 changes: 1 addition & 5 deletions resources/shared/test-invoker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
20 changes: 16 additions & 4 deletions resources/shared/test-runner.mjs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -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;

Expand All @@ -79,14 +86,19 @@ 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();
}
}

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);
}
Expand Down
5 changes: 3 additions & 2 deletions resources/suite-runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 064e1cc

Please sign in to comment.