Skip to content

Commit f3b6538

Browse files
chore(@wdio/spec-reporter): use base name of app path in prefix (#13842)
1 parent ffba24e commit f3b6538

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

packages/wdio-spec-reporter/src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import prettyMs from 'pretty-ms'
1+
import path from 'node:path'
22
import { format } from 'node:util'
3+
4+
import prettyMs from 'pretty-ms'
35
import type { Capabilities } from '@wdio/types'
46
import { Chalk, type ChalkInstance } from 'chalk'
57
import WDIOReporter, { TestStats } from '@wdio/reporter'
@@ -598,7 +600,12 @@ export default class SpecReporter extends WDIOReporter {
598600
const device = caps['appium:deviceName']
599601
// @ts-expect-error outdated JSONWP capabilities
600602
const app = ((caps['appium:app'] || caps.app) || '').replace('sauce-storage:', '')
601-
const appName = app || caps['appium:bundleId'] || caps['appium:appPackage']
603+
const appName = (
604+
caps['appium:bundleId'] ||
605+
caps['appium:appPackage'] ||
606+
caps['appium:appActivity'] ||
607+
(path.isAbsolute(app) ? path.basename(app) : app)
608+
)
602609
// @ts-expect-error outdated JSONWP capabilities
603610
const browser = caps.browserName || caps.browser || appName
604611
/**

packages/wdio-spec-reporter/tests/index.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,33 @@ describe('SpecReporter', () => {
10051005
'appium:appActivity': '.MainActivity'
10061006
}, false)).toBe('com.example.android Android')
10071007
})
1008+
1009+
it('should prefer bundleId over app path', () => {
1010+
expect(tmpReporter.getEnviromentCombo({
1011+
platformName: 'Android',
1012+
'appium:automationName': 'uiautomator2',
1013+
'appium:bundleId': 'com.example.android',
1014+
'appium:appActivity': '.MainActivity',
1015+
'appium:app': '/foo/bar/loo.apk'
1016+
}, false)).toBe('com.example.android Android')
1017+
})
1018+
1019+
it('prefers app activity over app path', () => {
1020+
expect(tmpReporter.getEnviromentCombo({
1021+
platformName: 'Android',
1022+
'appium:automationName': 'uiautomator2',
1023+
'appium:appActivity': '.MainActivity',
1024+
'appium:app': '/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/loo.apk'
1025+
}, false)).toBe('.MainActivity Android')
1026+
})
1027+
1028+
it('uses file name as app path instead of long path', () => {
1029+
expect(tmpReporter.getEnviromentCombo({
1030+
platformName: 'Android',
1031+
'appium:automationName': 'uiautomator2',
1032+
'appium:app': '/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/loo.apk'
1033+
}, false)).toBe('loo.apk Android')
1034+
})
10081035
})
10091036

10101037
describe('add real time report', () => {

0 commit comments

Comments
 (0)