@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
package/lib/pipe/csv.js CHANGED
@@ -1,12 +1,17 @@
1
- const debug = require('debug')('@testomatio/reporter:pipe:csv');
2
- const path = require('path');
3
- const fs = require('fs');
4
- const csvWriter = require('csv-writer');
5
- const chalk = require('chalk');
6
- const merge = require('lodash.merge');
7
- const { isSameTest, getCurrentDateTime, ansiRegExp } = require('../utils/utils');
8
- const { CSV_HEADERS } = require('../constants');
9
-
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
+ const debug_1 = __importDefault(require("debug"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const csv_writer_1 = require("csv-writer");
10
+ const picocolors_1 = __importDefault(require("picocolors"));
11
+ const lodash_merge_1 = __importDefault(require("lodash.merge"));
12
+ const utils_js_1 = require("../utils/utils.js");
13
+ const constants_js_1 = require("../constants.js");
14
+ const debug = (0, debug_1.default)('@testomatio/reporter:pipe:csv');
10
15
  /**
11
16
  * @typedef {import('../../types').Pipe} Pipe
12
17
  * @typedef {import('../../types').TestData} TestData
@@ -14,126 +19,108 @@ const { CSV_HEADERS } = require('../constants');
14
19
  * @implements {Pipe}
15
20
  */
16
21
  class CsvPipe {
17
- constructor(params, store) {
18
- this.store = store || {};
19
- this.title = params.title || process.env.TESTOMATIO_TITLE;
20
- this.results = [];
21
-
22
- this.outputDir = 'export';
23
- this.defaultReportName = 'report.csv';
24
- this.csvFilename = process.env.TESTOMATIO_CSV_FILENAME;
25
- this.isEnabled = false;
26
-
27
- if (this.csvFilename) {
28
- const filenameParts = this.csvFilename.split('.');
29
-
30
- if (filenameParts.length > 0) {
31
- this.isEnabled = true;
32
- const baseFilename = filenameParts[0];
33
- const defaultOutputFile = path.resolve(process.cwd(), this.outputDir, this.defaultReportName);
34
-
35
- const outputFile =
36
- baseFilename === this.defaultReportName.split('.')[0] // = 'report'
37
- ? defaultOutputFile
38
- : path.resolve(process.cwd(), this.outputDir, `${getCurrentDateTime()}_${baseFilename}.csv`);
39
-
40
- this.outputFile = outputFile;
41
- }
22
+ constructor(params, store) {
23
+ this.store = store || {};
24
+ this.title = params.title || process.env.TESTOMATIO_TITLE;
25
+ this.results = [];
26
+ this.outputDir = 'export';
27
+ this.defaultReportName = 'report.csv';
28
+ this.csvFilename = process.env.TESTOMATIO_CSV_FILENAME;
29
+ this.isEnabled = false;
30
+ if (this.csvFilename) {
31
+ const filenameParts = this.csvFilename.split('.');
32
+ if (filenameParts.length > 0) {
33
+ this.isEnabled = true;
34
+ const baseFilename = filenameParts[0];
35
+ const defaultOutputFile = path_1.default.resolve(process.cwd(), this.outputDir, this.defaultReportName);
36
+ const outputFile = baseFilename === this.defaultReportName.split('.')[0] // = 'report'
37
+ ? defaultOutputFile
38
+ : path_1.default.resolve(process.cwd(), this.outputDir, `${(0, utils_js_1.getCurrentDateTime)()}_${baseFilename}.csv`);
39
+ this.outputFile = outputFile;
40
+ }
41
+ }
42
42
  }
43
- }
44
-
45
- // TODO: to using SET opts as argument => prepareRun(opts)
46
- async prepareRun() {}
47
-
48
- async createRun() {
49
- // empty
50
- }
51
-
52
- updateRun() {}
53
-
54
- /**
55
- * Create a folder that will contain the exported files
56
- */
57
- checkExportDir() {
58
- if (!fs.existsSync(this.outputDir)) {
59
- return fs.mkdirSync(this.outputDir);
43
+ // TODO: to using SET opts as argument => prepareRun(opts)
44
+ async prepareRun() { }
45
+ async createRun() {
46
+ // empty
60
47
  }
61
- }
62
-
63
- /**
64
- * Save data to the csv file.
65
- * @param {Object} data - data that will be added to the CSV file.
66
- * Example: [{suite_title: "Suite #1", test: "Test-case-1", message: "Test msg"}]
67
- * @param {Object} headers - csv file headers. Example: [{ id: 'suite_title', title: 'Suite_title' }]
68
- */
69
- async saveToCsv(data, headers) {
70
- debug('Data', data);
71
- // First, we check whether the export directory exists: if yes - OK, no - create it.
72
- this.checkExportDir();
73
-
74
- if (!this.outputFile) {
75
- console.log(chalk.yellow(`⚠️ CSV file is not set, ignoring`));
76
- return;
48
+ updateRun() { }
49
+ /**
50
+ * Create a folder that will contain the exported files
51
+ */
52
+ checkExportDir() {
53
+ if (!fs_1.default.existsSync(this.outputDir)) {
54
+ return fs_1.default.mkdirSync(this.outputDir);
55
+ }
77
56
  }
78
-
79
- console.log(chalk.yellow(`⏳ The test results will be added to the csv. It will take some time...`));
80
-
81
- try {
82
- // Create csv writer object
83
- const writer = csvWriter.createObjectCsvWriter({
84
- path: this.outputFile,
85
- header: headers,
86
- });
87
- // Save csv file based on the current data
88
- return await writer.writeRecords(data);
89
- } catch (e) {
90
- console.log('Unknown csv error: ', e);
57
+ /**
58
+ * Save data to the csv file.
59
+ * @param {Object} data - data that will be added to the CSV file.
60
+ * Example: [{suite_title: "Suite #1", test: "Test-case-1", message: "Test msg"}]
61
+ * @param {Object} headers - csv file headers. Example: [{ id: 'suite_title', title: 'Suite_title' }]
62
+ */
63
+ async saveToCsv(data, headers) {
64
+ debug('Data', data);
65
+ // First, we check whether the export directory exists: if yes - OK, no - create it.
66
+ this.checkExportDir();
67
+ if (!this.outputFile) {
68
+ console.log(picocolors_1.default.yellow(`⚠️ CSV file is not set, ignoring`));
69
+ return;
70
+ }
71
+ console.log(picocolors_1.default.yellow(`⏳ The test results will be added to the csv. It will take some time...`));
72
+ try {
73
+ // Create csv writer object
74
+ const writer = (0, csv_writer_1.createObjectCsvWriter)({
75
+ path: this.outputFile,
76
+ header: headers,
77
+ });
78
+ // Save csv file based on the current data
79
+ return await writer.writeRecords(data);
80
+ }
81
+ catch (e) {
82
+ console.log('Unknown csv error: ', e);
83
+ }
91
84
  }
92
- }
93
-
94
- /**
95
- * Add test data to the result array for saving. As a result of this function, we get a result object to save.
96
- * @param {Object} test - object which includes each test entry.
97
- */
98
- addTest(test) {
99
- if (!this.isEnabled) return;
100
-
101
- const index = this.results.findIndex(t => isSameTest(t, test));
102
- // update if they were already added
103
- if (index >= 0) {
104
- this.results[index] = merge(this.results[index], test);
105
- return;
85
+ /**
86
+ * Add test data to the result array for saving. As a result of this function, we get a result object to save.
87
+ * @param {Object} test - object which includes each test entry.
88
+ */
89
+ addTest(test) {
90
+ if (!this.isEnabled)
91
+ return;
92
+ const index = this.results.findIndex(t => (0, utils_js_1.isSameTest)(t, test));
93
+ // update if they were already added
94
+ if (index >= 0) {
95
+ this.results[index] = (0, lodash_merge_1.default)(this.results[index], test);
96
+ return;
97
+ }
98
+ const { suite_title, title, status, message, stack } = test;
99
+ this.results.push({
100
+ suite_title,
101
+ title,
102
+ status,
103
+ message: message.replace((0, utils_js_1.ansiRegExp)(), ''),
104
+ stack: stack.replace((0, utils_js_1.ansiRegExp)(), ''),
105
+ });
106
106
  }
107
-
108
- const { suite_title, title, status, message, stack } = test;
109
-
110
- this.results.push({
111
- suite_title,
112
- title,
113
- status,
114
- message: message.replace(ansiRegExp(), ''),
115
- stack: stack.replace(ansiRegExp(), ''),
116
- });
117
- }
118
-
119
- /**
120
- * @param {{ tests?: TestData[] }} runParams
121
- * @returns {Promise<void>}
122
- */
123
- async finishRun(runParams) {
124
- if (!this.isEnabled) return;
125
-
126
- if (runParams.tests) runParams.tests.forEach(t => this.addTest(t));
127
- // Save results based on the default headers
128
- if (this.isEnabled) {
129
- await this.saveToCsv(this.results, CSV_HEADERS);
130
- console.log(chalk.green(`🗃️ Recording completed! You can check the result in file = ${this.outputFile}`));
107
+ /**
108
+ * @param {{ tests?: TestData[] }} runParams
109
+ * @returns {Promise<void>}
110
+ */
111
+ async finishRun(runParams) {
112
+ if (!this.isEnabled)
113
+ return;
114
+ if (runParams.tests)
115
+ runParams.tests.forEach(t => this.addTest(t));
116
+ // Save results based on the default headers
117
+ if (this.isEnabled) {
118
+ await this.saveToCsv(this.results, constants_js_1.CSV_HEADERS);
119
+ console.log(picocolors_1.default.green(`🗃️ Recording completed! You can check the result in file = ${this.outputFile}`));
120
+ }
121
+ }
122
+ toString() {
123
+ return 'csv exporter';
131
124
  }
132
- }
133
-
134
- toString() {
135
- return 'csv exporter';
136
- }
137
125
  }
138
-
139
126
  module.exports = CsvPipe;