Skip to content

Commit a841951

Browse files
DavertMikkobenguyent
andauthoredFeb 26, 2020
WIP: Nested steps (#2)
* rewrite reportportal as plugin * testing phase * fix some errors * handle events * handle events * add tests * fix tests * add test script * changed name of the package * updated * updated nested steps and better reports + adde ddebug * updated index * implemented right order for nested steps * udpated readme Co-authored-by: Peter Nguyen Tr <peter.nguyentr@gmail.com>
1 parent 19575d5 commit a841951

8 files changed

+393
-148
lines changed
 

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
package-lock.json
2-
node_modules
2+
node_modules
3+
test/output/*

‎README.md

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/6e6495428bbd41f0807e4239c42403eb)](https://www.codacy.com/manual/PeterNgTr/codeceptjs-rphelper?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=PeterNgTr/codeceptjs-rphelper&amp;utm_campaign=Badge_Grade) [![npm version](https://badge.fury.io/js/codeceptjs-rphelper.svg)](https://badge.fury.io/js/codeceptjs-rphelper) [![Greenkeeper badge](https://badges.greenkeeper.io/PeterNgTr/codeceptjs-rphelper.svg)](https://greenkeeper.io/)
22

33
# codeceptjs-rphelper
4+
45
This helpes you integrate the test results of CodeceptJS with ReportPortal
56

6-
codeceptjs-rphelper is a [CodeceptJS](https://codecept.io/) helper which can publish tests results on [ReportPortal](https://reportportal.io/) after execution.
7+
`@reportportal/agent-js-codecept` is a [CodeceptJS](https://codecept.io/) plugin which can publish tests results on [ReportPortal](https://reportportal.io/) after execution.
78

89
## Installation
10+
911
```sh
10-
npm i codeceptjs-rphelper --save
12+
npm i @reportportal/agent-js-codecept --save
1113
```
1214

1315
## Configuration
1416

15-
This helper should be added in codecept.json/codecept.conf.js
17+
This plugin should be added in `codecept.conf.js`
1618

1719
Example:
1820

1921
```js
2022
{
2123
...
22-
helpers: {
23-
ReportPortalHelper: {
24-
require: 'codeceptjs-rphelper',
24+
plugins: {
25+
reportportal: {
26+
require: '@reportportal/agent-js-codecept',
2527
token: 'YOUR_TOKEN',
2628
endpoint: 'http://localhost:8080/api/v1',
2729
launchName: 'This is awesome',
2830
launchDescription: 'This is a description of your launch',
2931
launchAttributes: [{ key: 'yourKey', value: 'yourValue' }],
3032
projectName: 'YOUR_PROJECT',
3133
rerun: false,
32-
debug: false
34+
debug: false,
35+
enabled: true
3336
}
3437
...
3538
}
3639
```
3740
38-
To use this helper you need to provide the following info:
41+
To use this plugin you need to provide the following info:
3942
4043
```sh
4144
- `token`: which can be found by navigating to the user profile page, clicking the username drop-down in the right header and selecting the "Profile" > "UUID" – is a unique user identifier. UUID is used in automated test configuration files for a user authentication instead of a password. It will allow you to post data, without logging it in the UI.
@@ -105,10 +108,20 @@ Success finish launch 65ndx5jucolqsp
105108
```
106109
107110
## Screenshot
111+
108112
![ReportPortal Test](https://i.ibb.co/Qm52G0n/Screenshot-2019-04-11-at-15-57-40.png)
109113
110114
All the feature tests are now combine in a single launch
111115
![ReportPortal Launch](http://g.recordit.co/GKsRlB4Fi4.gif)
112116
113117
## Notes
118+
114119
Right now, when running with `codeceptjs run`, all tests will be added under a launch. However, if you run with `codeceptjs run-workers no_of_workers`, there will be multiple launches that match `no_of_workers` and all tests will be added under any random launch. One thing you could try right now is trying to use `codeceptjs run-workers --suites no_of_workers`, by that, you won't get the messy results on `reportportal`.
120+
121+
## Debugging Plugin
122+
123+
To debug this plugin run script enabing DEBUG env variable:
124+
125+
```
126+
DEBUG="codeceptjs:reportportal" npx codeceptjs run
127+
```

‎index.js

+261-134
Large diffs are not rendered by default.

‎jsconfig.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"allowJs": true
4+
}
5+
}

‎package.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "codeceptjs-rphelper",
3-
"version": "1.1.12",
4-
"description": "Reportportal helper for Codecept JS tests",
2+
"name": "@reportportal/agent-js-codecept",
3+
"version": "2.0.0",
4+
"description": "Reportportal plugin for Codecept JS tests",
55
"repository": {
66
"type": "git",
77
"url": "git+ssh://git@github.com/PeterNgTr/codeceptjs-rphelper.git"
@@ -22,11 +22,17 @@
2222
"main": "index.js",
2323
"dependencies": {
2424
"reportportal-client": "5.5.0",
25-
"codeceptjs": "^2.3.5"
25+
"codeceptjs": "2.5.0"
26+
},
27+
"scripts": {
28+
"test": "mocha test/acceptance_test.js --timeout 6000"
2629
},
2730
"devDependencies": {
31+
"chai": "^4.2.0",
2832
"eslint": "^6.6.0",
2933
"eslint-config-airbnb-base": "^14.0.0",
30-
"eslint-plugin-import": "^2.18.2"
34+
"eslint-plugin-import": "^2.18.2",
35+
"mocha": "^7.0.1",
36+
"puppeteer": "^2.1.1"
3137
}
3238
}

‎test/acceptance_test.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const { exec } = require("child_process");
2+
const { expect } = require('chai');
3+
const runner = './node_modules/.bin/codeceptjs run rp_plugin_test.js'
4+
const configFilePath = './test/codecept.conf.js'
5+
6+
describe('RP Plugin - Codeceptjs Integration', () => {
7+
8+
describe('Passed test', () => {
9+
it('should push data to rp', (done) => {
10+
exec(`${runner} --grep @pass -c ${configFilePath} --verbose`, (error, stdout, stderr) => {
11+
expect(stderr).to.be.empty;
12+
expect(stdout).to.include('The launchId is started.');
13+
expect(stdout).to.include('The suiteId is started.');
14+
expect(stdout).to.include('The testId is started.');
15+
expect(stdout).to.include('The stepId is started.');
16+
expect(stdout).to.include('The passed stepId is updated.');
17+
expect(stdout).to.include('OK | 1 passed ');
18+
done();
19+
});
20+
});
21+
22+
});
23+
24+
describe('Failed test', () => {
25+
it('should push data to rp', (done) => {
26+
exec(`${runner} --grep @fail -c ${configFilePath} --verbose`, (error, stdout, stderr) => {
27+
expect(stderr).to.be.empty;
28+
expect(stdout).to.include('The launchId is started.');
29+
expect(stdout).to.include('The launchId is started.');
30+
expect(stdout).to.include('The suiteId is started.');
31+
expect(stdout).to.include('The testId is started.');
32+
expect(stdout).to.include('The stepId is started.');
33+
expect(stdout).to.include('The failed stepId is updated.');
34+
expect(stdout).to.include('Screenshot is attached to failed step');
35+
expect(stdout).to.include('FAIL | 0 passed, 1 failed');
36+
done();
37+
});
38+
});
39+
});
40+
41+
});
42+

‎test/codecept.conf.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { setHeadlessWhen } = require('@codeceptjs/configure');
2+
3+
// turn on headless mode when running with HEADLESS=true environment variable
4+
// HEADLESS=true npx codecept run
5+
setHeadlessWhen(process.env.HEADLESS);
6+
7+
exports.config = {
8+
tests: './*_test.js',
9+
output: './output',
10+
timeout: 10000,
11+
helpers: {
12+
Puppeteer: {
13+
url: 'https://www.google.de/',
14+
show: false
15+
}
16+
},
17+
bootstrap: null,
18+
mocha: {},
19+
name: 'codeceptjs-rphelper',
20+
plugins: {
21+
retryFailedStep: {
22+
enabled: false
23+
},
24+
screenshotOnFail: {
25+
enabled: true
26+
},
27+
reportportal: {
28+
require: '../index',
29+
token: process.env['RP_TOKEN'],
30+
endpoint: 'https://web.demo.reportportal.io/api/v1',
31+
launchName: 'This is demo launch',
32+
launchDescription: 'This is a description of your launch',
33+
launchAttributes: [{ key: 'yourKey', value: 'yourValue' }],
34+
projectName: 'peterngtr_personal',
35+
rerun: false,
36+
debug: false,
37+
enabled: true
38+
}
39+
}
40+
}

‎test/rp_plugin_test.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature('RP Plugin tests');
2+
3+
Scenario('Send passed results to RP @pass', (I) => {
4+
I.amOnPage('/');
5+
I.dontSee('abc');
6+
});
7+
8+
Scenario('Send failed results to RP @fail', (I) => {
9+
I.amOnPage('/');
10+
I.see('abcdef');
11+
});

0 commit comments

Comments
 (0)
Please sign in to comment.