reportportal / agent-js-jest

Agent to integrate Jest with ReportPortal.
https://www.npmjs.com/package/@reportportal/agent-js-jest
Apache License 2.0
21 stars 37 forks source link

Re-use the same launches when using `jest --shard` #121

Open snitin315 opened 1 year ago

snitin315 commented 1 year ago

Jest recently introduced--shard option to fasten up tests on CLI.

This option breaks a single run into multiple runs as shown in the image below:

Screenshot 2023-01-10 at 10 43 00 AM

All of these 4 runs are actually part of a single test run on CI and hence same launch ID should be used for all of the individual shard runs.

However, the current behavior is that the package creates 4 different launches and hence 4 different reports on the report portal. Which disturbs the final graph on the report portal.

burhanuday commented 1 year ago

There isn't an easy way to do this but here's what my team has been doing:

  1. Create a launch id using @reportportal/client-javascript
  2. Write the launch id to a file and upload it to S3 (or any object storage) with the commit id (or head commit id in case of PR) as the filename
  3. In each shard, download the file from S3 and read it to get the launch id
  4. After all the shards are done running, in another job you can download the launch id and then close the launch
snitin315 commented 1 year ago

I believe this issue is also related https://github.com/reportportal/agent-js-jest/issues/58

burhanuday commented 1 year ago

alternatively, upload-artifact action could be used in place of S3

as for #58, this functionality does exist but its not documented. You can pass launchId: string in the @reportportal/agent-js-jest config in the jest.config.js file