📋Beautiful enterprise-grade test reports integrated with CodeceptJS testing framework. This helpes you integrate the test results of CodeceptJS with ReportPortal
Based on CodeceptJS RPHelper by PeterNgTr.
@reportportal/agent-js-codecept is a CodeceptJS plugin which can publish tests results on ReportPortal after execution.
When enabled this plugin sends information on test runs to ReportPortal server:
- ✅status for failed and passed tests
- 🔍step by step log
- 🖼screenshots on failure are attached
npm i @reportportal/agent-js-codecept --saveRequires Node.js >=16.
Deprecated option names. The options were renamed to match the rest of the ReportPortal JavaScript agents (e.g.
agent-js-playwright). The old names still work but print a deprecation warning; when both are set, the new name wins. They will be removed in a future major release.
Deprecated Replacement tokenapiKeyprojectNameprojectlaunchNamelaunchlaunchDescriptiondescriptionlaunchAttributesattributes
This plugin should be added in codecept.conf.js
Example:
{
//...
plugins: {
reportportal: {
enabled: true,
require: '@reportportal/agent-js-codecept',
apiKey: 'YOUR_API_KEY',
endpoint: 'http://localhost:8080/api/v1',
launch: 'local launch',
project: 'Awesome_project'
}
//...
}To use this plugin you need to provide the following info:
apiKey- required: user's token for ReportPortal. The API key can be found on the user profile page in the ReportPortal UI. It is used for authentication instead of a password so that data can be posted without a UI login.endpoint- required: your reportportal host +api/v1for instance:http://localhost:8080/api/v1project- required: the project that you created in the reportportal UIlaunch: (optional) the launch name you want. Defaults tocodeceptjs tests. If not provided and the suite title is available, the suite title is used.description: (optional) the description of your launch, if not provided, the description will be emptyattributes: (optional) the attributes of your launch, if not provided, the attributes will be empty ([])mode: (optional) to specify visibility of launch, if set to'DEBUG', then launch results will be only visible in the 'Debug' section of a project. Defaults to'DEFAULT'.debug: (optional) to turn on the debug for reportportalrerun: (optional) to enable rerunrerunOf: (optional) UUID of launch you want to rerun. If not specified, report portal will update the latest launch with the same namerestClientConfig: (optional) opaque object forwarded verbatim to the ReportPortal HTTP client. Use it to configure HTTP transport such as proxy, timeout, retry, and custom headers. See@reportportal/client-javascriptREADME for the accepted shape.
Four options accept an environment-variable fallback. The following environment variables are recognised:
| Env var | Option |
|---|---|
RP_API_KEY |
apiKey |
RP_ENDPOINT |
endpoint |
RP_PROJECT |
project |
RP_LAUNCH |
launch |
Precedence (highest to lowest):
- Explicit value from
codecept.conf.js - Environment variable (where applicable)
- Default (if any)
A value is considered "set" only when it is defined and non-empty, so a
blank shell variable (RP_LAUNCH="") or an empty option falls through to the
next level.
This lets CI/CD supply values the committed codecept.conf.js leaves out (for
example a per-pipeline API key) without editing the file.
You can send logs to ReportPortal to current step / test by accessing this plugin from your code:
const reportPortal = codeceptjs.container.plugins('reportportal');
reportPortal.addLog({
level: 'debug',
message: 'your message'
});To send attachment, use second parameter:
const reportPortal = codeceptjs.container.plugins('reportportal');
reportPortal.addLog({
level: 'debug',
message: 'your message'
}, {
name: 'screenshot.png',
type: 'image/png',
content: fs.readFileSync('output/screenshot.png')
});See sendLog method of ReportPortal JavaScript Client for more oprtions.
Once report is posted a special reportportal.result event is created.
You can use it to pass URL of a report into other plugins. For instance, you can use it to send Slack or Email notifications including a link to a report.
// inside your custom plugin:
event.dispatcher.on('reportportal.result', (result) => {
// use result.link as URL to report
console.log('Report was published at', result.link);
})- Support
run-workerscommand to aggregate all tests under one launch.
To debug this plugin run script enabing DEBUG env variable:
DEBUG="codeceptjs:reportportal" npx codeceptjs run
