@testomatio/reporter 0.5.0 → 0.5.3
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/Changelog.md +12 -0
- package/lib/adapter/cypress-plugin/index.js +19 -4
- package/lib/util.js +16 -0
- package/package.json +1 -1
package/Changelog.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const TRConstants = require('../../constants');
|
|
2
|
-
const { parseTest } = require('../../util');
|
|
2
|
+
const { parseTest, parseSuite } = require('../../util');
|
|
3
3
|
const TestomatClient = require('../../client');
|
|
4
4
|
|
|
5
5
|
const testomatioReporter = on => {
|
|
@@ -15,21 +15,36 @@ const testomatioReporter = on => {
|
|
|
15
15
|
const videos = [results.video];
|
|
16
16
|
|
|
17
17
|
for (const test of results.tests) {
|
|
18
|
-
const
|
|
18
|
+
const lastAttemptIndex = test.attempts.length - 1;
|
|
19
|
+
const latestAttempt = test.attempts[lastAttemptIndex];
|
|
20
|
+
|
|
19
21
|
const time = latestAttempt.duration;
|
|
20
22
|
const error = latestAttempt.error;
|
|
21
23
|
|
|
22
|
-
const title = test.title
|
|
24
|
+
const title = test.title.pop();
|
|
25
|
+
const suiteTitle = test.title.pop();
|
|
26
|
+
|
|
23
27
|
const testId = parseTest(title);
|
|
28
|
+
const suiteId = parseSuite(suiteTitle);
|
|
29
|
+
|
|
30
|
+
if (error) {
|
|
31
|
+
error.inspect = function() {
|
|
32
|
+
return this.codeFrame.frame;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
24
35
|
|
|
25
36
|
const screenshots = results.screenshots
|
|
26
37
|
.filter(screenshot => screenshot.path.includes(title))
|
|
38
|
+
.filter(screenshot => screenshot.testAttemptIndex === lastAttemptIndex)
|
|
27
39
|
.map(screenshot => screenshot.path);
|
|
40
|
+
|
|
28
41
|
const files = [...videos, ...screenshots];
|
|
29
42
|
|
|
30
43
|
const state = test.state === 'passed' ? TRConstants.PASSED : TRConstants.FAILED;
|
|
31
44
|
|
|
32
|
-
addSpecTestsPromises.push(client.addTestRun(testId, state, {
|
|
45
|
+
addSpecTestsPromises.push(client.addTestRun(testId, state, {
|
|
46
|
+
title, time, error, files, suite_title: suiteTitle, suite_id: suiteId
|
|
47
|
+
}));
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
await Promise.all(addSpecTestsPromises);
|
package/lib/util.js
CHANGED
|
@@ -14,6 +14,21 @@ const parseTest = testTitle => {
|
|
|
14
14
|
return null;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @param {String} suiteTitle - suite title
|
|
19
|
+
*
|
|
20
|
+
* @returns {String} suiteId
|
|
21
|
+
*/
|
|
22
|
+
const parseSuite = suiteTitle => {
|
|
23
|
+
const captures = suiteTitle.match(/@S([\w\d]+)/);
|
|
24
|
+
if (captures) {
|
|
25
|
+
return captures[1];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
|
|
17
32
|
const ansiRegExp = () => {
|
|
18
33
|
const pattern = [
|
|
19
34
|
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
|
@@ -35,6 +50,7 @@ const isValidUrl = s => {
|
|
|
35
50
|
|
|
36
51
|
module.exports = {
|
|
37
52
|
parseTest,
|
|
53
|
+
parseSuite,
|
|
38
54
|
ansiRegExp,
|
|
39
55
|
isValidUrl,
|
|
40
56
|
};
|