Skip to content

Commit

Permalink
chore(@wdio/spec-reporter): use base name of app path in prefix (#13842)
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann authored Nov 1, 2024
1 parent ffba24e commit f3b6538
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/wdio-spec-reporter/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import prettyMs from 'pretty-ms'
import path from 'node:path'
import { format } from 'node:util'

import prettyMs from 'pretty-ms'
import type { Capabilities } from '@wdio/types'
import { Chalk, type ChalkInstance } from 'chalk'
import WDIOReporter, { TestStats } from '@wdio/reporter'
Expand Down Expand Up @@ -598,7 +600,12 @@ export default class SpecReporter extends WDIOReporter {
const device = caps['appium:deviceName']
// @ts-expect-error outdated JSONWP capabilities
const app = ((caps['appium:app'] || caps.app) || '').replace('sauce-storage:', '')
const appName = app || caps['appium:bundleId'] || caps['appium:appPackage']
const appName = (
caps['appium:bundleId'] ||
caps['appium:appPackage'] ||
caps['appium:appActivity'] ||
(path.isAbsolute(app) ? path.basename(app) : app)
)
// @ts-expect-error outdated JSONWP capabilities
const browser = caps.browserName || caps.browser || appName
/**
Expand Down
27 changes: 27 additions & 0 deletions packages/wdio-spec-reporter/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,33 @@ describe('SpecReporter', () => {
'appium:appActivity': '.MainActivity'
}, false)).toBe('com.example.android Android')
})

it('should prefer bundleId over app path', () => {
expect(tmpReporter.getEnviromentCombo({
platformName: 'Android',
'appium:automationName': 'uiautomator2',
'appium:bundleId': 'com.example.android',
'appium:appActivity': '.MainActivity',
'appium:app': '/foo/bar/loo.apk'
}, false)).toBe('com.example.android Android')
})

it('prefers app activity over app path', () => {
expect(tmpReporter.getEnviromentCombo({
platformName: 'Android',
'appium:automationName': 'uiautomator2',
'appium:appActivity': '.MainActivity',
'appium:app': '/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/loo.apk'
}, false)).toBe('.MainActivity Android')
})

it('uses file name as app path instead of long path', () => {
expect(tmpReporter.getEnviromentCombo({
platformName: 'Android',
'appium:automationName': 'uiautomator2',
'appium:app': '/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/loo.apk'
}, false)).toBe('loo.apk Android')
})
})

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

0 comments on commit f3b6538

Please sign in to comment.