From 561617587771d8d1f3dcf12e98e590bb88877f4f Mon Sep 17 00:00:00 2001 From: EmmaYuan1015 Date: Tue, 26 May 2026 16:54:11 +0800 Subject: [PATCH] fix(smoke): type mocha context for dispose hooks --- test/smoke/suites/actionBar.test.ts | 2 +- test/smoke/suites/helper/baseSmokeTest.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/smoke/suites/actionBar.test.ts b/test/smoke/suites/actionBar.test.ts index f6ee4cc07..8c5ca32b1 100644 --- a/test/smoke/suites/actionBar.test.ts +++ b/test/smoke/suites/actionBar.test.ts @@ -17,7 +17,7 @@ export function startActionBarTests(): void { return app.getMainPage(); } - async function dispose() { + async function dispose(this: Mocha.Context): Promise { if (this.currentTest?.state === "failed") { SmokeTestLogger.info("Test failed, taking screenshot ..."); await screenshots.takeScreenshots( diff --git a/test/smoke/suites/helper/baseSmokeTest.ts b/test/smoke/suites/helper/baseSmokeTest.ts index 5efad841a..b359cf056 100644 --- a/test/smoke/suites/helper/baseSmokeTest.ts +++ b/test/smoke/suites/helper/baseSmokeTest.ts @@ -21,7 +21,7 @@ export class BaseSmokeTest { * Common dispose function to be called after each test * Takes screenshots on failure and closes the app */ - public static async dispose(this: any): Promise { + public static async dispose(this: Mocha.Context): Promise { if (this.currentTest?.state === "failed") { SmokeTestLogger.info("Test failed, taking screenshot ..."); await screenshots.takeScreenshots( @@ -30,7 +30,7 @@ export class BaseSmokeTest { ); } try { - SmokeTestLogger.info(`Dispose test: "${this.currentTest.title}" ...`); + SmokeTestLogger.info(`Dispose test: "${this.currentTest?.title ?? "unknown"}" ...`); if (app) { await app.close(); }