@percy/report 1.0.5 → 1.0.6
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/package.json +1 -1
- package/src/generate.js +32 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/report",
|
|
3
3
|
"description": "Package to generate a build report and project summary report for Percy, BrowserStack's visual testing platform",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "BrowserStack Pvt Ltd",
|
package/src/generate.js
CHANGED
|
@@ -49,17 +49,41 @@ module.exports.Generate = async function (config) {
|
|
|
49
49
|
throw new Error("Build Failed with an Error on Percy Server. Please check your percy dashboard for more information.")
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
console.log(`Generating report for Build ID ${buildId}`)
|
|
54
|
-
let snapshotsData = await axios.get(`/snapshots?build_id=${buildId}`, { responseType: 'json' }).then((res) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
// let snapshotsData = await axios.get(`/snapshots?build_id=${buildId}`, { responseType: 'json' }).then((res) => {
|
|
55
|
+
// if (res.status == 200) {
|
|
56
|
+
// let parser = new Parser(res.data)
|
|
57
|
+
// let data = parser.getSimplified()
|
|
58
|
+
// return data
|
|
59
|
+
// } else {
|
|
60
|
+
// throw res.data
|
|
61
|
+
// }
|
|
62
|
+
// })
|
|
63
|
+
//
|
|
64
|
+
let snapshotsData = [];
|
|
65
|
+
let cursor = null;
|
|
66
|
+
let hasMore = true;
|
|
67
|
+
|
|
68
|
+
while (hasMore) {
|
|
69
|
+
const cursorParam = cursor ? `&page[cursor]=${cursor}` : '';
|
|
70
|
+
const response = await axios.get(`/snapshots?build_id=${buildId}${cursorParam}`, { responseType: 'json' });
|
|
71
|
+
if (response.status === 200) {
|
|
72
|
+
let parser = new Parser(response.data);
|
|
73
|
+
let data = parser.getSimplified();
|
|
74
|
+
if (data.length > 0) {
|
|
75
|
+
snapshotsData.push(...data);
|
|
76
|
+
cursor = data[data.length - 1].id; // update cursor to last snapshot ID
|
|
77
|
+
// If less than a typical page size (usually 20), stop
|
|
78
|
+
// hasMore = data.length >= 20;
|
|
79
|
+
} else {
|
|
80
|
+
hasMore = false;
|
|
81
|
+
}
|
|
59
82
|
} else {
|
|
60
|
-
throw
|
|
83
|
+
throw response.data;
|
|
61
84
|
}
|
|
62
|
-
}
|
|
85
|
+
}
|
|
86
|
+
|
|
63
87
|
buildURL = buildDetails['data']['attributes']['web-url']
|
|
64
88
|
projectURL = buildURL.split("/builds/")[0]
|
|
65
89
|
projectName = projectURL.split('/').slice(-1)[0]
|