Should reporters be instantiated as services? #3780
Replies: 6 comments 1 reply
-
No, but you are right, we should allow reporters to have an onPrepare and onComplete step. |
Beta Was this translation helpful? Give feedback.
-
Where they are instantiated now they cannot support an onComplete step. Their "life" ends when the runner completes after the onRunnerEnd event is fired. And if we send all test events down to each runner, you now have multiple reporters trying to do the same thing on the same files. The service pattern makes the most sense for reporters. In v4 the child processes sent everything up to the "mothership" (parent process) and we had a single reporter object that was able to handle it. I don't know what decisions led to the reporters being per instance, but to aggregate results we need to rethink where they live. |
Beta Was this translation helpful? Give feedback.
-
As the reporter does not have access to the "end" event which was available in v4 it's now not possible to aggregate results and make one report after all the instances complete. For cases like the wdio-slack-reporter where you would want to send the aggregated results in one message it makes sense to re-think of where the reporter may live. |
Beta Was this translation helpful? Give feedback.
-
@christian-bromann : Is there any update about this discussion? Thanks. |
Beta Was this translation helpful? Give feedback.
-
No updates. I have seen people adding a complementary service to their reporters to achieve these things. |
Beta Was this translation helpful? Give feedback.
-
Hi , I am facing issue with TimelineService module import. I am not able to get HTL report for all the specs. below are my version details, "@wdio/cli": "^8.13.1", // wdio.conf.tsimport { TimelineService } from 'wdio-timeline-reporter/timeline-service'; // Included since I got error related to require, //Services section
|
Beta Was this translation helpful? Give feedback.
-
With the v5 refactor, reporters are now initialized per instance (runner) and only generate reports for the spec file(s) that are run on that instance.
Take junit-reporter for example. Given a run of 10 spec files, I will have 10 separate xml results files. I can combine these after the fact, but it would be nice to have access to all the results inside the reporter.
Would it make sense to convert some reporters into "services" so that they have access to all the test events? Are services even privy to test events (like testStart, testPass, etc).
Beta Was this translation helpful? Give feedback.
All reactions