Skip to content

(@wdio/spec-reporter): propagate root suite hook errors#9914

Merged
christian-bromann merged 1 commit intomainfrom
cb-root-suite-hook-errors
Jul 10, 2023
Merged

(@wdio/spec-reporter): propagate root suite hook errors#9914
christian-bromann merged 1 commit intomainfrom
cb-root-suite-hook-errors

Conversation

@christian-bromann
Copy link
Member

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

latest

Mode

WDIO Testrunner

Which capabilities are you using?

any

What happened?

Given I have a Mocha test file as following:

import { expect, $, $$, browser } from '@wdio/globals'
import { Key } from 'webdriverio'

describe('Trello Application', () => {
  it('can find links with partial or full text selector', async () => {
    // ...
  })

  // ...
})

after(() => {
  throw new Error('FAIL')
})

The test fails as expected but the error in the root hook is not reported in the spec reporter:

 "spec" Reporter:
------------------------------------------------------------------
[chrome 110.0.5481.177 mac os x #0-0] Running: chrome (v110.0.5481.177) on mac os x
[chrome 110.0.5481.177 mac os x #0-0] Session ID: 7f57bd6942b2948627a4b8627bffefa2
[chrome 110.0.5481.177 mac os x #0-0]
[chrome 110.0.5481.177 mac os x #0-0] » /test/e2e/applitools.e2e.ts
[chrome 110.0.5481.177 mac os x #0-0] Trello Application
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can create an initial board
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can add a list on the board
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can add a card to the list
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can close adding more cards
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can star the board
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can delete a board
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can find links with partial or full text selector
[chrome 110.0.5481.177 mac os x #0-0]
[chrome 110.0.5481.177 mac os x #0-0] 7 passing (53.2s)
[chrome 110.0.5481.177 mac os x #0-0] 1 failing


Spec Files:      0 passed, 1 failed, 1 total (100% completed) in 00:00:56

What is your expected behavior?

I suggest the following reporting:

 "spec" Reporter:
------------------------------------------------------------------
[chrome 110.0.5481.177 mac os x #0-0] Running: chrome (v110.0.5481.177) on mac os x
[chrome 110.0.5481.177 mac os x #0-0] Session ID: 7f57bd6942b2948627a4b8627bffefa2
[chrome 110.0.5481.177 mac os x #0-0]
[chrome 110.0.5481.177 mac os x #0-0] » /test/e2e/applitools.e2e.ts
[chrome 110.0.5481.177 mac os x #0-0] Trello Application
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can create an initial board
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can add a list on the board
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can add a card to the list
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can close adding more cards
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can star the board
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can delete a board
[chrome 110.0.5481.177 mac os x #0-0]    ✓ can find links with partial or full text selector
[chrome 110.0.5481.177 mac os x #0-0]
[chrome 110.0.5481.177 mac os x #0-0] <ROOT HOOK>
[chrome 110.0.5481.177 mac os x #0-0]    ❌ Error: FAIL
[chrome 110.0.5481.177 mac os x #0-0]
[chrome 110.0.5481.177 mac os x #0-0] 7 passing (53.2s)
[chrome 110.0.5481.177 mac os x #0-0] 1 failing


Spec Files:      0 passed, 1 failed, 1 total (100% completed) in 00:00:56

or alternatively whatever is the behavior for a similar Mocha test.

How to reproduce the bug.

n/a

Relevant log output

n/a

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

@christian-bromann christian-bromann added Bug 🐛 help wanted Issues that are free to take by anyone interested good first pick a reasonable task to start getting familiar with the code base labels Mar 8, 2023
@hemche
Copy link

hemche commented Jun 24, 2023

@christian-bromann Don't we support using https://webdriver.io/docs/customservices/#service-error-handling to throw errors in hooks?

@christian-bromann
Copy link
Member Author

Don't we support using https://webdriver.io/docs/customservices/#service-error-handling to throw errors in hooks?

These are WebdriverIO hooks and are called by the WebdriverIO testrunner as oppose to Mocha.

@christian-bromann christian-bromann self-assigned this Jul 10, 2023
@christian-bromann christian-bromann changed the title [🐛 Bug]: errors in Mocha root hooks aren't reported (@wdio/spec-reporter): propagate root suite hook errors Jul 10, 2023
@christian-bromann christian-bromann added PR: Bug Fix 🐛 PRs that contain bug fixes and removed Bug 🐛 help wanted Issues that are free to take by anyone interested good first pick a reasonable task to start getting familiar with the code base labels Jul 10, 2023
@christian-bromann christian-bromann merged commit 7ad0e9a into main Jul 10, 2023
@christian-bromann christian-bromann deleted the cb-root-suite-hook-errors branch July 10, 2023 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 PRs that contain bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants