@testomatio/reporter 2.3.9 → 2.4.0
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/README.md +1 -1
- package/lib/bin/cli.js +26 -7
- package/lib/client.js +18 -10
- package/lib/data-storage.d.ts +1 -1
- package/lib/helpers.d.ts +1 -0
- package/lib/helpers.js +4 -0
- package/lib/pipe/coverage.d.ts +82 -0
- package/lib/pipe/coverage.js +373 -0
- package/lib/pipe/index.js +2 -0
- package/lib/pipe/testomatio.d.ts +1 -1
- package/lib/pipe/testomatio.js +25 -4
- package/lib/reporter-functions.js +13 -9
- package/lib/reporter.d.ts +12 -12
- package/lib/services/artifacts.d.ts +1 -1
- package/lib/services/key-values.d.ts +1 -1
- package/lib/services/links.d.ts +1 -1
- package/lib/services/logger.d.ts +1 -1
- package/lib/utils/pipe_utils.d.ts +15 -0
- package/lib/utils/pipe_utils.js +44 -2
- package/lib/utils/utils.d.ts +6 -0
- package/lib/utils/utils.js +71 -1
- package/package.json +5 -4
- package/src/bin/cli.js +35 -9
- package/src/client.js +22 -14
- package/src/helpers.js +1 -0
- package/src/pipe/coverage.js +440 -0
- package/src/pipe/index.js +2 -0
- package/src/pipe/testomatio.js +34 -5
- package/src/reporter-functions.js +13 -9
- package/src/utils/pipe_utils.js +52 -3
- package/src/utils/utils.js +75 -0
package/src/utils/utils.js
CHANGED
|
@@ -6,6 +6,7 @@ import isValid from 'is-valid-path';
|
|
|
6
6
|
import createDebugMessages from 'debug';
|
|
7
7
|
import os from 'os';
|
|
8
8
|
import { fileURLToPath } from 'url';
|
|
9
|
+
import { execSync } from 'child_process';
|
|
9
10
|
|
|
10
11
|
const debug = createDebugMessages('@testomatio/reporter:util');
|
|
11
12
|
|
|
@@ -58,6 +59,21 @@ const validateSuiteId = suiteId => {
|
|
|
58
59
|
return match ? match[0] : null;
|
|
59
60
|
};
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Gets current git commit SHA
|
|
64
|
+
* @returns {String|null} git commit SHA or null if not available
|
|
65
|
+
*/
|
|
66
|
+
const getGitCommitSha = () => {
|
|
67
|
+
try {
|
|
68
|
+
const sha = execSync('git rev-parse --short HEAD', {
|
|
69
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
70
|
+
}).toString().trim();
|
|
71
|
+
return sha || null;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
61
77
|
const ansiRegExp = () => {
|
|
62
78
|
const pattern = [
|
|
63
79
|
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
|
@@ -615,6 +631,63 @@ function truncate(s, size = 255) {
|
|
|
615
631
|
return `${str.substring(0, size)}...`;
|
|
616
632
|
}
|
|
617
633
|
|
|
634
|
+
function applyFilter(command, tests) {
|
|
635
|
+
if (!tests || !tests.length) return command;
|
|
636
|
+
|
|
637
|
+
const lower = (command || '').toLowerCase();
|
|
638
|
+
const regexPattern = `(${tests.join('|')})`;
|
|
639
|
+
|
|
640
|
+
if (lower.includes('jest')) {
|
|
641
|
+
return `${command} --testNamePattern ${regexPattern}`;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
if (lower.includes('cypress')) {
|
|
645
|
+
const grepValue = tests.join(',');
|
|
646
|
+
const baseEnv = {
|
|
647
|
+
grep: grepValue,
|
|
648
|
+
grepFilterSpecs: true,
|
|
649
|
+
grepOmitFiltered: true,
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
if (command.includes('--env')) {
|
|
653
|
+
return command.replace(
|
|
654
|
+
/--env\s+(['"]?)([^\s'"]+)\1/,
|
|
655
|
+
(match, quote, envVal) => {
|
|
656
|
+
const existingEnv = {};
|
|
657
|
+
|
|
658
|
+
if (envVal.startsWith('{') && envVal.endsWith('}')) {
|
|
659
|
+
try {
|
|
660
|
+
Object.assign(existingEnv, JSON.parse(envVal));
|
|
661
|
+
} catch (e) {
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if (!Object.keys(existingEnv).length) {
|
|
666
|
+
envVal.split(',').forEach((pair) => {
|
|
667
|
+
const [k, v] = pair.split('=');
|
|
668
|
+
if (!k) return;
|
|
669
|
+
|
|
670
|
+
if (v === 'true') existingEnv[k] = true;
|
|
671
|
+
else if (v === 'false') existingEnv[k] = false;
|
|
672
|
+
else existingEnv[k] = v;
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
const merged = { ...existingEnv, ...baseEnv };
|
|
677
|
+
const json = JSON.stringify(merged);
|
|
678
|
+
|
|
679
|
+
return `--env ${json}`;
|
|
680
|
+
},
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
const json = JSON.stringify(baseEnv);
|
|
685
|
+
return `${command} --env ${json}`;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
return `${command} --grep ${regexPattern}`;
|
|
689
|
+
}
|
|
690
|
+
|
|
618
691
|
export {
|
|
619
692
|
ansiRegExp,
|
|
620
693
|
truncate,
|
|
@@ -629,6 +702,7 @@ export {
|
|
|
629
702
|
foundedTestLog,
|
|
630
703
|
formatStep,
|
|
631
704
|
getCurrentDateTime,
|
|
705
|
+
getGitCommitSha,
|
|
632
706
|
getTestomatIdFromTestTitle,
|
|
633
707
|
humanize,
|
|
634
708
|
isValidUrl,
|
|
@@ -640,4 +714,5 @@ export {
|
|
|
640
714
|
testRunnerHelper,
|
|
641
715
|
transformEnvVarToBoolean,
|
|
642
716
|
validateSuiteId,
|
|
717
|
+
applyFilter
|
|
643
718
|
};
|