Skip to content

Commit 8c38071

Browse files
Liviu RauDevtools-frontend LUCI CQ
authored andcommitted
Add Mocha.Context to the e2e_non_hosted testing function signature
Bug: none Change-Id: I973f6d43e19fe3b547be3a22ec73938f44097016 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6361534 Commit-Queue: Liviu Rau <[email protected]> Reviewed-by: Philip Pfaffe <[email protected]>
1 parent 9ce8154 commit 8c38071

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

test/e2e_non_hosted/conductor/mocha-interface-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface State {
1818
}
1919

2020
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
21-
export type TestCallbackWithState = (state: State) => PromiseLike<any>;
21+
export type TestCallbackWithState = (this: Mocha.Context, state: State) => PromiseLike<any>;
2222

2323
async function takeScreenshots(state: State): Promise<{target?: string, frontend?: string}> {
2424
try {

test/e2e_non_hosted/conductor/mocha-interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function iterationSuffix(iteration: number): string {
108108
function customIt(testImplementation: TestFunctions, suite: Mocha.Suite, file: string) {
109109
function instrumentWithState(fn: TestCallbackWithState) {
110110
const fnWithState = async function(this: Mocha.Context) {
111-
return await StateProvider.instance.callWithState(suite, fn);
111+
return await StateProvider.instance.callWithState(this, suite, fn);
112112
};
113113
return makeInstrumentedTestFunction(fnWithState, 'test');
114114
}

test/e2e_non_hosted/conductor/state-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ export class StateProvider {
3636
this.settingsCallbackMap.set(suite, suiteSettings);
3737
}
3838

39-
async callWithState(suite: Mocha.Suite, testFn: TestCallbackWithState) {
39+
async callWithState(context: Mocha.Context, suite: Mocha.Suite, testFn: TestCallbackWithState) {
4040
const {state, browsingContext} = await this.getState(suite);
4141
try {
4242
/* eslint-disable-next-line no-debugger */
4343
debugger; // If you're paused here while debugging, stepping into the next line will step into your test.
44-
return await testFn(state);
44+
return await testFn.call(context, state);
4545
} finally {
4646
await browsingContext.close();
4747
dumpCollectedErrors();

0 commit comments

Comments
 (0)