jemishgopani / wdio-json-reporter

A WebdriverIO plugin. Report results in json format. http://webdriver.io
13 stars 32 forks source link

State of hook causes testrunner to crash #34

Closed dragancla closed 5 years ago

dragancla commented 5 years ago

Ever since version 1.3.0 the testrunner crashes if a test fails in a beforeEach mocha hook, which produces a domino-effect where, at the end of the suite, reportPortal sees the failing tests as "IN_PROGRESS" so it can't finish the suite launch <- unrelated, just submitted a bug for that as well

We reverted back to 1.2.0 and everything is fine.

Steps to reproduce:

describe('Should not crash testrunner in beforeEach', () => {

    beforeEach(() => {
        expect(1).to.equal(2);
    });

    it('should be true', () => {
        expect(1).to.equal(1);
    });

});

Stack trace:

[5-28] 2019-07-17T08:39:00.811Z ERROR @wdio/local-runner: Failed launching test session: TypeError: Cannot read property 'length' of undefined
    at module.exports (/usr/src/app/node_modules/wdio-json-reporter/src/mapHooks.js:13:40)
    at JsonReporter.prepareJson (/usr/src/app/node_modules/wdio-json-reporter/src/index.js:31:35)
    at JsonReporter.onRunnerEnd (/usr/src/app/node_modules/wdio-json-reporter/src/index.js:13:25)
    at JsonReporter.WDIOReporter.on.runner (/usr/src/app/node_modules/@wdio/reporter/build/index.js:181:12)
    at JsonReporter.emit (events.js:182:13)
    at JsonReporter.EventEmitter.emit (domain.js:442:20)
    at reporters.forEach.reporter (/usr/src/app/node_modules/@wdio/runner/build/reporter.js:61:49)
    at Array.forEach (<anonymous>)
    at BaseReporter.emit (/usr/src/app/node_modules/@wdio/runner/build/reporter.js:61:20)
    at Runner.run (/usr/src/app/node_modules/@wdio/runner/build/index.js:188:19)

[2-65] 2019-07-17T08:48:31.367Z ERROR @wdio/local-runner: Failed launching test session: TypeError: Cannot read property 'length' of undefined
    at module.exports (/usr/src/app/node_modules/wdio-json-reporter/src/mapHooks.js:13:40)
    at JsonReporter.prepareJson (/usr/src/app/node_modules/wdio-json-reporter/src/index.js:31:35)
    at JsonReporter.onRunnerEnd (/usr/src/app/node_modules/wdio-json-reporter/src/index.js:13:25)
    at JsonReporter.WDIOReporter.on.runner (/usr/src/app/node_modules/@wdio/reporter/build/index.js:181:12)
    at JsonReporter.emit (events.js:182:13)
    at JsonReporter.EventEmitter.emit (domain.js:442:20)
    at reporters.forEach.reporter (/usr/src/app/node_modules/@wdio/runner/build/reporter.js:61:49)
    at Array.forEach (<anonymous>)
    at BaseReporter.emit (/usr/src/app/node_modules/@wdio/runner/build/reporter.js:61:20)
    at Runner.run (/usr/src/app/node_modules/@wdio/runner/build/index.js:188:19)
dragancla commented 5 years ago

@fijijavis :)

fijijavis commented 5 years ago

@dragancla Are you using Mocha as your test runner? If so which version? I see what is probably causing the error but I'm unable to reproduce it with a minimal wdio example. Maybe share your package.json?

dragancla commented 5 years ago

We're using the latest mocha-framework provided by @wdio https://www.npmjs.com/package/@wdio/mocha-framework

  "dependencies": {
    "@wdio/appium-service": "^5.11.4",
    "@wdio/cli": "^5.11.5",
    "@wdio/local-runner": "^5.10.9",
    "@wdio/mocha-framework": "^5.11.0",
    "@wdio/selenium-standalone-service": "^5.11.2",
    "@wdio/spec-reporter": "^5.11.0",
    "@wdio/sync": "^5.10.8",
    "appium": "^1.14.0",
    "chai": "^4.1.2",
    "mocha-testrail-reporter": "^1.0.12",
    "wdio-image-comparison-service": "^1.2.0",
    "wdio-json-reporter": "1.2.0",
    "wdio-reportportal-reporter": "^5.0.1",
    "wdio-reportportal-service": "^5.0.2",
    "wdio-testrail-reporter": "^1.1.5",
    "webdriverio": "^5.11.5"
  }
fijijavis commented 5 years ago

@dragancla I finally figured out my issue... i didn't have the reporter setup in my wdio conf 🤒 🤦‍♂ Should have a fix out today.

fijijavis commented 5 years ago

@dragancla v1.3.1 has been published. It should take care of your issue

dragancla commented 5 years ago

@fijijavis Thanks! Testing it now

dragancla commented 5 years ago

Stressed it properly, no errors so far. Good job, thanks! 👍