@percy/report 0.0.4 → 0.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/README.md +20 -0
- package/package.json +4 -3
- package/src/generate.js +21 -8
package/README.md
CHANGED
|
@@ -68,3 +68,23 @@ Note: Project Slug is equal to Project Name on your percy dashboard
|
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
*Note: Interval between start date and end date should not exceed 30 days.*
|
|
71
|
+
|
|
72
|
+
# Examples
|
|
73
|
+
|
|
74
|
+
## Web Percy
|
|
75
|
+
|
|
76
|
+
#### Build Report
|
|
77
|
+

|
|
78
|
+
#### Summary Report
|
|
79
|
+

|
|
80
|
+
|
|
81
|
+
## App Percy
|
|
82
|
+
|
|
83
|
+
#### Build Report
|
|
84
|
+

|
|
85
|
+
|
|
86
|
+
#### Summary Report
|
|
87
|
+

|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
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": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "BrowserStack Pvt Ltd",
|
|
@@ -44,11 +44,12 @@
|
|
|
44
44
|
"commander": "^9.4.0",
|
|
45
45
|
"date-fns": "^2.29.3",
|
|
46
46
|
"dotenv": "^16.0.3",
|
|
47
|
-
"ejs": "^3.1.8"
|
|
47
|
+
"ejs": "^3.1.8",
|
|
48
|
+
"p-queue": "^8.0.1"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@percy/selenium-webdriver": "^1.0.2",
|
|
51
52
|
"chai": "^4.3.7",
|
|
52
53
|
"mocha": "^10.2.0"
|
|
53
54
|
}
|
|
54
|
-
}
|
|
55
|
+
}
|
package/src/generate.js
CHANGED
|
@@ -9,6 +9,7 @@ const defaultConfig = {
|
|
|
9
9
|
downloadPath: './Reports',
|
|
10
10
|
diffThreshold: 1
|
|
11
11
|
}
|
|
12
|
+
let downloadQueue;
|
|
12
13
|
module.exports.Generate = async function (config) {
|
|
13
14
|
let { buildId, percyToken, apiUrl, downloadImages, downloadPath, diffThreshold } = Object.assign({}, defaultConfig, config)
|
|
14
15
|
let axios = new Axios({
|
|
@@ -28,6 +29,11 @@ module.exports.Generate = async function (config) {
|
|
|
28
29
|
throw res.data
|
|
29
30
|
}
|
|
30
31
|
})
|
|
32
|
+
if(!downloadQueue){
|
|
33
|
+
await import('p-queue').then(({default:PQueue})=>{
|
|
34
|
+
downloadQueue = new PQueue({concurrency:1,intervalCap:5,interval:5000})
|
|
35
|
+
})
|
|
36
|
+
}
|
|
31
37
|
const isApp = buildDetails['data']['attributes']['type'] == 'app'
|
|
32
38
|
while (buildDetails.data && buildDetails.data.attributes.state !== 'finished') {
|
|
33
39
|
console.log("Waiting for build to complete on Percy...")
|
|
@@ -101,10 +107,12 @@ module.exports.Generate = async function (config) {
|
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
109
|
if (downloadImages) {
|
|
110
|
+
|
|
111
|
+
|
|
104
112
|
['base', 'head', 'diff'].forEach((val) => {
|
|
105
113
|
if (images[val]) {
|
|
106
114
|
images[val].file = downloadImage({
|
|
107
|
-
name: String(snapshot?.['attributes'].name)
|
|
115
|
+
name: String(snapshot?.['attributes'].name),
|
|
108
116
|
compTag,
|
|
109
117
|
width: images[val].width,
|
|
110
118
|
type: val,
|
|
@@ -167,18 +175,23 @@ function downloadImage(options) {
|
|
|
167
175
|
if (!fs.existsSync(`${baseDir}/${type}`)) {
|
|
168
176
|
fs.mkdirSync(`${baseDir}/${type}`, { recursive: true })
|
|
169
177
|
}
|
|
170
|
-
let
|
|
178
|
+
let composedName = `${name}-${compTag}-${width}.png`.replace(/[\\\/]/g,'_')
|
|
179
|
+
let path = `${baseDir}/${type}/${composedName}`
|
|
171
180
|
try {
|
|
172
|
-
new Axios({ responseType: 'arraybuffer', url: url }).get(url).then((file) => {
|
|
181
|
+
downloadQueue.add(()=>new Axios({ responseType: 'arraybuffer', url: url }).get(url).then((file) => {
|
|
173
182
|
console.log("Download Complete:" + path)
|
|
174
183
|
fs.writeFileSync(path, file.data)
|
|
175
184
|
}).catch((err) => {
|
|
176
185
|
console.error("Failed to Download: " + path)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
186
|
+
if(err.code == 'ECONNRESET'){
|
|
187
|
+
console.log('Retrying '+ path)
|
|
188
|
+
}else{
|
|
189
|
+
console.error(`Failed ${path}, error: ${err.code}`)
|
|
190
|
+
}
|
|
191
|
+
}))
|
|
192
|
+
return `file:./${type}/${composedName}`;
|
|
193
|
+
} catch(err) {
|
|
194
|
+
|
|
182
195
|
}
|
|
183
196
|
}
|
|
184
197
|
|