@percy/report 1.0.3 → 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 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 build | awk -F "/" '{print $NF}')
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.3",
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 isApp = buildDetails['data']['attributes']['type'] == 'app'
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 }, isApp?{ device:compTag }:{browser:compTag});
93
- if (isApp) {
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 }, isApp?{ device:compTag }:{browser:compTag})
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, isApp)
149
+ HtmlReportGenerator(config, report, useCompTag)
150
150
  console.log("Build Report Generated.")
151
151
  return report
152
152
  }
@@ -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, isApp) {
5
+ function HtmlReportGenerator(config, jsonReport, useCompTag) {
6
6
  let {
7
7
  buildId,
8
8
  downloadPath
@@ -11,7 +11,11 @@ function HtmlReportGenerator(config, jsonReport, isApp) {
11
11
  const template = fs.readFileSync(template_path, {
12
12
  encoding: 'utf-8'
13
13
  }).toString()
14
+ const babel = fs.readFileSync(path.resolve(__dirname,'template/babel.min.js'),{encoding:'utf8'}).toString()
14
15
  let htmlReport = ejs.render(template, {
16
+ babel:babel,
17
+ reactdom:fs.readFileSync(path.resolve(__dirname,'template/react-dom.production.min.js')).toString('utf-8'),
18
+ react: fs.readFileSync(path.resolve(__dirname,'template/react.production.min.js')).toString('utf-8'),
15
19
  data: Buffer.from(JSON.stringify({
16
20
  buildId,
17
21
  ...jsonReport
@@ -20,8 +24,8 @@ function HtmlReportGenerator(config, jsonReport, isApp) {
20
24
  fs.writeFileSync(`${downloadPath}/${buildId}/report.html`, htmlReport)
21
25
  }
22
26
 
23
- function HtmlSummary(summary, filename, isApp) {
24
- if (isApp) {
27
+ function HtmlSummary(summary, filename, useCompTag) {
28
+ if (useCompTag) {
25
29
  let template_path = path.resolve(__dirname, 'template/app-summary.html')
26
30
  const template = fs.readFileSync(template_path, {
27
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 isApp = project['data']['attributes']['type'] == 'app'
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`, isApp)
134
+ HtmlSummary(summary,`Summary/${summary.projectName}-${Date.now()}.html`, useCompTag)
135
135
  console.log("Summary report generated")
136
136
  return summary;
137
137