@testomatio/reporter 2.1.0-beta.2-codeceptjs → 2.1.0-beta.3-filter-plan
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/webdriver.js +9 -3
- package/lib/bin/cli.js +7 -5
- package/lib/bin/reportXml.js +0 -0
- package/lib/bin/startTest.js +0 -0
- package/lib/bin/uploadArtifacts.js +0 -0
- package/lib/client.d.ts +1 -1
- package/lib/client.js +6 -2
- package/lib/pipe/testomatio.js +7 -3
- package/lib/utils/utils.d.ts +6 -1
- package/lib/utils/utils.js +23 -2
- package/package.json +1 -1
package/lib/adapter/webdriver.js
CHANGED
|
@@ -48,8 +48,9 @@ class WebdriverReporter extends reporter_1.default {
|
|
|
48
48
|
options = Object.assign(options, { stdout: true });
|
|
49
49
|
this._addTestPromises = [];
|
|
50
50
|
this._isSynchronising = false;
|
|
51
|
-
//
|
|
52
|
-
|
|
51
|
+
// run is created by cli, if enabling the row below, it mat lead to multiple runs being created
|
|
52
|
+
// thus, need to check if process.env.runId is set and/or add more checks to avoid creating multiple runs
|
|
53
|
+
// this.client.createRun();
|
|
53
54
|
}
|
|
54
55
|
get isSynchronised() {
|
|
55
56
|
return this._isSynchronising === false;
|
|
@@ -68,7 +69,6 @@ class WebdriverReporter extends reporter_1.default {
|
|
|
68
69
|
}
|
|
69
70
|
onRunnerStart() {
|
|
70
71
|
// clear dir with artifacts/logs
|
|
71
|
-
//
|
|
72
72
|
utils_js_1.fileSystem.clearDir(constants_js_1.TESTOMAT_TMP_STORAGE_DIR);
|
|
73
73
|
}
|
|
74
74
|
onTestStart(test) {
|
|
@@ -153,3 +153,9 @@ function getTestLogs(fullTestTitle) {
|
|
|
153
153
|
return logs;
|
|
154
154
|
}
|
|
155
155
|
module.exports = WebdriverReporter;
|
|
156
|
+
/* INVESTIGATION RESULTS:
|
|
157
|
+
If you run tests in parallel, the WDIO creates a separate process for each parallel instance.
|
|
158
|
+
As a result, there is own WDIOReporter instance for each parallel process.
|
|
159
|
+
This means, its impossible to create or finish run, because can't understand if its was already created
|
|
160
|
+
in other process or not.
|
|
161
|
+
*/
|
package/lib/bin/cli.js
CHANGED
|
@@ -38,6 +38,7 @@ program
|
|
|
38
38
|
.command('start')
|
|
39
39
|
.description('Start a new run and return its ID')
|
|
40
40
|
.action(async () => {
|
|
41
|
+
(0, utils_js_1.cleanLatestRunId)();
|
|
41
42
|
console.log('Starting a new Run on Testomat.io...');
|
|
42
43
|
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
|
|
43
44
|
const client = new client_js_1.default({ apiKey });
|
|
@@ -66,6 +67,7 @@ program
|
|
|
66
67
|
});
|
|
67
68
|
program
|
|
68
69
|
.command('run')
|
|
70
|
+
.alias('test')
|
|
69
71
|
.description('Run tests with the specified command')
|
|
70
72
|
.argument('<command>', 'Test runner command')
|
|
71
73
|
.option('--filter <filter>', 'Additional execution filter')
|
|
@@ -91,24 +93,24 @@ program
|
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
console.log(constants_js_1.APP_PREFIX, `🚀 Running`, picocolors_1.default.green(command));
|
|
94
|
-
const runTests = () => {
|
|
96
|
+
const runTests = async () => {
|
|
95
97
|
const testCmds = command.split(' ');
|
|
96
98
|
const cmd = (0, cross_spawn_1.spawn)(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
|
|
97
|
-
cmd.on('close', code => {
|
|
99
|
+
cmd.on('close', async (code) => {
|
|
98
100
|
const emoji = code === 0 ? '🟢' : '🔴';
|
|
99
101
|
console.log(constants_js_1.APP_PREFIX, emoji, `Runner exited with ${picocolors_1.default.bold(code)}`);
|
|
100
102
|
if (apiKey) {
|
|
101
103
|
const status = code === 0 ? 'passed' : 'failed';
|
|
102
|
-
client.updateRunStatus(status, true);
|
|
104
|
+
await client.updateRunStatus(status, true);
|
|
103
105
|
}
|
|
104
106
|
process.exit(code);
|
|
105
107
|
});
|
|
106
108
|
};
|
|
107
109
|
if (apiKey) {
|
|
108
|
-
client.createRun().then(runTests);
|
|
110
|
+
await client.createRun().then(runTests);
|
|
109
111
|
}
|
|
110
112
|
else {
|
|
111
|
-
runTests();
|
|
113
|
+
await runTests();
|
|
112
114
|
}
|
|
113
115
|
});
|
|
114
116
|
// program
|
package/lib/bin/reportXml.js
CHANGED
|
File without changes
|
package/lib/bin/startTest.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/client.d.ts
CHANGED
package/lib/client.js
CHANGED
|
@@ -68,7 +68,7 @@ class Client {
|
|
|
68
68
|
constructor(params = {}) {
|
|
69
69
|
this.paramsForPipesFactory = params;
|
|
70
70
|
this.pipeStore = {};
|
|
71
|
-
this.runId =
|
|
71
|
+
this.runId = '';
|
|
72
72
|
this.queue = Promise.resolve();
|
|
73
73
|
// @ts-ignore this line will be removed in compiled code, because __dirname is defined in commonjs
|
|
74
74
|
const pathToPackageJSON = path_1.default.join(__dirname, '../package.json');
|
|
@@ -158,6 +158,8 @@ class Client {
|
|
|
158
158
|
* @returns {Promise<PipeResult[]>}
|
|
159
159
|
*/
|
|
160
160
|
async addTestRun(status, testData) {
|
|
161
|
+
if (!this.pipes || !this.pipes.length)
|
|
162
|
+
this.pipes = await (0, index_js_1.pipesFactory)(this.paramsForPipesFactory || {}, this.pipeStore);
|
|
161
163
|
// all pipes disabled, skipping
|
|
162
164
|
if (!this.pipes?.filter(p => p.isEnabled).length)
|
|
163
165
|
return [];
|
|
@@ -292,7 +294,9 @@ class Client {
|
|
|
292
294
|
* @param {boolean} [isParallel] - Whether the current test run was executed in parallel with other tests.
|
|
293
295
|
* @returns {Promise<any>} - A Promise that resolves when finishes the run.
|
|
294
296
|
*/
|
|
295
|
-
updateRunStatus(status, isParallel = false) {
|
|
297
|
+
async updateRunStatus(status, isParallel = false) {
|
|
298
|
+
this.pipes ||= await (0, index_js_1.pipesFactory)(this.paramsForPipesFactory || {}, this.pipeStore);
|
|
299
|
+
this.runId ||= (0, utils_js_1.readLatestRunId)();
|
|
296
300
|
debug('Updating run status...');
|
|
297
301
|
// all pipes disabled, skipping
|
|
298
302
|
if (!this.pipes?.filter(p => p.isEnabled).length)
|
package/lib/pipe/testomatio.js
CHANGED
|
@@ -113,7 +113,8 @@ class TestomatioPipe {
|
|
|
113
113
|
const resp = await this.client.request({
|
|
114
114
|
method: 'GET',
|
|
115
115
|
url: '/api/test_grep',
|
|
116
|
-
params: q
|
|
116
|
+
params: q.params,
|
|
117
|
+
responseType: q.responseType
|
|
117
118
|
});
|
|
118
119
|
if (Array.isArray(resp.data?.tests) && resp.data?.tests?.length > 0) {
|
|
119
120
|
(0, utils_js_1.foundedTestLog)(constants_js_1.APP_PREFIX, resp.data.tests);
|
|
@@ -331,11 +332,14 @@ class TestomatioPipe {
|
|
|
331
332
|
* Adds a test to the batch uploader (or reports a single test if batch uploading is disabled)
|
|
332
333
|
*/
|
|
333
334
|
addTest(data) {
|
|
334
|
-
this.isEnabled = this.apiKey ?? this.isEnabled;
|
|
335
|
+
this.isEnabled = !!(this.apiKey ?? this.isEnabled);
|
|
335
336
|
if (!this.isEnabled)
|
|
336
337
|
return;
|
|
337
|
-
|
|
338
|
+
this.runId = this.runId || process.env.runId || this.store.runId || (0, utils_js_1.readLatestRunId)();
|
|
339
|
+
if (!this.runId) {
|
|
340
|
+
console.warn(constants_js_1.APP_PREFIX, picocolors_1.default.red('Run ID is not set, skipping test reporting'));
|
|
338
341
|
return;
|
|
342
|
+
}
|
|
339
343
|
// add test ID + run ID
|
|
340
344
|
if (data.rid)
|
|
341
345
|
data.rid = `${this.runId}-${data.rid}`;
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export function getPackageVersion(): any;
|
|
|
2
2
|
export const TEST_ID_REGEX: RegExp;
|
|
3
3
|
export const SUITE_ID_REGEX: RegExp;
|
|
4
4
|
export function ansiRegExp(): RegExp;
|
|
5
|
+
export function cleanLatestRunId(): void;
|
|
5
6
|
export function isSameTest(test: any, t: any): boolean;
|
|
6
7
|
export function fetchSourceCode(contents: any, opts?: {}): string;
|
|
7
8
|
export function fetchSourceCodeFromStackTrace(stack?: string): string;
|
|
@@ -29,7 +30,11 @@ export function isValidUrl(s: any): boolean;
|
|
|
29
30
|
* @returns {String|null} suiteId
|
|
30
31
|
*/
|
|
31
32
|
export function parseSuite(suiteTitle: string): string | null;
|
|
32
|
-
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @returns {String|null} latest run ID
|
|
36
|
+
*/
|
|
37
|
+
export function readLatestRunId(): string | null;
|
|
33
38
|
/**
|
|
34
39
|
* Used to remove color codes
|
|
35
40
|
* @param {*} input
|
package/lib/utils/utils.js
CHANGED
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.validateSuiteId = exports.testRunnerHelper = exports.specificTestInfo = exports.parseSuite = exports.isValidUrl = exports.humanize = exports.getTestomatIdFromTestTitle = exports.getCurrentDateTime = exports.foundedTestLog = exports.fileSystem = exports.fetchFilesFromStackTrace = exports.fetchIdFromOutput = exports.fetchIdFromCode = exports.fetchSourceCodeFromStackTrace = exports.fetchSourceCode = exports.isSameTest = exports.ansiRegExp = exports.SUITE_ID_REGEX = exports.TEST_ID_REGEX = void 0;
|
|
40
40
|
exports.getPackageVersion = getPackageVersion;
|
|
41
|
+
exports.cleanLatestRunId = cleanLatestRunId;
|
|
41
42
|
exports.formatStep = formatStep;
|
|
42
43
|
exports.readLatestRunId = readLatestRunId;
|
|
43
44
|
exports.removeColorCodes = removeColorCodes;
|
|
@@ -391,6 +392,10 @@ function storeRunId(runId) {
|
|
|
391
392
|
const filePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.latest.run`);
|
|
392
393
|
fs_1.default.writeFileSync(filePath, runId);
|
|
393
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
*
|
|
397
|
+
* @returns {String|null} latest run ID
|
|
398
|
+
*/
|
|
394
399
|
function readLatestRunId() {
|
|
395
400
|
try {
|
|
396
401
|
const filePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.latest.run`);
|
|
@@ -398,13 +403,27 @@ function readLatestRunId() {
|
|
|
398
403
|
const diff = +new Date() - +stats.mtime;
|
|
399
404
|
const diffHours = diff / 1000 / 60 / 60;
|
|
400
405
|
if (diffHours > 1)
|
|
401
|
-
return;
|
|
402
|
-
return fs_1.default.readFileSync(filePath)?.toString()?.trim();
|
|
406
|
+
return null;
|
|
407
|
+
return fs_1.default.readFileSync(filePath)?.toString()?.trim() ?? null;
|
|
403
408
|
}
|
|
404
409
|
catch (e) {
|
|
410
|
+
console.warn('Could not read latest run ID from file: ', e);
|
|
405
411
|
return null;
|
|
406
412
|
}
|
|
407
413
|
}
|
|
414
|
+
function cleanLatestRunId() {
|
|
415
|
+
try {
|
|
416
|
+
const filePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.latest.run`);
|
|
417
|
+
const runId = readLatestRunId();
|
|
418
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
419
|
+
fs_1.default.unlinkSync(filePath);
|
|
420
|
+
}
|
|
421
|
+
debug(`Cleaned latest run ID (${runId}) file`, filePath);
|
|
422
|
+
}
|
|
423
|
+
catch (e) {
|
|
424
|
+
console.warn('Could not clean latest run ID file: ', e);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
408
427
|
function formatStep(step, shift = 0) {
|
|
409
428
|
const prefix = ' '.repeat(shift);
|
|
410
429
|
const lines = [];
|
|
@@ -427,6 +446,8 @@ function getPackageVersion() {
|
|
|
427
446
|
|
|
428
447
|
module.exports.getPackageVersion = getPackageVersion;
|
|
429
448
|
|
|
449
|
+
module.exports.cleanLatestRunId = cleanLatestRunId;
|
|
450
|
+
|
|
430
451
|
module.exports.formatStep = formatStep;
|
|
431
452
|
|
|
432
453
|
module.exports.readLatestRunId = readLatestRunId;
|