webdriverio-boneyard / wdio-sync

A WebdriverIO v4 plugin. Helper module to run WebdriverIO commands synchronously.
http://v4.webdriver.io
MIT License
17 stars 31 forks source link

Using jasmine, "done.fail" is never called (missing try catch block) #31

Closed mjusix closed 8 years ago

mjusix commented 8 years ago

Hi,

we are using "wdio-sync" 0.4.8 combined with jasmine testrunner and the junit-reporter.

We've become aware of the following problem:

If some (waitFor) timeout occurs in a test suite, the exception is logged to stdout but not catched in "wdio-sync" and not catched in jasmine or wdio too.

So the junit report doesn't notice of those failed test-cases! Only the number of executed tests is reduced by errors / fails.

Furthermore none of the following test-cases is executed.

So we've debugged wdio-sync to find some "breadcrumbs", leading us to the source of this problem.

We've changed the wdio-sync/index.js for debugging purposes from (line 336):

return origFn(specTitle, function (done) {
            Fiber(() => {
                **specFn.call(this)
                done()**
            }).run()
        })

to:

return origFn(specTitle, function (done) {
            Fiber(() => {
                **try{
                    specFn.call(this)
                    done()
                }catch(e){
                    done.fail(e)
                }**
            }).run()
        })

This solves the problem.

While debugging the "wdio-sync" code we found some similar places, where "done" function is passed as an error callback parameter:

For instance line 359 in wdio-sync/index.js:

}).then(() => done(), **done**)

Is that running for jasmine?!?

We think there must be passed the done.fail function.

Best regards Dominic Graulich

christian-bromann commented 8 years ago

Thanks, yeah apparently I always had Mocha in mind when handling with these callbacks. Thanks for noticing. Can you provide some reproducible examples which I could use for testing purposes?

christian-bromann commented 8 years ago

fixed with recent release