@testomatio/reporter 1.6.0-beta-2-artifacts → 2.0.0-beta-esm

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.
Files changed (97) hide show
  1. package/lib/adapter/codecept.js +288 -330
  2. package/lib/adapter/cucumber/current.js +195 -203
  3. package/lib/adapter/cucumber/legacy.js +130 -155
  4. package/lib/adapter/cucumber.js +5 -16
  5. package/lib/adapter/cypress-plugin/index.js +91 -105
  6. package/lib/adapter/jasmine/jasmine.js +63 -0
  7. package/lib/adapter/jasmine.js +54 -53
  8. package/lib/adapter/jest.js +97 -99
  9. package/lib/adapter/mocha/mocha.js +125 -0
  10. package/lib/adapter/mocha.js +111 -140
  11. package/lib/adapter/playwright.js +168 -200
  12. package/lib/adapter/vitest.js +144 -143
  13. package/lib/adapter/webdriver.js +113 -97
  14. package/lib/bin/reportXml.js +49 -49
  15. package/lib/bin/startTest.js +80 -97
  16. package/lib/client.js +344 -385
  17. package/lib/config.js +16 -21
  18. package/lib/constants.js +49 -43
  19. package/lib/data-storage.js +206 -188
  20. package/lib/fileUploader.js +245 -0
  21. package/lib/junit-adapter/adapter.js +17 -20
  22. package/lib/junit-adapter/csharp.js +18 -14
  23. package/lib/junit-adapter/index.js +27 -25
  24. package/lib/junit-adapter/java.js +41 -53
  25. package/lib/junit-adapter/javascript.js +30 -27
  26. package/lib/junit-adapter/python.js +38 -37
  27. package/lib/junit-adapter/ruby.js +11 -8
  28. package/lib/output.js +44 -52
  29. package/lib/package.json +1 -0
  30. package/lib/pipe/bitbucket.js +208 -227
  31. package/lib/pipe/csv.js +111 -124
  32. package/lib/pipe/github.js +184 -211
  33. package/lib/pipe/gitlab.js +164 -205
  34. package/lib/pipe/html.js +253 -312
  35. package/lib/pipe/index.js +83 -63
  36. package/lib/pipe/testomatio.js +391 -454
  37. package/lib/reporter-functions.js +16 -20
  38. package/lib/reporter.js +47 -17
  39. package/lib/services/artifacts.js +55 -51
  40. package/lib/services/index.js +14 -12
  41. package/lib/services/key-values.js +56 -53
  42. package/lib/services/logger.js +227 -245
  43. package/lib/utils/chalk.js +10 -0
  44. package/lib/utils/pipe_utils.js +91 -84
  45. package/lib/utils/utils.js +289 -273
  46. package/lib/xmlReader.js +480 -519
  47. package/package.json +57 -19
  48. package/src/adapter/codecept.js +369 -0
  49. package/src/adapter/cucumber/current.js +228 -0
  50. package/src/adapter/cucumber/legacy.js +158 -0
  51. package/src/adapter/cucumber.js +4 -0
  52. package/src/adapter/cypress-plugin/index.js +110 -0
  53. package/src/adapter/jasmine.js +60 -0
  54. package/src/adapter/jest.js +107 -0
  55. package/src/adapter/mocha.cjs +2 -0
  56. package/src/adapter/mocha.js +156 -0
  57. package/src/adapter/playwright.js +222 -0
  58. package/src/adapter/vitest.js +183 -0
  59. package/src/adapter/webdriver.js +111 -0
  60. package/src/bin/reportXml.js +67 -0
  61. package/src/bin/startTest.js +119 -0
  62. package/src/client.js +423 -0
  63. package/src/config.js +30 -0
  64. package/src/constants.js +49 -0
  65. package/src/data-storage.js +204 -0
  66. package/src/fileUploader.js +307 -0
  67. package/src/junit-adapter/adapter.js +23 -0
  68. package/src/junit-adapter/csharp.js +16 -0
  69. package/src/junit-adapter/index.js +28 -0
  70. package/src/junit-adapter/java.js +58 -0
  71. package/src/junit-adapter/javascript.js +31 -0
  72. package/src/junit-adapter/python.js +42 -0
  73. package/src/junit-adapter/ruby.js +10 -0
  74. package/src/output.js +57 -0
  75. package/src/pipe/bitbucket.js +254 -0
  76. package/src/pipe/csv.js +140 -0
  77. package/src/pipe/github.js +234 -0
  78. package/src/pipe/gitlab.js +229 -0
  79. package/src/pipe/html.js +366 -0
  80. package/src/pipe/index.js +73 -0
  81. package/src/pipe/testomatio.js +498 -0
  82. package/src/reporter-functions.js +44 -0
  83. package/src/reporter.cjs +22 -0
  84. package/src/reporter.js +24 -0
  85. package/src/services/artifacts.js +59 -0
  86. package/src/services/index.js +13 -0
  87. package/src/services/key-values.js +59 -0
  88. package/src/services/logger.js +314 -0
  89. package/src/template/emptyData.svg +23 -0
  90. package/src/template/testomatio.hbs +1421 -0
  91. package/src/utils/chalk.js +13 -0
  92. package/src/utils/pipe_utils.js +127 -0
  93. package/src/utils/utils.js +341 -0
  94. package/src/xmlReader.js +551 -0
  95. package/lib/bin/cli.js +0 -216
  96. package/lib/bin/uploadArtifacts.js +0 -86
  97. package/lib/uploader.js +0 -312
@@ -1,46 +1,42 @@
1
- const { services } = require('./services');
2
- const { initPlaywrightForStorage } = require('./adapter/playwright');
3
-
4
- if (process.env.PLAYWRIGHT_TEST_BASE_URL) {
5
- initPlaywrightForStorage();
6
- }
7
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_js_1 = require("./services/index.js");
4
+ const playwright_js_1 = require("./adapter/playwright.js");
5
+ if (process.env.PLAYWRIGHT_TEST_BASE_URL)
6
+ (0, playwright_js_1.initPlaywrightForStorage)();
8
7
  /**
9
8
  * Stores path to file as artifact and uploads it to the S3 storage
10
9
  * @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
11
10
  */
12
11
  function saveArtifact(data, context = null) {
13
- if (!data) return;
14
- services.artifacts.put(data, context);
12
+ if (!data)
13
+ return;
14
+ index_js_1.services.artifacts.put(data, context);
15
15
  }
16
-
17
16
  /**
18
17
  * Attach log message(s) to the test report
19
18
  * @param {...any} args
20
19
  */
21
20
  function logMessage(...args) {
22
- services.logger._templateLiteralLog(...args);
21
+ index_js_1.services.logger._templateLiteralLog(...args);
23
22
  }
24
-
25
23
  /**
26
24
  * Similar to "log" function but marks message in report as a step
27
25
  * @param {*} message
28
26
  */
29
27
  function addStep(message) {
30
- services.logger.step(message);
28
+ index_js_1.services.logger.step(message);
31
29
  }
32
-
33
30
  /**
34
31
  * Add key-value pair(s) to the test report
35
32
  * @param {*} keyValue
36
33
  */
37
34
  function setKeyValue(keyValue) {
38
- services.keyValues.put(keyValue);
35
+ index_js_1.services.keyValues.put(keyValue);
39
36
  }
40
-
41
37
  module.exports = {
42
- artifact: saveArtifact,
43
- log: logMessage,
44
- step: addStep,
45
- keyValue: setKeyValue,
38
+ artifact: saveArtifact,
39
+ log: logMessage,
40
+ step: addStep,
41
+ keyValue: setKeyValue,
46
42
  };
package/lib/reporter.js CHANGED
@@ -1,19 +1,49 @@
1
- const TestomatClient = require('./client');
2
- const TRConstants = require('./constants');
3
- const { services } = require('./services');
4
-
5
- const reporterFunctions = require('./reporter-functions');
6
-
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.step = exports.meta = exports.logger = exports.log = exports.artifact = void 0;
30
+ const client_js_1 = __importDefault(require("./client.js"));
31
+ const TRConstants = __importStar(require("./constants.js"));
32
+ const index_js_1 = require("./services/index.js");
33
+ const reporter_functions_js_1 = __importDefault(require("./reporter-functions.js"));
7
34
  module.exports = {
8
- // TODO: deprecate in future; use log or testomat.log
9
- testomatioLogger: services.logger,
10
-
11
- artifact: reporterFunctions.artifact,
12
- log: reporterFunctions.log,
13
- logger: services.logger,
14
- meta: reporterFunctions.keyValue,
15
- step: reporterFunctions.step,
16
-
17
- TestomatClient,
18
- TRConstants,
35
+ // TODO: deprecate in future; use log or testomat.log
36
+ testomatioLogger: index_js_1.services.logger,
37
+ artifact: reporter_functions_js_1.default.artifact,
38
+ log: reporter_functions_js_1.default.log,
39
+ logger: index_js_1.services.logger,
40
+ meta: reporter_functions_js_1.default.keyValue,
41
+ step: reporter_functions_js_1.default.step,
42
+ TestomatClient: client_js_1.default,
43
+ TRConstants,
19
44
  };
45
+ exports.artifact = reporter_functions_js_1.default.artifact;
46
+ exports.log = reporter_functions_js_1.default.log;
47
+ exports.logger = index_js_1.services.logger;
48
+ exports.meta = reporter_functions_js_1.default.keyValue;
49
+ exports.step = reporter_functions_js_1.default.step;
@@ -1,57 +1,61 @@
1
- const debug = require('debug')('@testomatio/reporter:services-artifacts');
2
- const { dataStorage } = require('../data-storage');
3
-
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.artifactStorage = void 0;
7
+ const debug_1 = __importDefault(require("debug"));
8
+ const data_storage_js_1 = require("../data-storage.js");
9
+ const debug = (0, debug_1.default)('@testomatio/reporter:services-artifacts');
4
10
  /**
5
11
  * Artifact storage is supposed to store file paths
6
12
  */
7
13
  class ArtifactStorage {
8
- static #instance;
9
-
10
- /**
11
- * Singleton
12
- * @returns {ArtifactStorage}
13
- */
14
- static getInstance() {
15
- if (!this.#instance) {
16
- this.#instance = new ArtifactStorage();
14
+ static #instance;
15
+ /**
16
+ * Singleton
17
+ * @returns {ArtifactStorage}
18
+ */
19
+ static getInstance() {
20
+ if (!this.#instance) {
21
+ this.#instance = new ArtifactStorage();
22
+ }
23
+ return this.#instance;
24
+ }
25
+ /**
26
+ * Stores path to file as artifact and uploads it to the S3 storage
27
+ * @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
28
+ * @param {*} context testId or test title
29
+ */
30
+ put(data, context = null) {
31
+ if (!data)
32
+ return;
33
+ debug('Save artifact:', data);
34
+ data_storage_js_1.dataStorage.putData('artifact', data, context);
35
+ }
36
+ /**
37
+ * Returns list of artifacts to upload
38
+ * @param {*} context testId or test context from test runner
39
+ * @returns {(string | {path: string, type: string, name: string})[]}
40
+ */
41
+ get(context) {
42
+ let artifacts = data_storage_js_1.dataStorage.getData('artifact', context);
43
+ if (!artifacts || !artifacts.length)
44
+ return [];
45
+ artifacts = artifacts.map(artifactData => {
46
+ // artifact could be an object ({type, path, name} props) or string (just path)
47
+ let artifact;
48
+ try {
49
+ artifact = JSON.parse(artifactData);
50
+ }
51
+ catch (e) {
52
+ artifact = artifactData;
53
+ }
54
+ return artifact;
55
+ });
56
+ artifacts = artifacts.filter(artifact => !!artifact);
57
+ debug(`Artifacts for test ${context}:`, artifacts);
58
+ return artifacts.length ? artifacts : [];
17
59
  }
18
- return this.#instance;
19
- }
20
-
21
- /**
22
- * Stores path to file as artifact and uploads it to the S3 storage
23
- * @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
24
- * @param {*} context testId or test title
25
- */
26
- put(data, context = null) {
27
- if (!data) return;
28
- debug('Save artifact:', data);
29
- dataStorage.putData('artifact', data, context);
30
- }
31
-
32
- /**
33
- * Returns list of artifacts to upload
34
- * @param {*} context testId or test context from test runner
35
- * @returns {(string | {path: string, type: string, name: string})[]}
36
- */
37
- get(context) {
38
- let artifacts = dataStorage.getData('artifact', context);
39
- if (!artifacts || !artifacts.length) return [];
40
-
41
- artifacts = artifacts.map(artifactData => {
42
- // artifact could be an object ({type, path, name} props) or string (just path)
43
- let artifact;
44
- try {
45
- artifact = JSON.parse(artifactData);
46
- } catch (e) {
47
- artifact = artifactData;
48
- }
49
- return artifact;
50
- });
51
- artifacts = artifacts.filter(artifact => !!artifact);
52
- debug(`Artifacts for test ${context}:`, artifacts);
53
- return artifacts.length ? artifacts : [];
54
- }
55
60
  }
56
-
57
- module.exports.artifactStorage = ArtifactStorage.getInstance();
61
+ exports.artifactStorage = ArtifactStorage.getInstance();
@@ -1,13 +1,15 @@
1
- const { logger } = require('./logger');
2
- const { artifactStorage } = require('./artifacts');
3
- const { keyValueStorage } = require('./key-values');
4
- const { dataStorage } = require('../data-storage');
5
-
6
- module.exports.services = {
7
- logger,
8
- artifacts: artifactStorage,
9
- keyValues: keyValueStorage,
10
- setContext: context => {
11
- dataStorage.setContext(context);
12
- },
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.services = void 0;
4
+ const logger_js_1 = require("./logger.js");
5
+ const artifacts_js_1 = require("./artifacts.js");
6
+ const key_values_js_1 = require("./key-values.js");
7
+ const data_storage_js_1 = require("../data-storage.js");
8
+ exports.services = {
9
+ logger: logger_js_1.logger,
10
+ artifacts: artifacts_js_1.artifactStorage,
11
+ keyValues: key_values_js_1.keyValueStorage,
12
+ setContext: context => {
13
+ data_storage_js_1.dataStorage.setContext(context);
14
+ },
13
15
  };
@@ -1,58 +1,61 @@
1
- const debug = require('debug')('@testomatio/reporter:services-key-value');
2
- const { dataStorage } = require('../data-storage');
3
-
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.keyValueStorage = void 0;
7
+ const debug_1 = __importDefault(require("debug"));
8
+ const data_storage_js_1 = require("../data-storage.js");
9
+ const debug = (0, debug_1.default)('@testomatio/reporter:services-key-value');
4
10
  class KeyValueStorage {
5
- static #instance;
6
-
7
- /**
8
- *
9
- * @returns {KeyValueStorage}
10
- */
11
- static getInstance() {
12
- if (!this.#instance) {
13
- this.#instance = new KeyValueStorage();
11
+ static #instance;
12
+ /**
13
+ *
14
+ * @returns {KeyValueStorage}
15
+ */
16
+ static getInstance() {
17
+ if (!this.#instance) {
18
+ this.#instance = new KeyValueStorage();
19
+ }
20
+ return this.#instance;
21
+ }
22
+ /**
23
+ * Stores key-value pair and passes it to reporter
24
+ * @param {{key: string}} keyValue - key-value pair(s) as object
25
+ * @param {*} context - full test title
26
+ */
27
+ put(keyValue, context = null) {
28
+ if (!keyValue)
29
+ return;
30
+ data_storage_js_1.dataStorage.putData('keyvalue', keyValue, context);
31
+ }
32
+ #isKeyValueObject(smth) {
33
+ return smth && typeof smth === 'object' && !Array.isArray(smth) && smth !== null;
14
34
  }
15
- return this.#instance;
16
- }
17
-
18
- /**
19
- * Stores key-value pair and passes it to reporter
20
- * @param {{key: string}} keyValue - key-value pair(s) as object
21
- * @param {*} context - full test title
22
- */
23
- put(keyValue, context = null) {
24
- if (!keyValue) return;
25
- dataStorage.putData('keyvalue', keyValue, context);
26
- }
27
-
28
- #isKeyValueObject(smth) {
29
- return smth && typeof smth === 'object' && !Array.isArray(smth) && smth !== null;
30
- }
31
-
32
- /**
33
- * Returns key-values pairs for the test as object
34
- * @param {*} context testId or test context from test runner
35
- * @returns {{[key: string]: string} | {}} key-values pairs as object, e.g. {priority: 'high', browser: 'chrome'}
36
- */
37
- get(context = null) {
38
- const keyValuesList = dataStorage.getData('keyvalue', context);
39
- if (!keyValuesList || !keyValuesList?.length) return {};
40
-
41
- const keyValues = {};
42
- for (const keyValue of keyValuesList) {
43
- if (this.#isKeyValueObject(keyValue)) {
44
- Object.assign(keyValues, keyValue);
45
- } else if (typeof keyValue === 'string') {
46
- try {
47
- Object.assign(keyValues, JSON.parse(keyValue));
48
- } catch (e) {
49
- debug(`Error parsing key-values for test ${context}`, keyValue);
35
+ /**
36
+ * Returns key-values pairs for the test as object
37
+ * @param {*} context testId or test context from test runner
38
+ * @returns {{[key: string]: string} | {}} key-values pairs as object, e.g. {priority: 'high', browser: 'chrome'}
39
+ */
40
+ get(context = null) {
41
+ const keyValuesList = data_storage_js_1.dataStorage.getData('keyvalue', context);
42
+ if (!keyValuesList || !keyValuesList?.length)
43
+ return {};
44
+ const keyValues = {};
45
+ for (const keyValue of keyValuesList) {
46
+ if (this.#isKeyValueObject(keyValue)) {
47
+ Object.assign(keyValues, keyValue);
48
+ }
49
+ else if (typeof keyValue === 'string') {
50
+ try {
51
+ Object.assign(keyValues, JSON.parse(keyValue));
52
+ }
53
+ catch (e) {
54
+ debug(`Error parsing key-values for test ${context}`, keyValue);
55
+ }
56
+ }
50
57
  }
51
- }
58
+ return keyValues;
52
59
  }
53
-
54
- return keyValues;
55
- }
56
60
  }
57
-
58
- module.exports.keyValueStorage = KeyValueStorage.getInstance();
61
+ exports.keyValueStorage = KeyValueStorage.getInstance();