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/01/11 08:59:59 UTC
[incubator-echarts-examples] branch next updated: e2e: add skip
param, fix wrong image diff result
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-echarts-examples.git
The following commit(s) were added to refs/heads/next by this push:
new fb65045 e2e: add skip param, fix wrong image diff result
fb65045 is described below
commit fb65045828b3ded43a371db2a0f9516706bc4537
Author: pissang <bm...@gmail.com>
AuthorDate: Mon Jan 11 16:58:51 2021 +0800
e2e: add skip param, fix wrong image diff result
---
README.md | 14 ++++++++---
common/compareImage.js | 2 +-
e2e/main.js | 63 ++++++++++++++++++++++++++++++++++----------------
e2e/report.html | 2 +-
4 files changed, 56 insertions(+), 25 deletions(-)
diff --git a/README.md b/README.md
index f5288f3..a13b2fc 100644
--- a/README.md
+++ b/README.md
@@ -60,12 +60,20 @@ If you want to test with esbuild bundler. Which is much faster.
npm run test:e2e:esbuild
```
-If you want use the packages in your local folder which is still in developing. Please update the `dir` path in `test/config.js` for all packages first. Then run the script directly without `--fetch` arg.
+If you want use the packages in your local folder which is still in developing. Please update the `dir` path in `test/config.js` for all packages first. Then run the script directly with `--local` arg.
+
+```shell
+node e2e/main.js --bundler esbuild -m --local
+node e2e/main.js --bundler webpack -m --local
+```
+
+Skip specific stages to speedup the test. Note: This can only be used when you run the whole e2e test at least once.
+
```shell
-node e2e/main.js --bundler esbuild -m
-node e2e/main.js --bundler webpack -m
+node e2e/main.js --skip bundle
```
+
## Edit example
All test cases are in the `public/data` folder. The comment in the header
diff --git a/common/compareImage.js b/common/compareImage.js
index 99f5fd0..e0d3a93 100644
--- a/common/compareImage.js
+++ b/common/compareImage.js
@@ -16,7 +16,7 @@ function readPNG(path) {
});
}
-module.exports.compareImage = function (targetPath, sourcePath, threshold) {
+module.exports.compareImage = function (targetPath, sourcePath, threshold = 0.1) {
if (!fs.existsSync(targetPath)) {
return true;
}
diff --git a/e2e/main.js b/e2e/main.js
index 4c7ac16..35300a4 100644
--- a/e2e/main.js
+++ b/e2e/main.js
@@ -35,9 +35,8 @@ parser.addArgument(['--local'], {
action: 'storeTrue',
help: `If use local repos. If so, don't forget to update the location of local repo in config.js.`
});
-parser.addArgument(['--no-check-npm'], {
- action: 'storeTrue',
- help: `If not check npm package publishing and install.`
+parser.addArgument(['--skip'], {
+ help: 'If skip some stages to speed up the test. Can be npm,bundle,render,compare'
});
const args = parser.parseArgs();
@@ -114,20 +113,16 @@ async function prepare() {
fse.removeSync(BUNDLE_DIR);
fse.removeSync(SCREENSHOTS_DIR);
- if (!args.no_check_npm) {
- fse.removeSync(REPO_DIR);
- fse.removeSync(PACKAGE_DIR);
- }
+ fse.removeSync(REPO_DIR);
+ fse.removeSync(PACKAGE_DIR);
fse.ensureDirSync(TMP_DIR);
fse.ensureDirSync(RUN_CODE_DIR);
fse.ensureDirSync(BUNDLE_DIR);
fse.ensureDirSync(SCREENSHOTS_DIR);
- if (!args.no_check_npm) {
- fse.ensureDirSync(REPO_DIR);
- fse.ensureDirSync(PACKAGE_DIR);
- }
+ fse.ensureDirSync(REPO_DIR);
+ fse.ensureDirSync(PACKAGE_DIR);
}
async function downloadPackages(config) {
@@ -593,9 +588,18 @@ async function compareExamples(testNames, result) {
async function main() {
const result = {};
- await prepare();
- if (!args.no_check_npm) {
+ if (!args.skip) {
+ // Don't clean up if skipping some of the stages.
+ await prepare();
+ }
+
+ function isNotSkipped(stage) {
+ return !((args.skip || '').indexOf(stage) >= 0);
+ }
+
+ // We don't have to test the npm if bundle is also skipped.
+ if (isNotSkipped('npm') && isNotSkipped('bundle')) {
if (!args.local) {
console.log(chalk.gray('Downloading packages'));
await downloadPackages(config);
@@ -604,12 +608,15 @@ async function main() {
console.log(chalk.gray('Installing packages'));
await installPackages(config);
}
+ else {
+ console.log(chalk.yellow('Skipped NPM.'));
+ }
console.log(chalk.gray('Generating codes'));
+ // Always build code.
const testNames = await buildRunCode();
-
for (let key of testNames) {
result[key] = {
compileErrors: {
@@ -622,6 +629,7 @@ async function main() {
}
console.log('Compiling TypeScript');
+ // Always run typescript check to generate the js code.
await compileTs(
(await globby(nodePath.join(RUN_CODE_DIR, '*.ts')))
// No need to check types of the minimal legacy imports
@@ -629,14 +637,29 @@ async function main() {
result
);
- console.log(`Bundling with ${USE_WEBPACK ? 'webpack' : 'esbuild'}`);
- await bundle(await globby(nodePath.join(RUN_CODE_DIR, '*.js')), result);
+ if (isNotSkipped('bundle')) {
+ console.log(`Bundling with ${USE_WEBPACK ? 'webpack' : 'esbuild'}`);
+ await bundle(await globby(nodePath.join(RUN_CODE_DIR, '*.js')), result);
+ }
+ else {
+ console.log(chalk.yellow('Skipped Bundle.'));
+ }
- console.log('Running examples');
- await runExamples(await globby(nodePath.join(BUNDLE_DIR, '*.js')), result);
+ if (isNotSkipped('render')) {
+ console.log('Running examples');
+ await runExamples(await globby(nodePath.join(BUNDLE_DIR, '*.js')), result);
+ }
+ else {
+ console.log(chalk.yellow('Skipped Render.'));
+ }
- console.log('Comparing Results');
- await compareExamples(testNames, result);
+ if (isNotSkipped('compare')) {
+ console.log('Comparing Results');
+ await compareExamples(testNames, result);
+ }
+ else {
+ console.log(chalk.yellow('Skipped Compare.'));
+ }
fs.writeFileSync(__dirname + '/tmp/result.json', JSON.stringify(
result, null, 2
diff --git a/e2e/report.html b/e2e/report.html
index 8028b0c..d4c44f2 100644
--- a/e2e/report.html
+++ b/e2e/report.html
@@ -83,7 +83,7 @@
</div>
</el-tab-pane>
<el-tab-pane label="Screenshots Compare" name="screenshots">
- <div v-for="item in typeCheckingResult">
+ <div v-for="item in screenshotsCompareResult">
<h3>{{ item.testName }}({{item.screenshotDiffRatio}})</h3>
<el-row :gutter="10">
<el-col :span="4">
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org