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

Not waiting for reporters to finish in synchronous mode #1713

Closed
keitharobertson opened this issue Nov 17, 2016 · 4 comments
Closed

Not waiting for reporters to finish in synchronous mode #1713

keitharobertson opened this issue Nov 17, 2016 · 4 comments
Labels
Bug 🐛 Needs Investigation Issues that require more information on the problem.
Milestone

Comments

@keitharobertson
Copy link

The problem

It seems like the test runner is not waiting for the reporters to finish before exiting, which results in the last events not being handled.

Environment

  • WebdriverIO version: 4.4.0
  • Node.js version: v6.9.1
  • Standalone mode or wdio testrunner: wdio testrunner
  • if wdio testrunner, running synchronous or asynchronous tests: synchronous
  • Additional wdio packages used (if applicable): wdio-allure-reporter, wdio-mocha-framework

Details

I am using the wdio-allure-reporter. I kept getting 'Could not find any allure results' when trying to generate the allure report. When I look in the allure-results directory, there is no xml file for the test suite. If I add an after hook with a browser.pause(5000), it works as expected. This seems to be more prevalent when running a long test and/or running on a system under load.

I modified the allure reporter to log out messages when events are being handled. I notice that the events for the last few commands are not handled before the process exits. If I put in the pause(5000), I do see the final events getting processed. For example, without the pause, the suite:end event is not processed and as a result no xml file is output to allure-results. With the pause, it is processed and an xml file is output.

@keitharobertson
Copy link
Author

When it fails (it is intermittent), the global.browser.on events are executed in runner.js which sends the events back to the parent process in launcher.js, but the event is not handled there (messageHandler() is never called). I added console logs to the events. In the case where it works as it should, there are logs from messageHandler in launcher.js that correspond to the logs from the events in runner.js. When it does not work correctly, there are many unmatched logs from runner.js at the end.

@keitharobertson
Copy link
Author

process.send is async nodejs/node#760. The problem is if you are doing large things (like screenshots), it is possible for the data to not be sent back before the process.exit. This can be fixed by moving the process.exit into the process.send callback on the runner:end event runner.js line 190. If this is changed from

process.send({
    event: 'runner:end',
    failures: failures,
    cid: this.cid,
    specs: this.specs
})
process.exit(failures === 0 ? 0 : 1)

to be this (process.exit in process.send callback), the problem is fixed

process.send({
    event: 'runner:end',
    failures: failures,
    cid: this.cid,
    specs: this.specs
}, null, {}, () => process.exit(failures === 0 ? 0 : 1))

@christian-bromann
Copy link
Member

@krobertson92 can you provide a minimal reproducible example?

@christian-bromann christian-bromann added Bug 🐛 Needs Investigation Issues that require more information on the problem. labels Dec 2, 2016
@christian-bromann christian-bromann added this to the Upcoming milestone Dec 2, 2016
christian-bromann added a commit to webdriverio-boneyard/wdio-mocha-framework that referenced this issue Dec 7, 2016
christian-bromann added a commit to webdriverio-boneyard/wdio-jasmine-framework that referenced this issue Dec 7, 2016
@christian-bromann
Copy link
Member

@krobertson92 thanks for filing the issue. It got fixed and will be released with the next framework adapter releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 Needs Investigation Issues that require more information on the problem.
Projects
None yet
Development

No branches or pull requests

2 participants