webdriverio: Why does not Webdriverio report an error in beforeAll with Jasmine?
I use with Jasmine.
When an error occur in beforeAll, WebdriverIO does not report the error, but exit code is 1.
I expect it to report error and test failed.
When an error occur in ‘beforeEach’, WebdriverIO report it and the test failed.
example code
describe('sample', () => {
beforeAll(() => {
throw new Error("ERROR")
})
it('sample', () => {
browser.url('http://www.google.com')
})
})
Environment (please complete the following information):
- **WebdriverIO version: 4.14.0
- Mode: WDIO Testrunner
- **If WDIO Testrunner, running sync/async:“” sync
- **Node.js version: 8.6.0
- NPM version: 6.4.1
- Browser name and version: Chrome 70
- **Platform name and version: mac OS 10.13.6
- Additional wdio packages used (if applicable): [e.g. @wdio/spec reporter, @wdio/selenium-standalone service]
- “chromedriver”: “2.44.0”,
- “wdio-chromedriver-service”: “0.1.3”,
- “wdio-jasmine-framework”: “0.3.7”,
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (13 by maintainers)
@nicholasbailey Please advise if you can share that patch/MR. I would be happy to take it from there, wrap it up and contribute an MR based on your work if you have no objections. This is quite nasty bug that makes people make quite an ugly workarounds to overcome it. Thanks!
The fact that beforeAll swallows all errors caused quite a bit of confusion / frustration when I upgraded from v4 to v5. I think it would be really useful to fix this issue.
Has there been any update on this issue?
I think I’m ok with them continuing execution. What I think is the current (my experience is mostly in v4, but I think it also exists in v5) is that errors in beforeAll, afterAll, etc are completely swallowed and don’t appear in logs at all.
Digging into this over the last few days, it looks like part of the problem is that at least spec-reporter is only looking for failures on hook:end and test:failed. An exception beforeEach will trigger a test:failed event in wdio-jasmine-framework, but beforeAll will not. wdio-jasmine-framework (unlike wdio-mocha-framework) never emits a hook:end event, because Jasmine’s reporting interface doesn’t expose the start and end of hooks.
A further complication - Jasmine catches the exception in beforeAll and doesn’t propagate it immediately. So we can’t even wrap beforeAll and emit a hook:end event after it is called, because the exception won’t be available
I can imagine a couple of solutions here:
In a vacuum, I’d do the third, but I don’t know the codebase/design choices as well as some other folks here.
No, that fix was related to Mocha
@issei126 I tried replacing jasmine with mocha and it didn’t have this issue. That tells me that it’s a wdio-jasmine-framework issue rather than wdio. Read through the code of wdio-jasmine-framework and compare it with wdio-mocha-framework now to see if I can find anything.