@reportportal/client-javascript 5.0.5 → 5.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +3 -0
- package/VERSION +1 -1
- package/analytics/analytics.js +7 -7
- package/analytics/constants.js +1 -1
- package/analytics/events.js +7 -7
- package/lib/constants/events.js +7 -7
- package/lib/constants/statuses.js +8 -8
- package/lib/helpers.js +61 -61
- package/lib/publicReportingAPI.js +28 -28
- package/lib/report-portal-client.js +486 -481
- package/lib/rest.js +82 -81
- package/package.json +17 -12
- package/.eslintrc +0 -17
- package/.istanbul.yml +0 -3
- package/spec/analytics.spec.js +0 -46
- package/spec/helper.spec.js +0 -142
- package/spec/publicReportingAPI.spec.js +0 -75
- package/spec/report-portal-client.spec.js +0 -744
- package/spec/rest.spec.js +0 -315
- package/spec/support/jasmine.json +0 -11
- package/version_fragment +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
|
|
2
|
+
## [5.0.6] - 2022-01-13
|
|
3
|
+
### Fixed
|
|
4
|
+
- Security vulnerabilities (axios, path-parse, minimist)
|
|
5
|
+
### Changed
|
|
6
|
+
- Package size reduced
|
|
7
|
+
|
|
2
8
|
## [5.0.5] - 2021-05-25
|
|
3
9
|
### Added
|
|
4
10
|
- Possibility to change Axios Requests timeout (closes [#115](https://github.com/reportportal/client-javascript/issues/115))
|
package/README.md
CHANGED
|
@@ -12,6 +12,9 @@ Library is used only for implementors of custom listeners for ReportPortal.
|
|
|
12
12
|
* [Cucumber integration](https://github.com/reportportal/agent-js-cucumber)
|
|
13
13
|
* [Codecept integration](https://github.com/reportportal/agent-js-codecept)
|
|
14
14
|
* [Postman integration](https://github.com/reportportal/agent-js-postman)
|
|
15
|
+
* [TestCafe integration](https://github.com/reportportal/agent-js-testcafe)
|
|
16
|
+
* [Webdriverio integration](https://github.com/reportportal/agent-js-webdriverio)
|
|
17
|
+
* [Playwright integration](https://github.com/reportportal/agent-js-playwright)
|
|
15
18
|
|
|
16
19
|
Examples for test framework integrations from the list above described in [examples](https://github.com/reportportal/examples-js) repository.
|
|
17
20
|
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.0.
|
|
1
|
+
5.0.6
|
package/analytics/analytics.js
CHANGED
|
@@ -2,14 +2,14 @@ const ua = require('universal-analytics');
|
|
|
2
2
|
const { GOOGLE_ANALYTICS_INSTANCE } = require('./constants');
|
|
3
3
|
|
|
4
4
|
class Analytics {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
constructor(agentParams) {
|
|
6
|
+
this.agentParams = agentParams;
|
|
7
|
+
this.visitorInstance = ua(GOOGLE_ANALYTICS_INSTANCE);
|
|
8
|
+
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
trackEvent(event) {
|
|
11
|
+
this.visitorInstance.event(event.category, event.action, event.label).send();
|
|
12
|
+
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
module.exports = Analytics;
|
package/analytics/constants.js
CHANGED
package/analytics/events.js
CHANGED
|
@@ -2,15 +2,15 @@ const { PJSON_VERSION, PJSON_NAME } = require('./constants');
|
|
|
2
2
|
|
|
3
3
|
const CLIENT_JAVASCRIPT = `Client name "${PJSON_NAME}", version "${PJSON_VERSION}"`;
|
|
4
4
|
const CLIENT_JAVASCRIPT_EVENTS = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
START_LAUNCH: {
|
|
6
|
+
category: CLIENT_JAVASCRIPT,
|
|
7
|
+
action: 'Start launch',
|
|
8
|
+
},
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const getAgentEventLabel = agentParams => `Agent name "${agentParams.name}", version "${agentParams.version}"`;
|
|
11
|
+
const getAgentEventLabel = (agentParams) => `Agent name "${agentParams.name}", version "${agentParams.version}"`;
|
|
12
12
|
|
|
13
13
|
module.exports = {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
CLIENT_JAVASCRIPT_EVENTS,
|
|
15
|
+
getAgentEventLabel,
|
|
16
16
|
};
|
package/lib/constants/events.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const EVENTS = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
SET_DESCRIPTION: 'rp:setDescription',
|
|
3
|
+
SET_TEST_CASE_ID: 'rp:setTestCaseId',
|
|
4
|
+
SET_STATUS: 'rp:setStatus',
|
|
5
|
+
SET_LAUNCH_STATUS: 'rp:setLaunchStatus',
|
|
6
|
+
ADD_ATTRIBUTES: 'rp:addAttributes',
|
|
7
|
+
ADD_LOG: 'rp:addLog',
|
|
8
|
+
ADD_LAUNCH_LOG: 'rp:addLaunchLog',
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
module.exports = { EVENTS };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const RP_STATUSES = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
PASSED: 'passed',
|
|
3
|
+
FAILED: 'failed',
|
|
4
|
+
SKIPPED: 'skipped',
|
|
5
|
+
STOPPED: 'stopped',
|
|
6
|
+
INTERRUPTED: 'interrupted',
|
|
7
|
+
CANCELLED: 'cancelled',
|
|
8
|
+
INFO: 'info',
|
|
9
|
+
WARN: 'warn',
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
module.exports = { RP_STATUSES };
|
package/lib/helpers.js
CHANGED
|
@@ -2,84 +2,84 @@ const fs = require('fs');
|
|
|
2
2
|
const glob = require('glob');
|
|
3
3
|
const os = require('os');
|
|
4
4
|
const RestClient = require('./rest');
|
|
5
|
-
const pjson = require('
|
|
5
|
+
const pjson = require('../package.json');
|
|
6
6
|
|
|
7
7
|
const MIN = 3;
|
|
8
8
|
const MAX = 256;
|
|
9
9
|
const PJSON_VERSION = pjson.version;
|
|
10
10
|
const PJSON_NAME = pjson.name;
|
|
11
11
|
|
|
12
|
-
const getUUIDFromFileName = filename => filename.match(/rplaunch-(.*)\.tmp/)[1];
|
|
12
|
+
const getUUIDFromFileName = (filename) => filename.match(/rplaunch-(.*)\.tmp/)[1];
|
|
13
13
|
|
|
14
14
|
module.exports = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
formatName(name) {
|
|
16
|
+
const len = name.length;
|
|
17
|
+
// eslint-disable-next-line no-mixed-operators
|
|
18
|
+
return ((len < MIN) ? (name + new Array(MIN - len + 1).join('.')) : name).slice(-MAX);
|
|
19
|
+
},
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
now() {
|
|
22
|
+
return new Date().valueOf();
|
|
23
|
+
},
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
getServerResult(url, request, options, method) {
|
|
26
|
+
return RestClient
|
|
27
|
+
.request(method, url, request, options);
|
|
28
|
+
},
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
readLaunchesFromFile() {
|
|
31
|
+
const files = glob.sync('rplaunch-*.tmp');
|
|
32
|
+
const ids = files.map(getUUIDFromFileName);
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
return ids;
|
|
35
|
+
},
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
saveLaunchIdToFile(launchId) {
|
|
38
|
+
const filename = `rplaunch-${launchId}.tmp`;
|
|
39
|
+
fs.open(filename, 'w', (err) => {
|
|
40
|
+
if (err) {
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
46
|
+
getSystemAttribute() {
|
|
47
|
+
const osType = os.type();
|
|
48
|
+
const osArchitecture = os.arch();
|
|
49
|
+
const RAMSize = os.totalmem();
|
|
50
|
+
const nodeVersion = process.version;
|
|
51
|
+
const systemAttr = [{
|
|
52
|
+
key: 'client',
|
|
53
|
+
value: `${PJSON_NAME}|${PJSON_VERSION}`,
|
|
54
|
+
system: true,
|
|
55
|
+
}, {
|
|
56
|
+
key: 'os',
|
|
57
|
+
value: `${osType}|${osArchitecture}`,
|
|
58
|
+
system: true,
|
|
59
|
+
}, {
|
|
60
|
+
key: 'RAMSize',
|
|
61
|
+
value: RAMSize,
|
|
62
|
+
system: true,
|
|
63
|
+
}, {
|
|
64
|
+
key: 'nodeJS',
|
|
65
|
+
value: nodeVersion,
|
|
66
|
+
system: true,
|
|
67
|
+
}];
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
return systemAttr;
|
|
70
|
+
},
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
generateTestCaseId(codeRef, params) {
|
|
73
|
+
if (!codeRef) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
if (!params) {
|
|
78
|
+
return codeRef;
|
|
79
|
+
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
const parameters = params.reduce((result, item) => (item.value ? result.concat(item.value) : result), []);
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
return `${codeRef}[${parameters}]`;
|
|
84
|
+
},
|
|
85
85
|
};
|
|
@@ -4,16 +4,16 @@ const { EVENTS } = require('./constants/events');
|
|
|
4
4
|
* Public API to emit additional events to RP JS agents.
|
|
5
5
|
*/
|
|
6
6
|
class PublicReportingAPI {
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
8
|
* Emit set description event.
|
|
9
9
|
* @param {String} text - description of current test/suite.
|
|
10
10
|
* @param {String} suite - suite description, optional.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
static setDescription(text, suite) {
|
|
13
|
+
process.emit(EVENTS.SET_DESCRIPTION, { text, suite });
|
|
14
|
+
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
17
|
* Emit add attributes event.
|
|
18
18
|
* @param {Array} attributes - array of attributes, should looks like this:
|
|
19
19
|
* [{
|
|
@@ -23,11 +23,11 @@ class PublicReportingAPI {
|
|
|
23
23
|
*
|
|
24
24
|
* @param {String} suite - suite description, optional.
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
static addAttributes(attributes, suite) {
|
|
27
|
+
process.emit(EVENTS.ADD_ATTRIBUTES, { attributes, suite });
|
|
28
|
+
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
31
|
* Emit send log to test item event.
|
|
32
32
|
* @param {Object} log - log object should looks like this:
|
|
33
33
|
* {
|
|
@@ -41,11 +41,11 @@ class PublicReportingAPI {
|
|
|
41
41
|
* }
|
|
42
42
|
* @param {String} suite - suite description, optional.
|
|
43
43
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
static addLog(log, suite) {
|
|
45
|
+
process.emit(EVENTS.ADD_LOG, { log, suite });
|
|
46
|
+
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
49
|
* Emit send log to current launch event.
|
|
50
50
|
* @param {Object} log - log object should looks like this:
|
|
51
51
|
* {
|
|
@@ -58,35 +58,35 @@ class PublicReportingAPI {
|
|
|
58
58
|
* },
|
|
59
59
|
* }
|
|
60
60
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
static addLaunchLog(log) {
|
|
62
|
+
process.emit(EVENTS.ADD_LAUNCH_LOG, log);
|
|
63
|
+
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
/**
|
|
66
66
|
* Emit set testCaseId event.
|
|
67
67
|
* @param {String} testCaseId - testCaseId of current test/suite.
|
|
68
68
|
* @param {String} suite - suite description, optional.
|
|
69
69
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
static setTestCaseId(testCaseId, suite) {
|
|
71
|
+
process.emit(EVENTS.SET_TEST_CASE_ID, { testCaseId, suite });
|
|
72
|
+
}
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
/**
|
|
75
75
|
* Emit set status to current launch event.
|
|
76
76
|
* @param {String} status - status of current launch.
|
|
77
77
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
static setLaunchStatus(status) {
|
|
79
|
+
process.emit(EVENTS.SET_LAUNCH_STATUS, status);
|
|
80
|
+
}
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
/**
|
|
83
83
|
* Emit set status event.
|
|
84
84
|
* @param {String} status - status of current test/suite.
|
|
85
85
|
* @param {String} suite - suite description, optional.
|
|
86
86
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
static setStatus(status, suite) {
|
|
88
|
+
process.emit(EVENTS.SET_STATUS, { status, suite });
|
|
89
|
+
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
module.exports = PublicReportingAPI;
|