Open sgordiev opened 3 years ago
Yes I intentially not report hooks. Wdio hooks reporting with suppporting mocha+jasmine+cucumber with correct handling failed hooks and retries is hell. See for example allure imlementation that still has bunch of bugs https://github.com/webdriverio/webdriverio/blob/master/packages/wdio-allure-reporter/src/index.ts#L260
honestly I cant undestand why one need to exclude hooks from report. I mean I undestand that them want read less, but mocha or junit, jasmine won't care about such 'less reading' and will always show them in console.I think all reporters should repeat that logic. And if cucumber doesn't show before
in its console then I think there might be a check isCucumber
in both onHookStart
and onHookEnds
that keeps old logic instead check if mocha
honestly I cant undestand why one need to exclude hooks from report
I can easily explain. I don't have enough time to implement a solid solution for it. There are a lot of corner cases that must be handled and tested. That's why I report only failed hooks.
But you have a broken functionality. When hook is failed you can't show what happened. I'd rather always show it in report than have this functionality cut off. Without check on as your have shared in allure( for some reason them added 'disableMochaHooks' flag for mocha to not to show before hooks and I think thats why have that problem now with lots of bugs). Please let me know if there is a way to add screenshots to hooks
Don't get me wrong I understand your concerns.
nope
so for those who came with the same question - your answer - won't fix ? And if one need that one should create his own report portal service ?
I didn't say "won't fix". For sure it is lack of functionality. I don't have time to implement it. It is an open source. You can research\implement\test it and make a pull request. But make sure it should work not only for mocha and not only in straight cases.
main issue here - if you don't handle hooks right you can easy broke whole suite reporting because you will break testitems tree - it is worse than don't have screen in hooks.
ok, right now I my project is in POC stage with report portal, I will create a custom service with the fix, and after when/if we choose it as our solution, and project give me time on the fix, I will try to provide a fix, or when I have my free time
That will be awesome. If you will need help feel free to ask here or in report portal slack
need your help. When I add the logic to start hook to enable sand the logs, it doesn't find that hook with sendFileToTest, and it seams hook name in afterHook(in wd.conf.js - client side) and in onHookStart onHookEnd(in reporter.js) has a different title. I mean startedTest.wdioEntity.title(from storage) === test.title(from wd.conf.js). So the logic of finding item by title works only for test and suite but not for hook for some reason. And error message is send to hook cause it doesn't use logic of finding by title but rather bu internal id you are assign this.client.sendLog(testItem.id....
Bottom line. If I than use await reportportal.sendFile( 'info', filename, fs.readFileSync(outputFile));
in 'afterHook' it works cause it also looks for 'testItem.id' instead of 'title' match
startedTest.wdioEntity.title "after all" hook for Check ads on LiveCoveragePage auth test.title(from wdio.config) "after all" hook for "should have Symbol(AD_LIVECOVERAGE)"
Check ads on LiveCoveragePage auth - is a suite name "should have Symbol(AD_LIVECOVERAGE)" - is a test name
hook name in afterHook(in wd.conf.js - client side) and in onHookStart onHookEnd(in reporter.js) has a different title.
That's true. Seems you can create issue in wdio repo to fix it.
And error message is send to hook cause it doesn't use logic of finding by title but rather bu internal id you are assign this.client.sendLog(testItem.id....
Yes. It is ok.
1) reporter.sendLog(level, message)
should attach log to current testitem( uses in case when you don't know current testitem
name or don't care)
2) reporter.sendLogToTest(test, level, message)
should attach log to specific testitem with test
title. It uses when you know title and want add logs to specific testitem
ok thanks, will create an issue for wide. Thanks for help, will be back with its url
from #139
I don't know how we should report per-file after suite mocha hooks. In fact they are not bounded to some reportportal suite and when they are executed there is no active suite item and there is no place to report them...
If I'm not mistaken allure just ignore them, see https://github.com/webdriverio/webdriverio/blob/main/packages/wdio-allure-reporter/src/index.ts#L278
Example:
describe('My suite 1', () => {
///
});
describe('My suite 2', () => {
///
});
describe('My suite 3', () => {
///
});
after(() => {
//will throw error
})
that would be step number 2 to think how to deal with it, at the moment regular hook doesn't work. After I fix that I will return to this issue
if any I opened a ticket https://github.com/webdriverio/webdriverio/issues/6336
The problem
Nor sendLogToTest neither sendFileToTest works with mocha wdio from afterHook. Error is next:
Can not send file to test "after all" hook for...
In my case I use mochabefore
andafter
for log in and log out. When something is wrong with that functionality I want to have some extra debug info.I think issue is that test item for hooks is not created at that time because of this logic in node_modules/wdio-reportportal-reporter/lib/reporter.ts:
As you can see
onHookStart
doesn't create any test item. And if I am not mistaken this hook starts before client'sbeforeHook
. AndonHookEnd
executes after client'safterHook
so code in clients after hook will try to send info to test item that not exists yet. If updateonHookStart
withthis.onTestStart(hook, TYPE.BEFORE_METHOD);
that will add hooks to all reports but also will enable sending info to that item.Environment
Code To Reproduce Issue [ Good To Have ]