@reportportal/client-javascript 5.0.2 → 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.
@@ -1,15 +1,15 @@
1
- const ua = require('universal-analytics');
2
- const { GOOGLE_ANALYTICS_INSTANCE } = require('./constants');
3
-
4
- class Analytics {
5
- constructor(agentParams) {
6
- this.agentParams = agentParams;
7
- this.visitorInstance = ua(GOOGLE_ANALYTICS_INSTANCE);
8
- }
9
-
10
- trackEvent(event) {
11
- this.visitorInstance.event(event.category, event.action, event.label).send();
12
- }
13
- }
14
-
15
- module.exports = Analytics;
1
+ const ua = require('universal-analytics');
2
+ const { GOOGLE_ANALYTICS_INSTANCE } = require('./constants');
3
+
4
+ class Analytics {
5
+ constructor(agentParams) {
6
+ this.agentParams = agentParams;
7
+ this.visitorInstance = ua(GOOGLE_ANALYTICS_INSTANCE);
8
+ }
9
+
10
+ trackEvent(event) {
11
+ this.visitorInstance.event(event.category, event.action, event.label).send();
12
+ }
13
+ }
14
+
15
+ module.exports = Analytics;
@@ -1,7 +1,7 @@
1
- const pjson = require('./../package.json');
2
-
3
- const PJSON_VERSION = pjson.version;
4
- const PJSON_NAME = pjson.name;
5
- const GOOGLE_ANALYTICS_INSTANCE = 'UA-173456809-1';
6
-
7
- module.exports = { PJSON_VERSION, PJSON_NAME, GOOGLE_ANALYTICS_INSTANCE };
1
+ const pjson = require('../package.json');
2
+
3
+ const PJSON_VERSION = pjson.version;
4
+ const PJSON_NAME = pjson.name;
5
+ const GOOGLE_ANALYTICS_INSTANCE = 'UA-173456809-1';
6
+
7
+ module.exports = { PJSON_VERSION, PJSON_NAME, GOOGLE_ANALYTICS_INSTANCE };
@@ -1,16 +1,16 @@
1
- const { PJSON_VERSION, PJSON_NAME } = require('./constants');
2
-
3
- const CLIENT_JAVASCRIPT = `Client name "${PJSON_NAME}", version "${PJSON_VERSION}"`;
4
- const CLIENT_JAVASCRIPT_EVENTS = {
5
- START_LAUNCH: {
6
- category: CLIENT_JAVASCRIPT,
7
- action: 'Start launch',
8
- },
9
- };
10
-
11
- const getAgentEventLabel = agentParams => `Agent name "${agentParams.name}", version "${agentParams.version}"`;
12
-
13
- module.exports = {
14
- CLIENT_JAVASCRIPT_EVENTS,
15
- getAgentEventLabel,
16
- };
1
+ const { PJSON_VERSION, PJSON_NAME } = require('./constants');
2
+
3
+ const CLIENT_JAVASCRIPT = `Client name "${PJSON_NAME}", version "${PJSON_VERSION}"`;
4
+ const CLIENT_JAVASCRIPT_EVENTS = {
5
+ START_LAUNCH: {
6
+ category: CLIENT_JAVASCRIPT,
7
+ action: 'Start launch',
8
+ },
9
+ };
10
+
11
+ const getAgentEventLabel = (agentParams) => `Agent name "${agentParams.name}", version "${agentParams.version}"`;
12
+
13
+ module.exports = {
14
+ CLIENT_JAVASCRIPT_EVENTS,
15
+ getAgentEventLabel,
16
+ };
@@ -1,11 +1,11 @@
1
1
  const EVENTS = {
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',
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
- const RP_STATUSES = {
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
- };
11
-
12
- module.exports = { RP_STATUSES };
1
+ const RP_STATUSES = {
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
+ };
11
+
12
+ module.exports = { RP_STATUSES };
package/lib/helpers.js CHANGED
@@ -1,85 +1,85 @@
1
- const fs = require('fs');
2
- const glob = require('glob');
3
- const os = require('os');
4
- const RestClient = require('./rest');
5
- const pjson = require('./../package.json');
6
-
7
- const MIN = 3;
8
- const MAX = 256;
9
- const PJSON_VERSION = pjson.version;
10
- const PJSON_NAME = pjson.name;
11
-
12
- const getUUIDFromFileName = filename => filename.match(/rplaunch-(.*)\.tmp/)[1];
13
-
14
- module.exports = {
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
-
21
- now() {
22
- return new Date().valueOf();
23
- },
24
-
25
- getServerResult(url, request, options, method) {
26
- return RestClient
27
- .request(method, url, request, options);
28
- },
29
-
30
- readLaunchesFromFile() {
31
- const files = glob.sync('rplaunch-*.tmp');
32
- const ids = files.map(getUUIDFromFileName);
33
-
34
- return ids;
35
- },
36
-
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
-
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
-
69
- return systemAttr;
70
- },
71
-
72
- generateTestCaseId(codeRef, params) {
73
- if (!codeRef) {
74
- return;
75
- }
76
-
77
- if (!params) {
78
- return codeRef;
79
- }
80
-
81
- const parameters = params.reduce((result, item) => (item.value ? result.concat(item.value) : result), []);
82
-
83
- return `${codeRef}[${parameters}]`;
84
- },
85
- };
1
+ const fs = require('fs');
2
+ const glob = require('glob');
3
+ const os = require('os');
4
+ const RestClient = require('./rest');
5
+ const pjson = require('../package.json');
6
+
7
+ const MIN = 3;
8
+ const MAX = 256;
9
+ const PJSON_VERSION = pjson.version;
10
+ const PJSON_NAME = pjson.name;
11
+
12
+ const getUUIDFromFileName = (filename) => filename.match(/rplaunch-(.*)\.tmp/)[1];
13
+
14
+ module.exports = {
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
+
21
+ now() {
22
+ return new Date().valueOf();
23
+ },
24
+
25
+ getServerResult(url, request, options, method) {
26
+ return RestClient
27
+ .request(method, url, request, options);
28
+ },
29
+
30
+ readLaunchesFromFile() {
31
+ const files = glob.sync('rplaunch-*.tmp');
32
+ const ids = files.map(getUUIDFromFileName);
33
+
34
+ return ids;
35
+ },
36
+
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
+
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
+
69
+ return systemAttr;
70
+ },
71
+
72
+ generateTestCaseId(codeRef, params) {
73
+ if (!codeRef) {
74
+ return;
75
+ }
76
+
77
+ if (!params) {
78
+ return codeRef;
79
+ }
80
+
81
+ const parameters = params.reduce((result, item) => (item.value ? result.concat(item.value) : result), []);
82
+
83
+ return `${codeRef}[${parameters}]`;
84
+ },
85
+ };
@@ -1,92 +1,92 @@
1
- const { EVENTS } = require('./constants/events');
2
-
3
- /**
4
- * Public API to emit additional events to RP JS agents.
5
- */
6
- class PublicReportingAPI {
7
- /**
8
- * Emit set description event.
9
- * @param {String} text - description of current test/suite.
10
- * @param {String} suite - suite description, optional.
11
- */
12
- static setDescription(text, suite) {
13
- process.emit(EVENTS.SET_DESCRIPTION, { text, suite });
14
- }
15
-
16
- /**
17
- * Emit add attributes event.
18
- * @param {Array} attributes - array of attributes, should looks like this:
19
- * [{
20
- * key: "attrKey",
21
- * value: "attrValue",
22
- * }]
23
- *
24
- * @param {String} suite - suite description, optional.
25
- */
26
- static addAttributes(attributes, suite) {
27
- process.emit(EVENTS.ADD_ATTRIBUTES, { attributes, suite });
28
- }
29
-
30
- /**
31
- * Emit send log to test item event.
32
- * @param {Object} log - log object should looks like this:
33
- * {
34
- * level: "INFO",
35
- * message: "log message",
36
- * file: {
37
- * name: "filename",
38
- * type: "image/png", // media type
39
- * content: data, // file content represented as 64base string
40
- * },
41
- * }
42
- * @param {String} suite - suite description, optional.
43
- */
44
- static addLog(log, suite) {
45
- process.emit(EVENTS.ADD_LOG, { log, suite });
46
- }
47
-
48
- /**
49
- * Emit send log to current launch event.
50
- * @param {Object} log - log object should looks like this:
51
- * {
52
- * level: "INFO",
53
- * message: "log message",
54
- * file: {
55
- * name: "filename",
56
- * type: "image/png", // media type
57
- * content: data, // file content represented as 64base string
58
- * },
59
- * }
60
- */
61
- static addLaunchLog(log) {
62
- process.emit(EVENTS.ADD_LAUNCH_LOG, log);
63
- }
64
-
65
- /**
66
- * Emit set testCaseId event.
67
- * @param {String} testCaseId - testCaseId of current test/suite.
68
- * @param {String} suite - suite description, optional.
69
- */
70
- static setTestCaseId(testCaseId, suite) {
71
- process.emit(EVENTS.SET_TEST_CASE_ID, { testCaseId, suite });
72
- }
73
-
74
- /**
75
- * Emit set status to current launch event.
76
- * @param {String} status - status of current launch.
77
- */
78
- static setLaunchStatus(status) {
79
- process.emit(EVENTS.SET_LAUNCH_STATUS, status);
80
- }
81
-
82
- /**
83
- * Emit set status event.
84
- * @param {String} status - status of current test/suite.
85
- * @param {String} suite - suite description, optional.
86
- */
87
- static setStatus(status, suite) {
88
- process.emit(EVENTS.SET_STATUS, { status, suite });
89
- }
90
- }
91
-
92
- module.exports = PublicReportingAPI;
1
+ const { EVENTS } = require('./constants/events');
2
+
3
+ /**
4
+ * Public API to emit additional events to RP JS agents.
5
+ */
6
+ class PublicReportingAPI {
7
+ /**
8
+ * Emit set description event.
9
+ * @param {String} text - description of current test/suite.
10
+ * @param {String} suite - suite description, optional.
11
+ */
12
+ static setDescription(text, suite) {
13
+ process.emit(EVENTS.SET_DESCRIPTION, { text, suite });
14
+ }
15
+
16
+ /**
17
+ * Emit add attributes event.
18
+ * @param {Array} attributes - array of attributes, should looks like this:
19
+ * [{
20
+ * key: "attrKey",
21
+ * value: "attrValue",
22
+ * }]
23
+ *
24
+ * @param {String} suite - suite description, optional.
25
+ */
26
+ static addAttributes(attributes, suite) {
27
+ process.emit(EVENTS.ADD_ATTRIBUTES, { attributes, suite });
28
+ }
29
+
30
+ /**
31
+ * Emit send log to test item event.
32
+ * @param {Object} log - log object should looks like this:
33
+ * {
34
+ * level: "INFO",
35
+ * message: "log message",
36
+ * file: {
37
+ * name: "filename",
38
+ * type: "image/png", // media type
39
+ * content: data, // file content represented as 64base string
40
+ * },
41
+ * }
42
+ * @param {String} suite - suite description, optional.
43
+ */
44
+ static addLog(log, suite) {
45
+ process.emit(EVENTS.ADD_LOG, { log, suite });
46
+ }
47
+
48
+ /**
49
+ * Emit send log to current launch event.
50
+ * @param {Object} log - log object should looks like this:
51
+ * {
52
+ * level: "INFO",
53
+ * message: "log message",
54
+ * file: {
55
+ * name: "filename",
56
+ * type: "image/png", // media type
57
+ * content: data, // file content represented as 64base string
58
+ * },
59
+ * }
60
+ */
61
+ static addLaunchLog(log) {
62
+ process.emit(EVENTS.ADD_LAUNCH_LOG, log);
63
+ }
64
+
65
+ /**
66
+ * Emit set testCaseId event.
67
+ * @param {String} testCaseId - testCaseId of current test/suite.
68
+ * @param {String} suite - suite description, optional.
69
+ */
70
+ static setTestCaseId(testCaseId, suite) {
71
+ process.emit(EVENTS.SET_TEST_CASE_ID, { testCaseId, suite });
72
+ }
73
+
74
+ /**
75
+ * Emit set status to current launch event.
76
+ * @param {String} status - status of current launch.
77
+ */
78
+ static setLaunchStatus(status) {
79
+ process.emit(EVENTS.SET_LAUNCH_STATUS, status);
80
+ }
81
+
82
+ /**
83
+ * Emit set status event.
84
+ * @param {String} status - status of current test/suite.
85
+ * @param {String} suite - suite description, optional.
86
+ */
87
+ static setStatus(status, suite) {
88
+ process.emit(EVENTS.SET_STATUS, { status, suite });
89
+ }
90
+ }
91
+
92
+ module.exports = PublicReportingAPI;