@testomatio/reporter 2.0.1-beta.5-timestamp → 2.0.1-beta.7

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 (152) hide show
  1. package/README.md +1 -0
  2. package/lib/adapter/codecept.d.ts +2 -0
  3. package/lib/adapter/codecept.js +297 -335
  4. package/lib/adapter/cucumber/current.d.ts +14 -0
  5. package/lib/adapter/cucumber/current.js +195 -203
  6. package/lib/adapter/cucumber/legacy.d.ts +0 -0
  7. package/lib/adapter/cucumber/legacy.js +130 -155
  8. package/lib/adapter/cucumber.d.ts +2 -0
  9. package/lib/adapter/cucumber.js +5 -16
  10. package/lib/adapter/cypress-plugin/index.d.ts +2 -0
  11. package/lib/adapter/cypress-plugin/index.js +91 -105
  12. package/lib/adapter/jasmine.d.ts +11 -0
  13. package/lib/adapter/jasmine.js +54 -53
  14. package/lib/adapter/jest.d.ts +13 -0
  15. package/lib/adapter/jest.js +97 -99
  16. package/lib/adapter/mocha.d.ts +2 -0
  17. package/lib/adapter/mocha.js +112 -141
  18. package/lib/adapter/nightwatch.d.ts +4 -0
  19. package/lib/adapter/nightwatch.js +80 -0
  20. package/lib/adapter/playwright.d.ts +14 -0
  21. package/lib/adapter/playwright.js +208 -231
  22. package/lib/adapter/vitest.d.ts +35 -0
  23. package/lib/adapter/vitest.js +150 -149
  24. package/lib/adapter/webdriver.d.ts +24 -0
  25. package/lib/adapter/webdriver.js +144 -121
  26. package/lib/bin/cli.d.ts +2 -0
  27. package/lib/bin/cli.js +229 -211
  28. package/lib/bin/reportXml.d.ts +2 -0
  29. package/lib/bin/reportXml.js +51 -52
  30. package/lib/bin/startTest.d.ts +2 -0
  31. package/lib/bin/startTest.js +83 -95
  32. package/lib/bin/uploadArtifacts.d.ts +2 -0
  33. package/lib/bin/uploadArtifacts.js +56 -61
  34. package/lib/client.d.ts +76 -0
  35. package/lib/client.js +431 -465
  36. package/lib/config.d.ts +1 -0
  37. package/lib/config.js +18 -23
  38. package/lib/constants.d.ts +25 -0
  39. package/lib/constants.js +50 -44
  40. package/lib/data-storage.d.ts +34 -0
  41. package/lib/data-storage.js +216 -188
  42. package/lib/junit-adapter/adapter.d.ts +9 -0
  43. package/lib/junit-adapter/adapter.js +17 -20
  44. package/lib/junit-adapter/csharp.d.ts +5 -0
  45. package/lib/junit-adapter/csharp.js +28 -14
  46. package/lib/junit-adapter/index.d.ts +3 -0
  47. package/lib/junit-adapter/index.js +27 -25
  48. package/lib/junit-adapter/java.d.ts +5 -0
  49. package/lib/junit-adapter/java.js +41 -53
  50. package/lib/junit-adapter/javascript.d.ts +4 -0
  51. package/lib/junit-adapter/javascript.js +30 -27
  52. package/lib/junit-adapter/python.d.ts +5 -0
  53. package/lib/junit-adapter/python.js +38 -37
  54. package/lib/junit-adapter/ruby.d.ts +4 -0
  55. package/lib/junit-adapter/ruby.js +11 -8
  56. package/lib/output.d.ts +11 -0
  57. package/lib/output.js +44 -52
  58. package/lib/package.json +3 -0
  59. package/lib/pipe/bitbucket.d.ts +25 -0
  60. package/lib/pipe/bitbucket.js +223 -230
  61. package/lib/pipe/csv.d.ts +47 -0
  62. package/lib/pipe/csv.js +113 -126
  63. package/lib/pipe/debug.d.ts +29 -0
  64. package/lib/pipe/debug.js +125 -99
  65. package/lib/pipe/github.d.ts +30 -0
  66. package/lib/pipe/github.js +218 -213
  67. package/lib/pipe/gitlab.d.ts +25 -0
  68. package/lib/pipe/gitlab.js +183 -206
  69. package/lib/pipe/html.d.ts +35 -0
  70. package/lib/pipe/html.js +258 -321
  71. package/lib/pipe/index.d.ts +1 -0
  72. package/lib/pipe/index.js +94 -66
  73. package/lib/pipe/testomatio.d.ts +71 -0
  74. package/lib/pipe/testomatio.js +429 -474
  75. package/lib/replay.d.ts +31 -0
  76. package/lib/replay.js +255 -0
  77. package/lib/reporter-functions.d.ts +41 -0
  78. package/lib/reporter-functions.js +64 -26
  79. package/lib/reporter.d.ts +235 -0
  80. package/lib/reporter.js +37 -29
  81. package/lib/services/artifacts.d.ts +33 -0
  82. package/lib/services/artifacts.js +55 -51
  83. package/lib/services/index.d.ts +11 -0
  84. package/lib/services/index.js +16 -12
  85. package/lib/services/key-values.d.ts +27 -0
  86. package/lib/services/key-values.js +56 -53
  87. package/lib/services/labels.d.ts +22 -0
  88. package/lib/services/labels.js +62 -0
  89. package/lib/services/logger.d.ts +64 -0
  90. package/lib/services/logger.js +226 -245
  91. package/lib/template/testomatio.hbs +1026 -1366
  92. package/lib/uploader.d.ts +60 -0
  93. package/lib/uploader.js +295 -364
  94. package/lib/utils/pipe_utils.d.ts +41 -0
  95. package/lib/utils/pipe_utils.js +89 -85
  96. package/lib/utils/utils.d.ts +54 -0
  97. package/lib/utils/utils.js +398 -307
  98. package/lib/xmlReader.d.ts +92 -0
  99. package/lib/xmlReader.js +525 -532
  100. package/package.json +64 -21
  101. package/src/adapter/codecept.js +377 -0
  102. package/src/adapter/cucumber/current.js +228 -0
  103. package/src/adapter/cucumber/legacy.js +158 -0
  104. package/src/adapter/cucumber.js +4 -0
  105. package/src/adapter/cypress-plugin/index.js +110 -0
  106. package/src/adapter/jasmine.js +60 -0
  107. package/src/adapter/jest.js +107 -0
  108. package/src/adapter/mocha.cjs +2 -0
  109. package/src/adapter/mocha.js +156 -0
  110. package/src/adapter/nightwatch.js +88 -0
  111. package/src/adapter/playwright.js +258 -0
  112. package/src/adapter/vitest.js +183 -0
  113. package/src/adapter/webdriver.js +142 -0
  114. package/src/bin/cli.js +348 -0
  115. package/src/bin/reportXml.js +77 -0
  116. package/src/bin/startTest.js +124 -0
  117. package/src/bin/uploadArtifacts.js +91 -0
  118. package/src/client.js +519 -0
  119. package/src/config.js +30 -0
  120. package/src/constants.js +53 -0
  121. package/src/data-storage.js +204 -0
  122. package/src/junit-adapter/adapter.js +23 -0
  123. package/src/junit-adapter/csharp.js +28 -0
  124. package/src/junit-adapter/index.js +28 -0
  125. package/src/junit-adapter/java.js +58 -0
  126. package/src/junit-adapter/javascript.js +31 -0
  127. package/src/junit-adapter/python.js +42 -0
  128. package/src/junit-adapter/ruby.js +10 -0
  129. package/src/output.js +57 -0
  130. package/src/pipe/bitbucket.js +252 -0
  131. package/src/pipe/csv.js +140 -0
  132. package/src/pipe/debug.js +125 -0
  133. package/src/pipe/github.js +232 -0
  134. package/src/pipe/gitlab.js +247 -0
  135. package/src/pipe/html.js +373 -0
  136. package/src/pipe/index.js +71 -0
  137. package/src/pipe/testomatio.js +504 -0
  138. package/src/replay.js +262 -0
  139. package/src/reporter-functions.js +96 -0
  140. package/src/reporter.cjs_decprecated +21 -0
  141. package/src/reporter.js +36 -0
  142. package/src/services/artifacts.js +59 -0
  143. package/src/services/index.js +15 -0
  144. package/src/services/key-values.js +59 -0
  145. package/src/services/labels.js +59 -0
  146. package/src/services/logger.js +315 -0
  147. package/src/template/emptyData.svg +23 -0
  148. package/src/template/testomatio.hbs +1081 -0
  149. package/src/uploader.js +376 -0
  150. package/src/utils/pipe_utils.js +119 -0
  151. package/src/utils/utils.js +416 -0
  152. package/src/xmlReader.js +614 -0
package/lib/reporter.js CHANGED
@@ -1,30 +1,38 @@
1
- const TestomatClient = require('./client');
2
- const TRConstants = require('./constants');
3
- const { services } = require('./services');
4
-
5
- const reporterFunctions = require('./reporter-functions');
6
-
7
- const testomat = {
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,
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.label = exports.step = exports.meta = exports.logger = exports.log = exports.artifact = void 0;
7
+ // import TestomatClient from './client.js';
8
+ // import * as TRConstants from './constants.js';
9
+ const index_js_1 = require("./services/index.js");
10
+ const reporter_functions_js_1 = __importDefault(require("./reporter-functions.js"));
11
+ exports.artifact = reporter_functions_js_1.default.artifact;
12
+ exports.log = reporter_functions_js_1.default.log;
13
+ exports.logger = index_js_1.services.logger;
14
+ exports.meta = reporter_functions_js_1.default.keyValue;
15
+ exports.step = reporter_functions_js_1.default.step;
16
+ exports.label = reporter_functions_js_1.default.label;
17
+ /**
18
+ * @typedef {import('./reporter-functions.js')} artifact
19
+ * @typedef {import('./reporter-functions.js')} log
20
+ * @typedef {import('./services/index.js')} logger
21
+ * @typedef {import('./reporter-functions.js')} meta
22
+ * @typedef {import('./reporter-functions.js')} step
23
+ * @typedef {import('./reporter-functions.js')} label
24
+ */
25
+ module.exports = {
26
+ /**
27
+ * @deprecated Use `log` or `testomat.log`
28
+ */
29
+ testomatioLogger: index_js_1.services.logger,
30
+ artifact: reporter_functions_js_1.default.artifact,
31
+ log: reporter_functions_js_1.default.log,
32
+ logger: index_js_1.services.logger,
33
+ meta: reporter_functions_js_1.default.keyValue,
34
+ step: reporter_functions_js_1.default.step,
35
+ label: reporter_functions_js_1.default.label,
36
+ // TestomatClient,
37
+ // TRConstants,
19
38
  };
20
-
21
- module.exports = testomat;
22
-
23
- module.exports.testomatioLogger = testomat;
24
- module.exports.artifact = reporterFunctions.artifact;
25
- module.exports.log = reporterFunctions.log;
26
- module.exports.logger = services.logger;
27
- module.exports.meta = reporterFunctions.keyValue;
28
- module.exports.step = reporterFunctions.step;
29
- module.exports.TestomatClient = TestomatClient;
30
- module.exports.TRConstants = TRConstants;
@@ -0,0 +1,33 @@
1
+ export const artifactStorage: ArtifactStorage;
2
+ /**
3
+ * Artifact storage is supposed to store file paths
4
+ */
5
+ declare class ArtifactStorage {
6
+ static "__#14@#instance": any;
7
+ /**
8
+ * Singleton
9
+ * @returns {ArtifactStorage}
10
+ */
11
+ static getInstance(): ArtifactStorage;
12
+ /**
13
+ * Stores path to file as artifact and uploads it to the S3 storage
14
+ * @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
15
+ * @param {*} context testId or test title
16
+ */
17
+ put(data: string | {
18
+ path: string;
19
+ type: string;
20
+ name: string;
21
+ }, context?: any): void;
22
+ /**
23
+ * Returns list of artifacts to upload
24
+ * @param {*} context testId or test context from test runner
25
+ * @returns {(string | {path: string, type: string, name: string})[]}
26
+ */
27
+ get(context: any): (string | {
28
+ path: string;
29
+ type: string;
30
+ name: string;
31
+ })[];
32
+ }
33
+ export {};
@@ -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();
@@ -0,0 +1,11 @@
1
+ export namespace services {
2
+ export { logger };
3
+ export { artifactStorage as artifacts };
4
+ export { keyValueStorage as keyValues };
5
+ export { labelStorage as labels };
6
+ export function setContext(context: any): void;
7
+ }
8
+ import { logger } from './logger.js';
9
+ import { artifactStorage } from './artifacts.js';
10
+ import { keyValueStorage } from './key-values.js';
11
+ import { labelStorage } from './labels.js';
@@ -1,13 +1,17 @@
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 labels_js_1 = require("./labels.js");
8
+ const data_storage_js_1 = require("../data-storage.js");
9
+ exports.services = {
10
+ logger: logger_js_1.logger,
11
+ artifacts: artifacts_js_1.artifactStorage,
12
+ keyValues: key_values_js_1.keyValueStorage,
13
+ labels: labels_js_1.labelStorage,
14
+ setContext: context => {
15
+ data_storage_js_1.dataStorage.setContext(context);
16
+ },
13
17
  };
@@ -0,0 +1,27 @@
1
+ export const keyValueStorage: KeyValueStorage;
2
+ declare class KeyValueStorage {
3
+ static "__#15@#instance": any;
4
+ /**
5
+ *
6
+ * @returns {KeyValueStorage}
7
+ */
8
+ static getInstance(): KeyValueStorage;
9
+ /**
10
+ * Stores key-value pair and passes it to reporter
11
+ * @param {{[key: string]: string}} keyValue - key-value pair(s) as object
12
+ * @param {*} context - full test title
13
+ */
14
+ put(keyValue: {
15
+ [key: string]: string;
16
+ }, context?: any): void;
17
+ /**
18
+ * Returns key-values pairs for the test as object
19
+ * @param {*} context testId or test context from test runner
20
+ * @returns {{[key: string]: string} | {}} key-values pairs as object, e.g. {priority: 'high', browser: 'chrome'}
21
+ */
22
+ get(context?: any): {
23
+ [key: string]: string;
24
+ } | {};
25
+ #private;
26
+ }
27
+ export {};
@@ -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]: 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();
@@ -0,0 +1,22 @@
1
+ export const labelStorage: LabelStorage;
2
+ declare class LabelStorage {
3
+ static "__#16@#instance": any;
4
+ /**
5
+ *
6
+ * @returns {LabelStorage}
7
+ */
8
+ static getInstance(): LabelStorage;
9
+ /**
10
+ * Stores labels array and passes it to reporter
11
+ * @param {string[]} labels - array of label strings
12
+ * @param {*} context - full test title
13
+ */
14
+ put(labels: string[], context?: any): void;
15
+ /**
16
+ * Returns labels array for the test
17
+ * @param {*} context testId or test context from test runner
18
+ * @returns {string[]} labels array, e.g. ['smoke', 'severity:high', 'feature:user_account']
19
+ */
20
+ get(context?: any): string[];
21
+ }
22
+ export {};
@@ -0,0 +1,62 @@
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.labelStorage = 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-labels');
10
+ class LabelStorage {
11
+ static #instance;
12
+ /**
13
+ *
14
+ * @returns {LabelStorage}
15
+ */
16
+ static getInstance() {
17
+ if (!this.#instance) {
18
+ this.#instance = new LabelStorage();
19
+ }
20
+ return this.#instance;
21
+ }
22
+ /**
23
+ * Stores labels array and passes it to reporter
24
+ * @param {string[]} labels - array of label strings
25
+ * @param {*} context - full test title
26
+ */
27
+ put(labels, context = null) {
28
+ if (!labels || !Array.isArray(labels))
29
+ return;
30
+ data_storage_js_1.dataStorage.putData('labels', labels, context);
31
+ }
32
+ /**
33
+ * Returns labels array for the test
34
+ * @param {*} context testId or test context from test runner
35
+ * @returns {string[]} labels array, e.g. ['smoke', 'severity:high', 'feature:user_account']
36
+ */
37
+ get(context = null) {
38
+ const labelsList = data_storage_js_1.dataStorage.getData('labels', context);
39
+ if (!labelsList || !labelsList?.length)
40
+ return [];
41
+ const allLabels = [];
42
+ for (const labels of labelsList) {
43
+ if (Array.isArray(labels)) {
44
+ allLabels.push(...labels);
45
+ }
46
+ else if (typeof labels === 'string') {
47
+ try {
48
+ const parsedLabels = JSON.parse(labels);
49
+ if (Array.isArray(parsedLabels)) {
50
+ allLabels.push(...parsedLabels);
51
+ }
52
+ }
53
+ catch (e) {
54
+ debug(`Error parsing labels for test ${context}`, labels);
55
+ }
56
+ }
57
+ }
58
+ // Remove duplicates
59
+ return [...new Set(allLabels)];
60
+ }
61
+ }
62
+ exports.labelStorage = LabelStorage.getInstance();
@@ -0,0 +1,64 @@
1
+ export const logger: Logger;
2
+ /**
3
+ * Logger allows to intercept logs from any logger (console.log, tracer, pino, etc)
4
+ * and save in the testomatio reporter.
5
+ * Supports different syntaxes to satisfy any user preferences.
6
+ */
7
+ declare class Logger {
8
+ static "__#13@#instance": any;
9
+ /**
10
+ *
11
+ * @returns {Logger}
12
+ */
13
+ static getInstance(): Logger;
14
+ logLevel: string;
15
+ /**
16
+ * Allows you to define a step inside a test. Step name is attached to the report and
17
+ * helps to understand the test flow.
18
+ * @param {*} strings
19
+ * @param {...any} values
20
+ */
21
+ step(strings: any, ...values: any[]): void;
22
+ /**
23
+ *
24
+ * @param {string} context testId or test context from test runner
25
+ * @returns {string[]}
26
+ */
27
+ getLogs(context: string): string[];
28
+ /**
29
+ * Tagget template literal. Allows to use different syntaxes:
30
+ * 1. Tagget template: log`text ${someVar}`
31
+ * 2. Standard: log(`text ${someVar}`)
32
+ * 3. Standard with multiple arguments: log('text', someVar)
33
+ */
34
+ _templateLiteralLog(strings: any, ...args: any[]): void;
35
+ assert(...args: any[]): void;
36
+ debug(...args: any[]): void;
37
+ error(...args: any[]): void;
38
+ info(...args: any[]): void;
39
+ log(...args: any[]): void;
40
+ trace(...args: any[]): void;
41
+ warn(...args: any[]): void;
42
+ /**
43
+ * Intercepts user logger messages.
44
+ * When call this method, Logger start to control the user logger
45
+ * @param {*} userLogger
46
+ */
47
+ intercept(userLogger: any): void;
48
+ stopInterception(): void;
49
+ /**
50
+ * Allows to configure logger. Make sure you do it before the logger usage in your code.
51
+ *
52
+ * @param {Object} [config={}] - The configuration object.
53
+ * @param {string} [config.logLevel] - The desired log level. Valid values are 'DEBUG', 'INFO', 'WARN', and 'ERROR'.
54
+ * @param {boolean} [config.prettyObjects] - Specifies whether to enable pretty printing of objects.
55
+ * @returns {void}
56
+ */
57
+ configure(config?: {
58
+ logLevel?: string;
59
+ prettyObjects?: boolean;
60
+ }): void;
61
+ prettyObjects: boolean;
62
+ #private;
63
+ }
64
+ export {};