You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/04/11 05:41:40 UTC
[echarts] branch optimize-visual-test-screenshot updated:
test(visual): optimize test runner and report tool
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch optimize-visual-test-screenshot
in repository https://gitbox.apache.org/repos/asf/echarts.git
The following commit(s) were added to refs/heads/optimize-visual-test-screenshot by this push:
new f60e8b0 test(visual): optimize test runner and report tool
f60e8b0 is described below
commit f60e8b0e4b89bd4b890292e543fe6e26f56e9614
Author: pissang <bm...@gmail.com>
AuthorDate: Sun Apr 11 13:40:52 2021 +0800
test(visual): optimize test runner and report tool
---
test/runTest/cli.js | 8 ++++----
test/runTest/config.js | 1 +
test/runTest/genReport.js | 19 +++++++++++--------
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/test/runTest/cli.js b/test/runTest/cli.js
index c7bbe91..f972643 100644
--- a/test/runTest/cli.js
+++ b/test/runTest/cli.js
@@ -96,9 +96,9 @@ async function convertToWebP(filePath, lossless) {
});
}
-async function takeScreenshot(page, fullPage, fileUrl, desc, useSVG, isExpected, minor) {
+async function takeScreenshot(page, fullPage, fileUrl, desc, isExpected, minor) {
let screenshotName = testNameFromFile(fileUrl);
- if (useSVG) {
+ if (program.renderer === 'svg') {
screenshotName += '-_svg_render_';
}
if (desc) {
@@ -153,7 +153,7 @@ async function runActions(page, testOpt, isExpected, screenshots) {
screenshotName,
screenshotPath,
rawScreenshotPath
- } = await takeScreenshot(page, false, testOpt.fileUrl, desc, testOpt.useSVG, isExpected, count++);
+ } = await takeScreenshot(page, false, testOpt.fileUrl, desc, isExpected, count++);
screenshots.push({
screenshotName,
desc,
@@ -213,7 +213,7 @@ async function runTestPage(browser, testOpt, version, runtimeCode, isExpected) {
screenshotName,
screenshotPath,
rawScreenshotPath
- } = await takeScreenshot(page, true, fileUrl, desc, testOpt.useSVG, isExpected);
+ } = await takeScreenshot(page, true, fileUrl, desc, isExpected);
screenshots.push({
screenshotName,
desc,
diff --git a/test/runTest/config.js b/test/runTest/config.js
index 71de615..0a2e409 100644
--- a/test/runTest/config.js
+++ b/test/runTest/config.js
@@ -19,6 +19,7 @@
module.exports = {
testVersion: 'test-v0.1',
+ cacheVersion: '0.1',
port: 8866,
origin: 'http://localhost:8866'
};
\ No newline at end of file
diff --git a/test/runTest/genReport.js b/test/runTest/genReport.js
index 762d206..ab41f25 100644
--- a/test/runTest/genReport.js
+++ b/test/runTest/genReport.js
@@ -23,7 +23,7 @@ const path = require('path');
const util = require('util');
// const jimp = require('jimp');
-// const marked = require('marked');
+const marked = require('marked');
const tests = JSON.parse(fs.readFileSync(
path.join(__dirname, 'tmp/__cache__.json'), 'utf-8'
@@ -51,7 +51,7 @@ async function inlineImage(imageUrl) {
// img.quality(70);
// return img.getBase64Async('image/jpeg');
let imgBuffer = await readFileAsync(fullPath);
- return 'data:image/png;base64,' + imgBuffer.toString('base64');
+ return 'data:image/webp;base64,' + imgBuffer.toString('base64');
}
catch (e) {
console.error(e);
@@ -77,9 +77,12 @@ async function genDetail(test) {
}
let [expectedUrl, actualUrl, diffUrl] = await Promise.all([
- resolveImagePath(shot.expected),
- resolveImagePath(shot.actual),
- resolveImagePath(shot.diff)
+ inlineImage(shot.expected),
+ inlineImage(shot.actual),
+ inlineImage(shot.diff)
+ // resolveImagePath(shot.expected),
+ // resolveImagePath(shot.actual),
+ // resolveImagePath(shot.diff)
]);
shotDetail += `
<div style="margin-top:10px">
@@ -155,9 +158,9 @@ ${detail.content}
fs.writeFileSync(__dirname + '/tmp-report.md', mdText, 'utf-8');
- // marked(mdText, { smartLists: true }, (err, res) => {
- // fs.writeFileSync(__dirname + '/tmp-report.html', res, 'utf-8');
- // });
+ marked(mdText, { smartLists: true }, (err, res) => {
+ fs.writeFileSync(__dirname + '/tmp-report.html', res, 'utf-8');
+ });
}
run();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org