@percy/report 1.0.4 → 1.0.5
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/package.json +1 -1
- package/src/generate.js +5 -5
- package/src/html-render.js +3 -3
- package/src/summary.js +2 -2
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ Step 3 : Execute the Percy Report Generation Step<br>
|
|
|
46
46
|
[Example](/example/percy.sh):
|
|
47
47
|
```sh
|
|
48
48
|
export PERCY_TOKEN=<your-percy-token>
|
|
49
|
-
BUILD_ID=$(npx percy exec -- {Test Command} | grep
|
|
49
|
+
BUILD_ID=$(npx percy exec -- {Test Command} | grep https:\/\/percy.io\/.*\/builds | awk -F "/" '{print $NF}')
|
|
50
50
|
npx percy-report generate $BUILD_ID
|
|
51
51
|
```
|
|
52
52
|
|
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.5",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "BrowserStack Pvt Ltd",
|
package/src/generate.js
CHANGED
|
@@ -34,7 +34,7 @@ module.exports.Generate = async function (config) {
|
|
|
34
34
|
downloadQueue = new PQueue({concurrency:1,intervalCap:5,interval:5000})
|
|
35
35
|
})
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const useCompTag = buildDetails['data']['attributes']['type'] == 'app' || buildDetails['data']['attributes']['type'] == 'automate'
|
|
38
38
|
while (buildDetails.data && buildDetails.data.attributes.state !== 'finished') {
|
|
39
39
|
console.log("Waiting for build to complete on Percy...")
|
|
40
40
|
await wait(30000)
|
|
@@ -89,8 +89,8 @@ module.exports.Generate = async function (config) {
|
|
|
89
89
|
let head = images['head'] = getComparisonImage(comp, 'head-screenshot')
|
|
90
90
|
let diff = images['diff'] = getComparisonImage(comp, 'diff-image')
|
|
91
91
|
let compTag;
|
|
92
|
-
Object.assign(comparison, comp.attributes, { images },
|
|
93
|
-
if (
|
|
92
|
+
Object.assign(comparison, comp.attributes, { images }, useCompTag?{ device:compTag }:{browser:compTag});
|
|
93
|
+
if (useCompTag) {
|
|
94
94
|
let device = getComparisonDevice(comp)
|
|
95
95
|
compTag = `${device.name} (${device['os-name']} ${device['os-version']})`
|
|
96
96
|
if(!report.devices.includes(compTag)){
|
|
@@ -130,7 +130,7 @@ module.exports.Generate = async function (config) {
|
|
|
130
130
|
report['unreviewedScreenshots']++
|
|
131
131
|
flagChanged = true
|
|
132
132
|
}
|
|
133
|
-
Object.assign(comparison, comp.attributes, { images },
|
|
133
|
+
Object.assign(comparison, comp.attributes, { images }, useCompTag?{ device:compTag }:{browser:compTag})
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
comparison['diff-percentage'] = (comparison['diff-ratio'] * 100).toFixed(2)
|
|
@@ -146,7 +146,7 @@ module.exports.Generate = async function (config) {
|
|
|
146
146
|
return formattedSnapshot
|
|
147
147
|
})
|
|
148
148
|
fs.writeFileSync(`${baseDir}/report.json`, JSON.stringify(report, undefined, 2))
|
|
149
|
-
HtmlReportGenerator(config, report,
|
|
149
|
+
HtmlReportGenerator(config, report, useCompTag)
|
|
150
150
|
console.log("Build Report Generated.")
|
|
151
151
|
return report
|
|
152
152
|
}
|
package/src/html-render.js
CHANGED
|
@@ -2,7 +2,7 @@ const fs = require('fs')
|
|
|
2
2
|
const ejs = require('ejs');
|
|
3
3
|
const path = require('path')
|
|
4
4
|
|
|
5
|
-
function HtmlReportGenerator(config, jsonReport,
|
|
5
|
+
function HtmlReportGenerator(config, jsonReport, useCompTag) {
|
|
6
6
|
let {
|
|
7
7
|
buildId,
|
|
8
8
|
downloadPath
|
|
@@ -24,8 +24,8 @@ function HtmlReportGenerator(config, jsonReport, isApp) {
|
|
|
24
24
|
fs.writeFileSync(`${downloadPath}/${buildId}/report.html`, htmlReport)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function HtmlSummary(summary, filename,
|
|
28
|
-
if (
|
|
27
|
+
function HtmlSummary(summary, filename, useCompTag) {
|
|
28
|
+
if (useCompTag) {
|
|
29
29
|
let template_path = path.resolve(__dirname, 'template/app-summary.html')
|
|
30
30
|
const template = fs.readFileSync(template_path, {
|
|
31
31
|
encoding: "utf-8"
|
package/src/summary.js
CHANGED
|
@@ -35,7 +35,7 @@ module.exports.Summary = async function (opts) {
|
|
|
35
35
|
throw res.data
|
|
36
36
|
}
|
|
37
37
|
})
|
|
38
|
-
const
|
|
38
|
+
const useCompTag = project['data']['attributes']['type'] == 'app' || project['data']['attributes']['type'] == 'automate'
|
|
39
39
|
let projectId = project.data.id
|
|
40
40
|
let projectURL = "https://percy.io/"+project.data.attributes['full-slug']
|
|
41
41
|
let projectName = project.data.attributes.name
|
|
@@ -131,7 +131,7 @@ module.exports.Summary = async function (opts) {
|
|
|
131
131
|
fs.mkdirSync('Summary',{recursive:true})
|
|
132
132
|
}
|
|
133
133
|
fs.writeFileSync(`Summary/${summary.projectName}-${Date.now()}.json`,JSON.stringify(summary,undefined,2))
|
|
134
|
-
HtmlSummary(summary,`Summary/${summary.projectName}-${Date.now()}.html`,
|
|
134
|
+
HtmlSummary(summary,`Summary/${summary.projectName}-${Date.now()}.html`, useCompTag)
|
|
135
135
|
console.log("Summary report generated")
|
|
136
136
|
return summary;
|
|
137
137
|
|