From 42caf6a89c3969cf183b3702525cf2bc27fa431b Mon Sep 17 00:00:00 2001 From: sauravdas1997 <104134282+sauravdas1997@users.noreply.github.com> Date: Thu, 18 Apr 2024 05:54:26 +0530 Subject: [PATCH] fix: Fix skip test filename (#12708) --- packages/wdio-browserstack-service/src/reporter.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/wdio-browserstack-service/src/reporter.ts b/packages/wdio-browserstack-service/src/reporter.ts index 29a824137ea..3546d885c1d 100644 --- a/packages/wdio-browserstack-service/src/reporter.ts +++ b/packages/wdio-browserstack-service/src/reporter.ts @@ -223,6 +223,9 @@ class _TestReporter extends WDIOReporter { const testMetaData: TestMeta = _TestReporter._tests[identifier] const scope = testStats.type === 'test' ? (testStats as TestStats).fullTitle : `${this._suites[0].title} - ${testStats.title}` + // If no describe block present, onSuiteStart doesn't get called. Use specs list for filename + const suiteFileName = this._suiteName || (this.specs?.length > 0 ? this.specs[this.specs.length - 1]?.replace('file:', '') : undefined) + await this.configureGit() const testData: TestData = { uuid: testMetaData ? testMetaData.uuid : uuidv4(), @@ -235,9 +238,9 @@ class _TestReporter extends WDIOReporter { scope: scope, scopes: scopes, identifier: identifier, - file_name: this._suiteName ? path.relative(process.cwd(), this._suiteName) : undefined, - location: this._suiteName ? path.relative(process.cwd(), this._suiteName) : undefined, - vc_filepath: (this._gitConfigPath && this._suiteName) ? path.relative(this._gitConfigPath, this._suiteName) : undefined, + file_name: suiteFileName ? path.relative(process.cwd(), suiteFileName) : undefined, + location: suiteFileName ? path.relative(process.cwd(), suiteFileName) : undefined, + vc_filepath: (this._gitConfigPath && suiteFileName) ? path.relative(this._gitConfigPath, suiteFileName) : undefined, started_at: testStats.start && testStats.start.toISOString(), finished_at: testStats.end && testStats.end.toISOString(), framework: framework,