One way to get the launch id is through adding a custom reporter on top of this package.
const ReporPortalAgent = require('@reportportal/agent-js-mocha');
const fs = require('fs');
class ReporPortal extends ReporPortalAgent {
constructor(runner, options) {
super(runner, options);
}
onLaunchStart() {
const systemAttributes = this.getSystemAttributes();
const launchAttributes = (this.options.reporterOptions.attributes || []).concat(
systemAttributes,
);
const { tempId, promise } = this.rpClient.startLaunch({
token: this.options.reporterOptions.token,
name: this.options.reporterOptions.launch,
startTime: this.rpClient.helpers.now(),
description: this.options.reporterOptions.description,
rerun: this.options.reporterOptions.rerun,
rerunOf: this.options.reporterOptions.rerunOf,
attributes: launchAttributes,
});
promise
.then(res => fs.writeFileSync('.env', `RP_LAUNCH_ID=${res.id}`))
.catch(err => console.error('Failed to launch run.', err));
this.launchId = tempId;
}
}
module.exports = ReporPortal;
Is there a better way to do it.
One way to get the launch id is through adding a custom reporter on top of this package.
Is there a better way to do it.