Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reporter breaks on skipped test for WebdriverIO + Mocha #46

Closed
szarlatan opened this issue Jun 30, 2023 · 3 comments · Fixed by #49 or #39
Closed

Reporter breaks on skipped test for WebdriverIO + Mocha #46

szarlatan opened this issue Jun 30, 2023 · 3 comments · Fixed by #49 or #39
Labels
bug Something isn't working
Milestone

Comments

@szarlatan
Copy link

szarlatan commented Jun 30, 2023

Hey there,

found a strange issue, that reporter breaks on it.skip(...) having WebdriverIO set up with Mocha (which seems quite popular pair).

Installed versions
agent-js-webdriverio: ^5.0.3
webdriverio: ^7.30.2

Sample code

describe('Demo of breaking skipped tests', () => {
  it('executing test case', () => {
    expect(true).toBe(true)
  })

  it.skip('skipped test case', () => {
    expect(true).toBe(true)
  })
})

gives following output when run

[0-0] TypeError in "Demo of breaking skipped tests.executing test case"
TypeError: Cannot destructure property 'id' of 'this.storage.getCurrentTest(...)' as it is null.
    at Reporter.finishTest (/Users/krzysztof.biszta/ACME/acme-app/clients/node_modules/@reportportal/agent-js-webdriverio/src/reporter.ts:177:7)
    at Reporter.onTestSkip (/Users/krzysztof.biszta/ACME/acme-app/clients/node_modules/@reportportal/agent-js-webdriverio/src/reporter.ts:154:10)
    at Reporter.<anonymous> (/Users/krzysztof.biszta/ACME/acme-app/clients/node_modules/@reportportal/agent-js-webdriverio/node_modules/@wdio/reporter/build/index.js:154:18)
    at Reporter.emit (node:events:526:28)
    at Reporter.emit (node:domain:475:12)
    at /Users/krzysztof.biszta/ACME/acme-app/clients/node_modules/@wdio/runner/build/reporter.js:36:56
    at Array.forEach (<anonymous>)
    at BaseReporter.emit (/Users/krzysztof.biszta/ACME/acme-app/clients/node_modules/@wdio/runner/build/reporter.js:36:25)
    at MochaAdapter.emit (/Users/krzysztof.biszta/ACME/acme-app/clients/node_modules/@wdio/mocha-framework/build/index.js:257:24)
    at Runner.emit (node:events:538:35)
    at Runner.emit (node:domain:475:12)
    at next (/Users/krzysztof.biszta/ACME/acme-app/clients/node_modules/mocha/lib/runner.js:759:14)
    at next (/Users/krzysztof.biszta/ACME/acme-app/clients/node_modules/mocha/lib/runner.js:581:14)
    at /Users/krzysztof.biszta/ACME/acme-app/clients/node_modules/mocha/lib/runner.js:591:7
    at next (/Users/krzysztof.biszta/ACME/acme-app/clients/node_modules/mocha/lib/runner.js:474:14)
    at Immediate.<anonymous> (/Users/krzysztof.biszta/ACME/acme-app/clients/node_modules/mocha/lib/runner.js:559:5)
@AmsterGet AmsterGet added the bug Something isn't working label Jul 20, 2023
@NikolayStanoev
Copy link

NikolayStanoev commented Aug 1, 2023

Hello, we have faced the same problem while testing same setup.

The problem comes from the fact that test is not started when it.skip is used. As a result the code goes to reporter.ts and calls onTestSkip method which calls finishTest and it fails because the storage object missing information about the current test.

The fix which we tried locally seems to work on first look. We have changed the following method from reporter.ts

onTestSkip(testStats: TestStats): void {
    this.finishTest(testStats);
  }

to

onTestSkip(testStats: TestStats): void {
    this.onTestStart(testStats);
    this.finishTest(testStats);
  }

and the test was successfully added as skipped in report portal.
And the execution completed without any hanging.

@AmsterGet Please take a look on this change and if it does not affect anything else - feel free to apply it.

@AmsterGet AmsterGet linked a pull request Nov 20, 2023 that will close this issue
@AmsterGet AmsterGet added this to the 5.0.4 milestone Nov 20, 2023
@AmsterGet
Copy link
Member

Fixed.
Will be published in the scope of v5.0.4.

@AmsterGet AmsterGet modified the milestones: 5.0.4, 5.1.0 Jan 30, 2024
@AmsterGet AmsterGet linked a pull request Feb 6, 2024 that will close this issue
@AmsterGet
Copy link
Member

Fixed in version 5.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants