Skip to content

Commit 876fb8f

Browse files
authored
Honouring the skipped status (webdriverio#15232)
* honouring the skipped status * review changes pt.1
1 parent b4ba956 commit 876fb8f

4 files changed

Lines changed: 12 additions & 7 deletions

File tree

packages/wdio-browserstack-service/src/cli/frameworks/wdioMochaTestFramework.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,17 @@ export default class WdioMochaTestFramework extends TestFramework {
168168

169169
loadTestResult(instance: TestFrameworkInstance, args: Record<string, unknown>) {
170170
const results = args.result as Frameworks.TestResult
171-
const { error, passed } = results
171+
const { error, passed, skipped } = results
172172
let result = 'passed'
173173
let failure: Array<unknown>|null = null
174174
let failureReason: string|null = null
175175
let failureType: string|null = null
176176
if (!passed) {
177-
result = (error && error.message && error.message.includes('sync skip; aborting execution')) ? 'ignore' : 'failed'
177+
if (skipped) {
178+
result = 'skipped'
179+
} else {
180+
result = (error && error.message && error.message.includes('sync skip; aborting execution')) ? 'ignore' : 'failed'
181+
}
178182
if (error && result !== 'skipped') {
179183
failure = [{ backtrace: [removeAnsiColors(error.message), removeAnsiColors(error.stack || '')] }] // add all errors here
180184
failureReason = removeAnsiColors(error.message)

packages/wdio-browserstack-service/src/cli/modules/automateModule.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ export default class AutomateModule extends BaseModule {
100100
async onAfterTest(args: Record<string, unknown>) {
101101
this.logger.debug('onAfterTest: inside automate module after test hook!')
102102
const instace = args.instance as TestFrameworkInstance
103-
const { error, passed } = args.result as { error: Error | null, passed: boolean }
103+
const { error, passed, skipped } = args.result as { error: Error | null, passed: boolean, skipped?: boolean }
104104
const _failReasons: string[] = []
105105

106-
if (!passed) {
106+
if (!passed && !skipped) {
107107
_failReasons.push((error && error.message) || 'Unknown Error')
108108
}
109109

110-
const status = passed ? 'passed' : 'failed'
110+
const status = passed || skipped ? 'passed' : 'failed'
111111
const reason = _failReasons.length > 0 ? _failReasons.join('\n') : undefined
112112

113113
const autoInstance = AutomationFramework.getTrackedInstance()

packages/wdio-browserstack-service/src/service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ export default class BrowserstackService implements Services.ServiceInstance {
402402
@PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'afterTest' })
403403
async afterTest(test: Frameworks.Test, context: never, results: Frameworks.TestResult) {
404404
this._specsRan = true
405-
const { error, passed } = results
406-
if (!passed) {
405+
const { error, passed, skipped } = results
406+
if (!passed && !skipped) {
407407
const testError = (error && error.message) || 'Unknown Error'
408408
this._failReasons.push(testError)
409409

packages/wdio-types/src/Frameworks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export interface TestResult {
4141
retries: TestRetries
4242
exception: string
4343
status: string
44+
skipped?: boolean
4445
}
4546

4647
export interface Results {

0 commit comments

Comments
 (0)