@testomatio/reporter 1.6.13 → 2.0.1-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.
- package/lib/adapter/codecept.d.ts +2 -0
- package/lib/adapter/codecept.js +295 -335
- package/lib/adapter/cucumber/current.d.ts +14 -0
- package/lib/adapter/cucumber/current.js +195 -203
- package/lib/adapter/cucumber/legacy.d.ts +0 -0
- package/lib/adapter/cucumber/legacy.js +130 -155
- package/lib/adapter/cucumber.d.ts +2 -0
- package/lib/adapter/cucumber.js +5 -16
- package/lib/adapter/cypress-plugin/index.d.ts +2 -0
- package/lib/adapter/cypress-plugin/index.js +93 -105
- package/lib/adapter/jasmine.d.ts +11 -0
- package/lib/adapter/jasmine.js +54 -53
- package/lib/adapter/jest.d.ts +13 -0
- package/lib/adapter/jest.js +97 -99
- package/lib/adapter/mocha.d.ts +2 -0
- package/lib/adapter/mocha.js +112 -140
- package/lib/adapter/playwright.d.ts +14 -0
- package/lib/adapter/playwright.js +195 -231
- package/lib/adapter/vitest.d.ts +35 -0
- package/lib/adapter/vitest.js +150 -149
- package/lib/adapter/webdriver.d.ts +24 -0
- package/lib/adapter/webdriver.js +134 -119
- package/lib/bin/cli.d.ts +2 -0
- package/lib/bin/cli.js +164 -211
- package/lib/bin/reportXml.d.ts +2 -0
- package/lib/bin/reportXml.js +49 -52
- package/lib/bin/startTest.d.ts +2 -0
- package/lib/bin/startTest.js +82 -95
- package/lib/bin/uploadArtifacts.d.ts +2 -0
- package/lib/bin/uploadArtifacts.js +55 -61
- package/lib/client.d.ts +76 -0
- package/lib/client.js +411 -465
- package/lib/config.d.ts +1 -0
- package/lib/config.js +16 -21
- package/lib/constants.d.ts +25 -0
- package/lib/constants.js +50 -44
- package/lib/data-storage.d.ts +34 -0
- package/lib/data-storage.js +206 -188
- package/lib/junit-adapter/adapter.d.ts +9 -0
- package/lib/junit-adapter/adapter.js +17 -20
- package/lib/junit-adapter/csharp.d.ts +4 -0
- package/lib/junit-adapter/csharp.js +18 -14
- package/lib/junit-adapter/index.d.ts +3 -0
- package/lib/junit-adapter/index.js +27 -25
- package/lib/junit-adapter/java.d.ts +5 -0
- package/lib/junit-adapter/java.js +41 -53
- package/lib/junit-adapter/javascript.d.ts +4 -0
- package/lib/junit-adapter/javascript.js +30 -27
- package/lib/junit-adapter/python.d.ts +5 -0
- package/lib/junit-adapter/python.js +38 -37
- package/lib/junit-adapter/ruby.d.ts +4 -0
- package/lib/junit-adapter/ruby.js +11 -8
- package/lib/output.d.ts +11 -0
- package/lib/output.js +44 -52
- package/lib/package.json +3 -0
- package/lib/pipe/bitbucket.d.ts +23 -0
- package/lib/pipe/bitbucket.js +210 -229
- package/lib/pipe/csv.d.ts +47 -0
- package/lib/pipe/csv.js +113 -126
- package/lib/pipe/debug.d.ts +29 -0
- package/lib/pipe/debug.js +104 -99
- package/lib/pipe/github.d.ts +30 -0
- package/lib/pipe/github.js +186 -213
- package/lib/pipe/gitlab.d.ts +23 -0
- package/lib/pipe/gitlab.js +166 -207
- package/lib/pipe/html.d.ts +34 -0
- package/lib/pipe/html.js +260 -319
- package/lib/pipe/index.d.ts +1 -0
- package/lib/pipe/index.js +84 -66
- package/lib/pipe/testomatio.d.ts +70 -0
- package/lib/pipe/testomatio.js +413 -462
- package/lib/reporter-functions.d.ts +34 -0
- package/lib/reporter-functions.js +28 -26
- package/lib/reporter.d.ts +232 -0
- package/lib/reporter.js +34 -29
- package/lib/services/artifacts.d.ts +33 -0
- package/lib/services/artifacts.js +55 -51
- package/lib/services/index.d.ts +9 -0
- package/lib/services/index.js +14 -12
- package/lib/services/key-values.d.ts +27 -0
- package/lib/services/key-values.js +56 -53
- package/lib/services/logger.d.ts +64 -0
- package/lib/services/logger.js +227 -245
- package/lib/template/testomatio.hbs +651 -1366
- package/lib/uploader.d.ts +60 -0
- package/lib/uploader.js +291 -360
- package/lib/utils/pipe_utils.d.ts +41 -0
- package/lib/utils/pipe_utils.js +89 -85
- package/lib/utils/utils.d.ts +45 -0
- package/lib/utils/utils.js +347 -307
- package/lib/xmlReader.d.ts +92 -0
- package/lib/xmlReader.js +490 -529
- package/package.json +57 -15
- package/src/adapter/codecept.js +375 -0
- package/src/adapter/cucumber/current.js +228 -0
- package/src/adapter/cucumber/legacy.js +158 -0
- package/src/adapter/cucumber.js +4 -0
- package/src/adapter/cypress-plugin/index.js +112 -0
- package/src/adapter/jasmine.js +60 -0
- package/src/adapter/jest.js +107 -0
- package/src/adapter/mocha.cjs +2 -0
- package/src/adapter/mocha.js +157 -0
- package/src/adapter/playwright.js +250 -0
- package/src/adapter/vitest.js +183 -0
- package/src/adapter/webdriver.js +142 -0
- package/src/bin/cli.js +280 -0
- package/src/bin/reportXml.js +74 -0
- package/src/bin/startTest.js +123 -0
- package/src/bin/uploadArtifacts.js +90 -0
- package/src/client.js +504 -0
- package/src/config.js +30 -0
- package/src/constants.js +53 -0
- package/src/data-storage.js +204 -0
- package/src/junit-adapter/adapter.js +23 -0
- package/src/junit-adapter/csharp.js +16 -0
- package/src/junit-adapter/index.js +28 -0
- package/src/junit-adapter/java.js +58 -0
- package/src/junit-adapter/javascript.js +31 -0
- package/src/junit-adapter/python.js +42 -0
- package/src/junit-adapter/ruby.js +10 -0
- package/src/output.js +57 -0
- package/src/pipe/bitbucket.js +254 -0
- package/src/pipe/csv.js +140 -0
- package/src/pipe/debug.js +104 -0
- package/src/pipe/github.js +233 -0
- package/src/pipe/gitlab.js +229 -0
- package/src/pipe/html.js +374 -0
- package/src/pipe/index.js +71 -0
- package/src/pipe/testomatio.js +503 -0
- package/src/reporter-functions.js +55 -0
- package/src/reporter.cjs_decprecated +21 -0
- package/src/reporter.js +33 -0
- package/src/services/artifacts.js +59 -0
- package/src/services/index.js +13 -0
- package/src/services/key-values.js +59 -0
- package/src/services/logger.js +316 -0
- package/src/template/emptyData.svg +23 -0
- package/src/template/testomatio.hbs +706 -0
- package/src/uploader.js +371 -0
- package/src/utils/pipe_utils.js +119 -0
- package/src/utils/utils.js +383 -0
- package/src/xmlReader.js +562 -0
package/lib/pipe/csv.js
CHANGED
|
@@ -1,139 +1,126 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
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
|
-
* @typedef {import('../../types').Pipe} Pipe
|
|
12
|
-
* @typedef {import('../../types').TestData} TestData
|
|
16
|
+
* @typedef {import('../../types/types.js').Pipe} Pipe
|
|
17
|
+
* @typedef {import('../../types/types.js').TestData} TestData
|
|
13
18
|
* @class CsvPipe
|
|
14
19
|
* @implements {Pipe}
|
|
15
20
|
*/
|
|
16
21
|
class CsvPipe {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
46
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class DebugPipe {
|
|
2
|
+
constructor(params: any, store: any);
|
|
3
|
+
params: any;
|
|
4
|
+
store: any;
|
|
5
|
+
isEnabled: boolean;
|
|
6
|
+
batch: {
|
|
7
|
+
isEnabled: any;
|
|
8
|
+
intervalFunction: any;
|
|
9
|
+
intervalTime: number;
|
|
10
|
+
tests: any[];
|
|
11
|
+
batchIndex: number;
|
|
12
|
+
};
|
|
13
|
+
logFilePath: string;
|
|
14
|
+
testomatioEnvVars: {};
|
|
15
|
+
batchUpload(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Logs data to a file if logging is enabled.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} logData - The data to be logged.
|
|
20
|
+
* @returns {Promise<void>} A promise that resolves when the log data has been appended to the file.
|
|
21
|
+
*/
|
|
22
|
+
logToFile(logData: any): Promise<void>;
|
|
23
|
+
lastActionTimestamp: number;
|
|
24
|
+
prepareRun(opts: any): Promise<any[]>;
|
|
25
|
+
createRun(params?: {}): Promise<{}>;
|
|
26
|
+
addTest(data: any): Promise<void>;
|
|
27
|
+
finishRun(params: any): Promise<void>;
|
|
28
|
+
toString(): string;
|
|
29
|
+
}
|
package/lib/pipe/debug.js
CHANGED
|
@@ -1,103 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
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.DebugPipe = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
11
|
+
const constants_js_1 = require("../constants.js");
|
|
12
|
+
const pretty_ms_1 = __importDefault(require("pretty-ms"));
|
|
13
|
+
const debug = (0, debug_1.default)('@testomatio/reporter:pipe:debug');
|
|
9
14
|
class DebugPipe {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
constructor(params, store) {
|
|
16
|
+
this.params = params || {};
|
|
17
|
+
this.store = store || {};
|
|
18
|
+
this.isEnabled = !!process.env.TESTOMATIO_DEBUG || !!process.env.DEBUG;
|
|
19
|
+
if (this.isEnabled) {
|
|
20
|
+
this.batch = {
|
|
21
|
+
isEnabled: this.params.isBatchEnabled ?? !process.env.TESTOMATIO_DISABLE_BATCH_UPLOAD ?? true,
|
|
22
|
+
intervalFunction: null,
|
|
23
|
+
intervalTime: 5000,
|
|
24
|
+
tests: [],
|
|
25
|
+
batchIndex: 0,
|
|
26
|
+
};
|
|
27
|
+
this.logFilePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.debug.${Date.now()}.json`);
|
|
28
|
+
debug('Creating debug file:', this.logFilePath);
|
|
29
|
+
fs_1.default.writeFileSync(this.logFilePath, '');
|
|
30
|
+
console.log(constants_js_1.APP_PREFIX, '🪲. Debug created:');
|
|
31
|
+
this.testomatioEnvVars = Object.keys(process.env)
|
|
32
|
+
.filter(key => key.startsWith('TESTOMATIO_'))
|
|
33
|
+
.reduce((acc, key) => {
|
|
34
|
+
acc[key] = process.env[key];
|
|
35
|
+
return acc;
|
|
36
|
+
}, {});
|
|
37
|
+
this.logToFile({ datetime: new Date().toISOString(), timestamp: Date.now() });
|
|
38
|
+
this.logToFile({ data: 'variables', testomatioEnvVars: this.testomatioEnvVars });
|
|
39
|
+
this.logToFile({ data: 'store', store: this.store || {} });
|
|
40
|
+
// Bind batchUpload to the instance
|
|
41
|
+
this.batchUpload = this.batchUpload.bind(this);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Logs data to a file if logging is enabled.
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} logData - The data to be logged.
|
|
48
|
+
* @returns {Promise<void>} A promise that resolves when the log data has been appended to the file.
|
|
49
|
+
*/
|
|
50
|
+
logToFile(logData) {
|
|
51
|
+
if (!this.isEnabled)
|
|
52
|
+
return;
|
|
53
|
+
const timePassedFromLastAction = Date.now() - (this.lastActionTimestamp || Date.now());
|
|
54
|
+
this.lastActionTimestamp = Date.now();
|
|
55
|
+
const logLine = JSON.stringify({ t: `+${(0, pretty_ms_1.default)(timePassedFromLastAction)}`, ...logData });
|
|
56
|
+
fs_1.default.appendFileSync(this.logFilePath, `${logLine}\n`);
|
|
57
|
+
}
|
|
58
|
+
async prepareRun(opts) {
|
|
59
|
+
if (!this.isEnabled)
|
|
60
|
+
return [];
|
|
61
|
+
this.logToFile({ action: 'prepareRun', data: opts });
|
|
62
|
+
}
|
|
63
|
+
async createRun(params = {}) {
|
|
64
|
+
if (!this.isEnabled)
|
|
65
|
+
return;
|
|
66
|
+
if (params.isBatchEnabled === true || params.isBatchEnabled === false)
|
|
67
|
+
this.batch.isEnabled = params.isBatchEnabled;
|
|
68
|
+
if (!this.isEnabled)
|
|
69
|
+
return {};
|
|
70
|
+
if (this.batch.isEnabled)
|
|
71
|
+
this.batch.intervalFunction = setInterval(this.batchUpload, this.batch.intervalTime);
|
|
72
|
+
this.logToFile({ action: 'createRun', params });
|
|
73
|
+
}
|
|
74
|
+
async addTest(data) {
|
|
75
|
+
if (!this.isEnabled)
|
|
76
|
+
return;
|
|
77
|
+
if (!this.batch.isEnabled)
|
|
78
|
+
this.logToFile({ action: 'addTest', testId: data });
|
|
79
|
+
else
|
|
80
|
+
this.batch.tests.push(data);
|
|
81
|
+
if (!this.batch.intervalFunction)
|
|
82
|
+
await this.batchUpload();
|
|
83
|
+
}
|
|
84
|
+
async batchUpload() {
|
|
85
|
+
this.batch.batchIndex++;
|
|
86
|
+
if (!this.batch.isEnabled)
|
|
87
|
+
return;
|
|
88
|
+
if (!this.batch.tests.length)
|
|
89
|
+
return;
|
|
90
|
+
const testsToSend = this.batch.tests.splice(0);
|
|
91
|
+
this.logToFile({ action: 'addTestsBatch', tests: testsToSend });
|
|
92
|
+
}
|
|
93
|
+
async finishRun(params) {
|
|
94
|
+
if (!this.isEnabled)
|
|
95
|
+
return;
|
|
96
|
+
this.logToFile({ actions: 'finishRun', params });
|
|
97
|
+
await this.batchUpload();
|
|
98
|
+
if (this.batch.intervalFunction)
|
|
99
|
+
clearInterval(this.batch.intervalFunction);
|
|
100
|
+
console.log(constants_js_1.APP_PREFIX, '🪲. Debug Saved to', this.logFilePath);
|
|
101
|
+
}
|
|
102
|
+
toString() {
|
|
103
|
+
return 'Debug Reporter';
|
|
37
104
|
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Logs data to a file if logging is enabled.
|
|
42
|
-
*
|
|
43
|
-
* @param {Object} logData - The data to be logged.
|
|
44
|
-
* @returns {Promise<void>} A promise that resolves when the log data has been appended to the file.
|
|
45
|
-
*/
|
|
46
|
-
logToFile(logData) {
|
|
47
|
-
if (!this.isEnabled) return;
|
|
48
|
-
const timePassedFromLastAction = Date.now() - (this.lastActionTimestamp || Date.now());
|
|
49
|
-
this.lastActionTimestamp = Date.now();
|
|
50
|
-
|
|
51
|
-
const logLine = JSON.stringify({ t: `+${prettyMs(timePassedFromLastAction)}`, ...logData });
|
|
52
|
-
fs.appendFileSync(this.logFilePath, `${logLine}\n`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async prepareRun(opts) {
|
|
56
|
-
if (!this.isEnabled) return [];
|
|
57
|
-
|
|
58
|
-
this.logToFile({ action: 'prepareRun', data: opts });
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async createRun(params = {}) {
|
|
62
|
-
if (!this.isEnabled) return;
|
|
63
|
-
if (params.isBatchEnabled === true || params.isBatchEnabled === false) this.batch.isEnabled = params.isBatchEnabled;
|
|
64
|
-
|
|
65
|
-
if (!this.isEnabled) return {};
|
|
66
|
-
if (this.batch.isEnabled) this.batch.intervalFunction = setInterval(this.batchUpload, this.batch.intervalTime);
|
|
67
|
-
|
|
68
|
-
this.logToFile({ action: 'createRun', params });
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async addTest(data) {
|
|
72
|
-
if (!this.isEnabled) return;
|
|
73
|
-
|
|
74
|
-
if (!this.batch.isEnabled) this.logToFile({ action: 'addTest', testId: data });
|
|
75
|
-
else this.batch.tests.push(data);
|
|
76
|
-
|
|
77
|
-
if (!this.batch.intervalFunction) await this.batchUpload();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async batchUpload() {
|
|
81
|
-
this.batch.batchIndex++;
|
|
82
|
-
if (!this.batch.isEnabled) return;
|
|
83
|
-
if (!this.batch.tests.length) return;
|
|
84
|
-
|
|
85
|
-
const testsToSend = this.batch.tests.splice(0);
|
|
86
|
-
|
|
87
|
-
this.logToFile({ action: 'addTestsBatch', tests: testsToSend });
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async finishRun(params) {
|
|
91
|
-
if (!this.isEnabled) return;
|
|
92
|
-
this.logToFile({ actions: 'finishRun', params });
|
|
93
|
-
await this.batchUpload();
|
|
94
|
-
if (this.batch.intervalFunction) clearInterval(this.batch.intervalFunction);
|
|
95
|
-
console.log(APP_PREFIX, '🪲. Debug Saved to', this.logFilePath);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
toString() {
|
|
99
|
-
return 'Debug Reporter';
|
|
100
|
-
}
|
|
101
105
|
}
|
|
106
|
+
exports.DebugPipe = DebugPipe;
|
|
102
107
|
|
|
103
|
-
module.exports = DebugPipe;
|
|
108
|
+
module.exports.DebugPipe = DebugPipe;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default GitHubPipe;
|
|
2
|
+
export type Pipe = import("../../types/types.js").Pipe;
|
|
3
|
+
export type TestData = import("../../types/types.js").TestData;
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import('../../types/types.js').Pipe} Pipe
|
|
6
|
+
* @typedef {import('../../types/types.js').TestData} TestData
|
|
7
|
+
* @class GitHubPipe
|
|
8
|
+
* @implements {Pipe}
|
|
9
|
+
*/
|
|
10
|
+
declare class GitHubPipe implements Pipe {
|
|
11
|
+
constructor(params: any, store?: {});
|
|
12
|
+
isEnabled: boolean;
|
|
13
|
+
store: {};
|
|
14
|
+
tests: any[];
|
|
15
|
+
token: any;
|
|
16
|
+
ref: string;
|
|
17
|
+
repo: string;
|
|
18
|
+
jobKey: string;
|
|
19
|
+
hiddenCommentData: string;
|
|
20
|
+
issue: number;
|
|
21
|
+
start: Date;
|
|
22
|
+
prepareRun(): Promise<void>;
|
|
23
|
+
createRun(): Promise<void>;
|
|
24
|
+
addTest(test: any): void;
|
|
25
|
+
finishRun(runParams: any): Promise<void>;
|
|
26
|
+
octokit: import("@octokit/core").Octokit & {
|
|
27
|
+
paginate: import("@octokit/plugin-paginate-rest").PaginateInterface;
|
|
28
|
+
} & import("@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types.js").RestEndpointMethods & import("@octokit/plugin-rest-endpoint-methods/dist-types/types.js").Api;
|
|
29
|
+
toString(): string;
|
|
30
|
+
}
|