@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/bin/cli.js
CHANGED
|
@@ -1,275 +1,228 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const cross_spawn_1 = require("cross-spawn");
|
|
9
|
+
const glob_1 = __importDefault(require("glob"));
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
11
|
+
const client_js_1 = __importDefault(require("../client.js"));
|
|
12
|
+
const xmlReader_js_1 = __importDefault(require("../xmlReader.js"));
|
|
13
|
+
const constants_js_1 = require("../constants.js");
|
|
14
|
+
const package_json_1 = require("../../package.json");
|
|
15
|
+
const config_js_1 = require("../config.js");
|
|
16
|
+
const utils_js_1 = require("../utils/utils.js");
|
|
17
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
18
|
+
const filesize_1 = require("filesize");
|
|
19
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
20
|
+
const debug = (0, debug_1.default)('@testomatio/reporter:xml-cli');
|
|
21
|
+
console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io Reporter v${package_json_1.version}`)));
|
|
22
|
+
const program = new commander_1.Command();
|
|
17
23
|
program
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
.version(package_json_1.version)
|
|
25
|
+
.option('--env-file <envfile>', 'Load environment variables from env file')
|
|
26
|
+
.hook('preAction', thisCommand => {
|
|
21
27
|
const opts = thisCommand.opts();
|
|
22
28
|
if (opts.envFile) {
|
|
23
|
-
|
|
24
|
-
} else {
|
|
25
|
-
require('dotenv').config();
|
|
29
|
+
dotenv_1.default.config({ path: opts.envFile });
|
|
26
30
|
}
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
else {
|
|
32
|
+
dotenv_1.default.config();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
29
35
|
program
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
.command('start')
|
|
37
|
+
.description('Start a new run and return its ID')
|
|
38
|
+
.action(async () => {
|
|
33
39
|
console.log('Starting a new Run on Testomat.io...');
|
|
34
|
-
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config.TESTOMATIO;
|
|
35
|
-
const client = new
|
|
36
|
-
|
|
40
|
+
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
|
|
41
|
+
const client = new client_js_1.default({ apiKey });
|
|
37
42
|
client.createRun().then(() => {
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
console.log(process.env.runId);
|
|
44
|
+
process.exit(0);
|
|
40
45
|
});
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
});
|
|
43
47
|
program
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
process.env.TESTOMATIO_RUN ||= readLatestRunId();
|
|
48
|
-
|
|
48
|
+
.command('finish')
|
|
49
|
+
.description('Finish Run by its ID')
|
|
50
|
+
.action(async () => {
|
|
51
|
+
process.env.TESTOMATIO_RUN ||= (0, utils_js_1.readLatestRunId)();
|
|
49
52
|
if (!process.env.TESTOMATIO_RUN) {
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
|
|
54
|
+
return process.exit(1);
|
|
52
55
|
}
|
|
53
|
-
|
|
54
56
|
console.log('Finishing Run on Testomat.io...');
|
|
55
|
-
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config.TESTOMATIO;
|
|
56
|
-
const client = new
|
|
57
|
-
|
|
58
|
-
client.updateRunStatus(STATUS.FINISHED).then(() => {
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
|
|
58
|
+
const client = new client_js_1.default({ apiKey });
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
client.updateRunStatus(constants_js_1.STATUS.FINISHED).then(() => {
|
|
61
|
+
console.log(picocolors_1.default.yellow(`Run ${process.env.TESTOMATIO_RUN} was finished`));
|
|
62
|
+
process.exit(0);
|
|
61
63
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
});
|
|
64
65
|
program
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config.TESTOMATIO;
|
|
66
|
+
.command('run')
|
|
67
|
+
.description('Run tests with the specified command')
|
|
68
|
+
.argument('<command>', 'Test runner command')
|
|
69
|
+
.option('--filter <filter>', 'Additional execution filter')
|
|
70
|
+
.action(async (command, opts) => {
|
|
71
|
+
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
|
|
71
72
|
const title = process.env.TESTOMATIO_TITLE;
|
|
72
|
-
|
|
73
73
|
if (!command || !command.split) {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
console.log(constants_js_1.APP_PREFIX, `No command provided. Use -c option to launch a test runner.`);
|
|
75
|
+
return process.exit(255);
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
const client = new TestomatClient({ apiKey, title, parallel: true });
|
|
79
|
-
|
|
77
|
+
const client = new client_js_1.default({ apiKey, title, parallel: true });
|
|
80
78
|
if (opts.filter) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
const [pipe, ...optsArray] = opts.filter.split(':');
|
|
80
|
+
const pipeOptions = optsArray.join(':');
|
|
81
|
+
try {
|
|
82
|
+
const tests = await client.prepareRun({ pipe, pipeOptions });
|
|
83
|
+
if (tests && tests.length > 0) {
|
|
84
|
+
command += ` --grep (${tests.join('|')})`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
console.log(constants_js_1.APP_PREFIX, err);
|
|
88
89
|
}
|
|
89
|
-
} catch (err) {
|
|
90
|
-
console.log(APP_PREFIX, err);
|
|
91
|
-
}
|
|
92
90
|
}
|
|
93
|
-
|
|
94
|
-
console.log(APP_PREFIX, `🚀 Running`, chalk.green(command));
|
|
95
|
-
|
|
91
|
+
console.log(constants_js_1.APP_PREFIX, `🚀 Running`, picocolors_1.default.green(command));
|
|
96
92
|
const runTests = () => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
93
|
+
const testCmds = command.split(' ');
|
|
94
|
+
const cmd = (0, cross_spawn_1.spawn)(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
|
|
95
|
+
cmd.on('close', code => {
|
|
96
|
+
const emoji = code === 0 ? '🟢' : '🔴';
|
|
97
|
+
console.log(constants_js_1.APP_PREFIX, emoji, `Runner exited with ${picocolors_1.default.bold(code)}`);
|
|
98
|
+
if (apiKey) {
|
|
99
|
+
const status = code === 0 ? 'passed' : 'failed';
|
|
100
|
+
client.updateRunStatus(status, true);
|
|
101
|
+
}
|
|
102
|
+
process.exit(code);
|
|
103
|
+
});
|
|
109
104
|
};
|
|
110
|
-
|
|
111
105
|
if (apiKey) {
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
106
|
+
client.createRun().then(runTests);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
runTests();
|
|
115
110
|
}
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
});
|
|
118
112
|
program
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
.command('xml')
|
|
114
|
+
.description('Parse XML reports and upload to Testomat.io')
|
|
115
|
+
.argument('<pattern>', 'XML file pattern')
|
|
116
|
+
.option('-d, --dir <dir>', 'Project directory')
|
|
117
|
+
.option('--java-tests [java-path]', 'Load Java tests from path, by default: src/test/java')
|
|
118
|
+
.option('--lang <lang>', 'Language used (python, ruby, java)')
|
|
119
|
+
.option('--timelimit <time>', 'default time limit in seconds to kill a stuck process')
|
|
120
|
+
.action(async (pattern, opts) => {
|
|
127
121
|
if (!pattern.endsWith('.xml')) {
|
|
128
|
-
|
|
122
|
+
pattern += '.xml';
|
|
129
123
|
}
|
|
130
124
|
let { javaTests, lang } = opts;
|
|
131
|
-
if (javaTests === true)
|
|
125
|
+
if (javaTests === true)
|
|
126
|
+
javaTests = 'src/test/java';
|
|
132
127
|
lang = lang?.toLowerCase();
|
|
133
|
-
const runReader = new
|
|
134
|
-
const files =
|
|
128
|
+
const runReader = new xmlReader_js_1.default({ javaTests, lang });
|
|
129
|
+
const files = glob_1.default.sync(pattern, { cwd: opts.dir || process.cwd() });
|
|
135
130
|
if (!files.length) {
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
console.log(constants_js_1.APP_PREFIX, `Report can't be created. No XML files found 😥`);
|
|
132
|
+
process.exit(1);
|
|
138
133
|
}
|
|
139
|
-
|
|
140
134
|
for (const file of files) {
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
console.log(constants_js_1.APP_PREFIX, `Parsed ${file}`);
|
|
136
|
+
runReader.parse(file);
|
|
143
137
|
}
|
|
144
|
-
|
|
145
138
|
let timeoutTimer;
|
|
146
139
|
if (opts.timelimit) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
);
|
|
152
|
-
process.exit(0);
|
|
153
|
-
},
|
|
154
|
-
parseInt(opts.timelimit, 10) * 1000,
|
|
155
|
-
);
|
|
140
|
+
timeoutTimer = setTimeout(() => {
|
|
141
|
+
console.log(`⚠️ Reached timeout of ${opts.timelimit}s. Exiting... (Exit code is 0 to not fail the pipeline)`);
|
|
142
|
+
process.exit(0);
|
|
143
|
+
}, parseInt(opts.timelimit, 10) * 1000);
|
|
156
144
|
}
|
|
157
|
-
|
|
158
145
|
try {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
} catch (err) {
|
|
162
|
-
console.log(APP_PREFIX, 'Error updating status, skipping...', err);
|
|
146
|
+
await runReader.createRun();
|
|
147
|
+
await runReader.uploadData();
|
|
163
148
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
149
|
+
catch (err) {
|
|
150
|
+
console.log(constants_js_1.APP_PREFIX, 'Error updating status, skipping...', err);
|
|
151
|
+
}
|
|
152
|
+
if (timeoutTimer)
|
|
153
|
+
clearTimeout(timeoutTimer);
|
|
154
|
+
});
|
|
168
155
|
program
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const apiKey = config.TESTOMATIO;
|
|
174
|
-
|
|
156
|
+
.command('upload-artifacts')
|
|
157
|
+
.description('Upload artifacts to Testomat.io')
|
|
158
|
+
.option('--force', 'Re-upload artifacts even if they were uploaded before')
|
|
159
|
+
.action(async (opts) => {
|
|
160
|
+
const apiKey = config_js_1.config.TESTOMATIO;
|
|
175
161
|
process.env.TESTOMATIO_DISABLE_ARTIFACTS = '';
|
|
176
|
-
const runId = process.env.TESTOMATIO_RUN || process.env.runId || readLatestRunId();
|
|
177
|
-
|
|
162
|
+
const runId = process.env.TESTOMATIO_RUN || process.env.runId || (0, utils_js_1.readLatestRunId)();
|
|
178
163
|
if (!runId) {
|
|
179
|
-
|
|
180
|
-
|
|
164
|
+
console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
|
|
165
|
+
return process.exit(1);
|
|
181
166
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
isBatchEnabled: false,
|
|
167
|
+
const client = new client_js_1.default({
|
|
168
|
+
apiKey,
|
|
169
|
+
runId,
|
|
170
|
+
isBatchEnabled: false,
|
|
187
171
|
});
|
|
188
|
-
|
|
189
172
|
let testruns = client.uploader.readUploadedFiles(runId);
|
|
190
173
|
const numTotalArtifacts = testruns.length;
|
|
191
|
-
|
|
192
174
|
debug('Found testruns:', testruns);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
175
|
+
if (!opts.force)
|
|
176
|
+
testruns = testruns.filter(tr => !tr.uploaded);
|
|
196
177
|
if (!testruns.length) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
178
|
+
console.log(constants_js_1.APP_PREFIX, '🗄️ Total artifacts:', numTotalArtifacts);
|
|
179
|
+
if (numTotalArtifacts) {
|
|
180
|
+
console.log(constants_js_1.APP_PREFIX, 'No new artifacts to upload');
|
|
181
|
+
console.log(constants_js_1.APP_PREFIX, 'To re-upload artifacts run this command with --force flag');
|
|
182
|
+
}
|
|
183
|
+
process.exit(0);
|
|
203
184
|
}
|
|
204
|
-
|
|
205
185
|
const testrunsByRid = testruns.reduce((acc, { rid, file }) => {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
186
|
+
if (!acc[rid]) {
|
|
187
|
+
acc[rid] = [];
|
|
188
|
+
}
|
|
189
|
+
if (!acc[rid].includes(file))
|
|
190
|
+
acc[rid].push(file);
|
|
191
|
+
return acc;
|
|
211
192
|
}, {});
|
|
212
|
-
|
|
213
193
|
await client.createRun();
|
|
214
194
|
client.uploader.checkEnabled();
|
|
215
195
|
client.uploader.disableLogStorage();
|
|
216
|
-
|
|
217
196
|
for (const rid in testrunsByRid) {
|
|
218
|
-
|
|
219
|
-
|
|
197
|
+
const files = testrunsByRid[rid];
|
|
198
|
+
await client.addTestRun(undefined, { rid, files });
|
|
220
199
|
}
|
|
221
|
-
|
|
222
|
-
console.log(APP_PREFIX, '🗄️', client.uploader.successfulUploads.length, 'artifacts 🟢uploaded');
|
|
223
|
-
|
|
200
|
+
console.log(constants_js_1.APP_PREFIX, '🗄️', client.uploader.successfulUploads.length, 'artifacts 🟢uploaded');
|
|
224
201
|
if (client.uploader.successfulUploads.length) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
`🟢 Uploaded artifact`,
|
|
235
|
-
`${upload.relativePath},`,
|
|
236
|
-
'size:',
|
|
237
|
-
`${upload.sizePretty},`,
|
|
238
|
-
'link:',
|
|
239
|
-
`${upload.link}`,
|
|
240
|
-
);
|
|
241
|
-
});
|
|
202
|
+
debug('\n', constants_js_1.APP_PREFIX, `🗄️ ${client.uploader.successfulUploads.length} artifacts uploaded to S3 bucket`);
|
|
203
|
+
const uploadedArtifacts = client.uploader.successfulUploads.map(file => ({
|
|
204
|
+
relativePath: file.path.replace(process.cwd(), ''),
|
|
205
|
+
link: file.link,
|
|
206
|
+
sizePretty: (0, filesize_1.filesize)(file.size, { round: 0 }).toString(),
|
|
207
|
+
}));
|
|
208
|
+
uploadedArtifacts.forEach(upload => {
|
|
209
|
+
debug(`🟢Uploaded artifact`, `${upload.relativePath},`, 'size:', `${upload.sizePretty},`, 'link:', `${upload.link}`);
|
|
210
|
+
});
|
|
242
211
|
}
|
|
243
|
-
|
|
244
212
|
const filesizeStrMaxLength = 7;
|
|
245
|
-
|
|
246
213
|
if (client.uploader.failedUploads.length) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
relativePath: path.replace(process.cwd(), ''),
|
|
257
|
-
sizePretty: prettyBytes(size, { round: 0 }).toString(),
|
|
258
|
-
}));
|
|
259
|
-
|
|
260
|
-
const pathPadding = Math.max(...failedUploads.map(upload => upload.relativePath.length)) + 1;
|
|
261
|
-
failedUploads.forEach(upload => {
|
|
262
|
-
console.log(
|
|
263
|
-
` ${chalk.gray('|')} 🔴 ${upload.relativePath.padEnd(pathPadding)} ${chalk.gray(
|
|
264
|
-
`| ${upload.sizePretty.padStart(filesizeStrMaxLength)} |`,
|
|
265
|
-
)}`,
|
|
266
|
-
);
|
|
267
|
-
});
|
|
214
|
+
console.log('\n', constants_js_1.APP_PREFIX, '🗄️', client.uploader.failedUploads.length, `artifacts 🔴${picocolors_1.default.bold('failed')} to upload`);
|
|
215
|
+
const failedUploads = client.uploader.failedUploads.map(({ path, size }) => ({
|
|
216
|
+
relativePath: path.replace(process.cwd(), ''),
|
|
217
|
+
sizePretty: (0, filesize_1.filesize)(size, { round: 0 }).toString(),
|
|
218
|
+
}));
|
|
219
|
+
const pathPadding = Math.max(...failedUploads.map(upload => upload.relativePath.length)) + 1;
|
|
220
|
+
failedUploads.forEach(upload => {
|
|
221
|
+
console.log(` ${picocolors_1.default.gray('|')} 🔴 ${upload.relativePath.padEnd(pathPadding)} ${picocolors_1.default.gray(`| ${upload.sizePretty.padStart(filesizeStrMaxLength)} |`)}`);
|
|
222
|
+
});
|
|
268
223
|
}
|
|
269
|
-
|
|
270
|
-
|
|
224
|
+
});
|
|
271
225
|
program.parse(process.argv);
|
|
272
|
-
|
|
273
226
|
if (!process.argv.slice(2).length) {
|
|
274
|
-
|
|
227
|
+
program.outputHelp();
|
|
275
228
|
}
|
package/lib/bin/reportXml.js
CHANGED
|
@@ -1,72 +1,69 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
9
|
+
const glob_1 = require("glob");
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
11
|
+
const constants_js_1 = require("../constants.js");
|
|
12
|
+
const xmlReader_js_1 = __importDefault(require("../xmlReader.js"));
|
|
13
|
+
const package_json_1 = require("../../package.json");
|
|
14
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
15
|
+
const debug = (0, debug_1.default)('@testomatio/reporter:xml-cli');
|
|
16
|
+
console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io XML Reporter v${package_json_1.version}`)));
|
|
17
|
+
const program = new commander_1.Command();
|
|
13
18
|
program
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
.arguments('<pattern>')
|
|
20
|
+
.option('-d, --dir <dir>', 'Project directory')
|
|
21
|
+
.option('--java-tests [java-path]', 'Load Java tests from path, by default: src/test/java')
|
|
22
|
+
.option('--lang <lang>', 'Language used (python, ruby, java)')
|
|
23
|
+
.option('--timelimit <time>', 'default time limit in seconds to kill a stuck process')
|
|
24
|
+
.option('--env-file <envfile>', 'Load environment variables from env file')
|
|
25
|
+
.action(async (pattern, opts) => {
|
|
21
26
|
if (!pattern.endsWith('.xml')) {
|
|
22
|
-
|
|
27
|
+
pattern += '.xml';
|
|
23
28
|
}
|
|
24
29
|
let { javaTests, lang } = opts;
|
|
25
30
|
if (opts.envFile) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
console.log(constants_js_1.APP_PREFIX, 'Loading env file:', opts.envFile);
|
|
32
|
+
debug('Loading env file: %s', opts.envFile);
|
|
33
|
+
dotenv_1.default.config({ path: opts.envFile });
|
|
29
34
|
}
|
|
30
|
-
if (javaTests === true) javaTests = 'src/test/java';
|
|
31
35
|
lang = lang?.toLowerCase();
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
if (javaTests === true || (lang === 'java' && !javaTests))
|
|
37
|
+
javaTests = 'src/test/java';
|
|
38
|
+
const runReader = new xmlReader_js_1.default({ javaTests, lang });
|
|
39
|
+
const files = glob_1.glob.sync(pattern, { cwd: opts.dir || process.cwd() });
|
|
34
40
|
if (!files.length) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
console.log(constants_js_1.APP_PREFIX, `Report can't be created. No XML files found 😥`);
|
|
42
|
+
process.exitCode = 1;
|
|
43
|
+
return;
|
|
38
44
|
}
|
|
39
|
-
|
|
40
45
|
for (const file of files) {
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
console.log(constants_js_1.APP_PREFIX, `Parsed ${file}`);
|
|
47
|
+
runReader.parse(file);
|
|
43
48
|
}
|
|
44
|
-
|
|
45
49
|
let timeoutTimer;
|
|
46
50
|
if (opts.timelimit) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
process.exit(0);
|
|
53
|
-
},
|
|
54
|
-
parseInt(opts.timelimit, 10) * 1000,
|
|
55
|
-
);
|
|
51
|
+
timeoutTimer = setTimeout(() => {
|
|
52
|
+
console.log(`⚠️ Reached timeout of ${opts.timelimit}s. Exiting... (Exit code is 0 to not fail the pipeline)`);
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}, parseInt(opts.timelimit, 10) * 1000);
|
|
56
55
|
}
|
|
57
|
-
|
|
58
56
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
} catch (err) {
|
|
62
|
-
console.log(APP_PREFIX, 'Error updating status, skipping...', err);
|
|
57
|
+
await runReader.createRun();
|
|
58
|
+
await runReader.uploadData();
|
|
63
59
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
catch (err) {
|
|
61
|
+
console.log(constants_js_1.APP_PREFIX, 'Error updating status, skipping...', err);
|
|
62
|
+
}
|
|
63
|
+
if (timeoutTimer)
|
|
64
|
+
clearTimeout(timeoutTimer);
|
|
65
|
+
});
|
|
68
66
|
if (process.argv.length < 3) {
|
|
69
|
-
|
|
67
|
+
program.outputHelp();
|
|
70
68
|
}
|
|
71
|
-
|
|
72
69
|
program.parse(process.argv);
|