agent-js-jest icon indicating copy to clipboard operation
agent-js-jest copied to clipboard

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

Open snitin315 opened this issue 2 years ago • 3 comments

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.

snitin315 avatar Jan 10 '23 05:01 snitin315

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

burhanuday avatar Jan 11 '23 13:01 burhanuday

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

snitin315 avatar Jan 14 '23 00:01 snitin315

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

burhanuday avatar Jan 14 '23 14:01 burhanuday