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 07:20:32 UTC
[incubator-echarts-examples] branch next updated: add gl testing in
e2e test
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 2eb5a4c add gl testing in e2e test
2eb5a4c is described below
commit 2eb5a4cb946ed40cf3a5df855a0a999354dc2fd5
Author: pissang <bm...@gmail.com>
AuthorDate: Mon Jan 11 15:20:17 2021 +0800
add gl testing in e2e test
---
README.md | 4 ++-
common/buildCode.js | 3 ++
e2e/config.js | 6 ++--
e2e/main.js | 89 +++++++++++++++++++++++++++++++++--------------------
package.json | 6 ++--
5 files changed, 68 insertions(+), 40 deletions(-)
diff --git a/README.md b/README.md
index cf9132f..f5288f3 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,7 @@ node tool/build-example.js -t default
## Run e2e tests.
-Run all the examples to test module importing, minimal bundling and DTS correctness.
+Run all the examples to test package publishing and install, module importing, minimal bundling and DTS correctness.
Before run the tests. you need to update the examples.
@@ -53,6 +53,8 @@ Then run the tests.
npm run test:e2e
```
+You can change the testing branch or local dir, which is available when add `--local` in `e2e/config.js`
+
If you want to test with esbuild bundler. Which is much faster.
```shell
npm run test:e2e:esbuild
diff --git a/common/buildCode.js b/common/buildCode.js
index 7ca0e05..2213ab5 100644
--- a/common/buildCode.js
+++ b/common/buildCode.js
@@ -163,6 +163,9 @@ module.exports.collectDeps = function collectDeps(option) {
if (CHARTS_MAP[seriesOpt.type]) {
deps.push(CHARTS_MAP[seriesOpt.type]);
}
+ if (CHARTS_GL_MAP[seriesOpt.type]) {
+ deps.push(CHARTS_GL_MAP[seriesOpt.type]);
+ }
MARKERS.forEach(markerType => {
if (seriesOpt[markerType]) {
deps.push(COMPONENTS_MAP[markerType]);
diff --git a/e2e/config.js b/e2e/config.js
index 57a5799..8295789 100644
--- a/e2e/config.js
+++ b/e2e/config.js
@@ -6,17 +6,17 @@ module.exports = {
{
name: 'zrender', // package name
dir: nodePath.resolve(__dirname, '../../zrender'),
- git: 'ecomfe/zrender#master'
+ git: 'ecomfe/zrender#release'
},
{
name: 'echarts',
dir: nodePath.resolve(__dirname, '../../echarts'),
- git: 'apache/incubator-echarts#master'
+ git: 'apache/incubator-echarts#release'
},
{
name: 'echarts-gl',
dir: nodePath.resolve(__dirname, '../../echarts-gl'),
- git: 'ecomfe/echarts-gl#master'
+ git: 'ecomfe/echarts-gl#next'
},
{
name: 'echarts-wordcloud',
diff --git a/e2e/main.js b/e2e/main.js
index 27101bc..8b2b335 100644
--- a/e2e/main.js
+++ b/e2e/main.js
@@ -31,10 +31,14 @@ parser.addArgument(['-m', '--minify'], {
action: 'storeTrue',
help: 'If minify'
});
-parser.addArgument(['--fetch'], {
+parser.addArgument(['--local'], {
action: 'storeTrue',
- help: `If fetch repo from github. If not use fetch, don't forget to update the location of local repo in config.js.`
-})
+ 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.`
+});
const args = parser.parseArgs();
const EXAMPLE_DIR = `${__dirname}/../public/`;
@@ -109,15 +113,21 @@ async function prepare() {
fse.removeSync(RUN_CODE_DIR);
fse.removeSync(BUNDLE_DIR);
fse.removeSync(SCREENSHOTS_DIR);
- fse.removeSync(REPO_DIR);
- fse.removeSync(PACKAGE_DIR);
+
+ if (!args.no_check_npm) {
+ 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);
- fse.ensureDirSync(REPO_DIR);
- fse.ensureDirSync(PACKAGE_DIR);
+
+ if (!args.no_check_npm) {
+ fse.ensureDirSync(REPO_DIR);
+ fse.ensureDirSync(PACKAGE_DIR);
+ }
}
async function downloadPackages(config) {
@@ -137,11 +147,11 @@ async function installPackages(config) {
function checkFolder(pkg) {
const dir = pkg.dir;
if (!fs.existsSync(dir)) {
- console.warn(chalk.yellow(`${dir} not exists. Please update it in e2e/config.js. Or use --fetch to fetch from GitHub.`));
+ console.warn(chalk.yellow(`${dir} not exists. Please update it in e2e/config.js.`));
return false;
}
if (!nodePath.isAbsolute(dir)) {
- console.warn(chalk.yellow(`${dir} is not an absolute path. Please update it in e2e/config.js. Or add --fetch flag to fetch from GitHub.`));
+ console.warn(chalk.yellow(`${dir} is not an absolute path. Please update it in e2e/config.js.`));
return false;
}
return true;
@@ -167,7 +177,10 @@ async function installPackages(config) {
}
}
- shell.exec(`npm install`)
+ if (!args.local) {
+ // Only run install commands when fetching from github.
+ shell.exec(`npm install`);
+ }
shell.exec(`npm install ${publishedPackages[depPkgName]} --no-save`);
}
}
@@ -194,17 +207,22 @@ async function installPackages(config) {
}
async function buildRunCode() {
- const files = await globby(`${EXAMPLE_DIR}/data/option/*.json`);
+ const files = await globby([
+ `${EXAMPLE_DIR}/data/option/*.json`,
+ `${EXAMPLE_DIR}/data-gl/option/*.json`
+ ]);
if (!files.length) {
throw new Error('You need to run `node tool/build-example.js` before run this test.');
}
return (await runTasks(files, async (fileName) => {
+ const isGL = fileName.startsWith(`${EXAMPLE_DIR}/data-gl`);
+
const optionCode = await fse.readFile(fileName, 'utf-8');
const option = JSON.parse(optionCode);
const jsCode = await fse.readFile(nodePath.join(
- EXAMPLE_DIR, 'data', nodePath.basename(fileName, '.json') + '.js'
+ EXAMPLE_DIR, isGL ? 'data-gl' : 'data', nodePath.basename(fileName, '.json') + '.js'
), 'utf-8');
// TODO Ignore case with extension.
@@ -214,7 +232,9 @@ async function buildRunCode() {
'CanvasRenderer'
]);
- if (deps.includes('MapChart') || deps.includes('GeoComponent') || option.bmap) {
+ if (deps.includes('MapChart')
+ || deps.includes('GeoComponent')
+ || option.bmap) {
console.warn(chalk.yellow(`Ignored map tests.${fileName}`));
return;
}
@@ -222,16 +242,18 @@ async function buildRunCode() {
const testName = nodePath.basename(fileName, '.json');
const ROOT_PATH = `${baseUrl}/public`;
- const fullTsCode = buildExampleCode(buildPrepareCode(true) + jsCode, deps, {
+ const checkTs = !isGL; // TODO: Don't support TypeScript in GL
+
+ const fullCode = buildExampleCode(buildPrepareCode(true) + jsCode, deps, {
minimal: false,
- ts: true,
+ ts: checkTs,
// Check if theme will break the minimal imports.
theme: TEST_THEME,
ROOT_PATH
});
- const minimalTsCode = buildExampleCode(buildPrepareCode(true) + jsCode, deps, {
+ const minimalCode = buildExampleCode(buildPrepareCode(true) + jsCode, deps, {
minimal: true,
- ts: true,
+ ts: checkTs, // TODO: Don't support TypeScript in GL
theme: TEST_THEME,
ROOT_PATH
});
@@ -244,17 +266,17 @@ async function buildRunCode() {
});
await fse.writeFile(
- nodePath.join(RUN_CODE_DIR, testName + '.ts'),
- prettier.format(fullTsCode, {
+ nodePath.join(RUN_CODE_DIR, testName + (checkTs ? '.ts' : '.js')),
+ prettier.format(fullCode, {
singleQuote: true,
- parser: 'typescript'
+ parser: checkTs ? 'typescript' : 'babel'
}), 'utf-8'
);
await fse.writeFile(
- nodePath.join(RUN_CODE_DIR, testName + `.${MINIMAL_POSTFIX}.ts`),
- prettier.format(minimalTsCode, {
+ nodePath.join(RUN_CODE_DIR, testName + `.${MINIMAL_POSTFIX}.${checkTs ? 'ts' : 'js'}`),
+ prettier.format(minimalCode, {
singleQuote: true,
- parser: 'typescript'
+ parser: checkTs ? 'typescript' : 'babel'
}), 'utf-8'
);
await fse.writeFile(
@@ -265,7 +287,7 @@ async function buildRunCode() {
}), 'utf-8'
);
console.log(
- chalk.green('Generated: ', nodePath.join(RUN_CODE_DIR, testName + '.ts'))
+ chalk.green('Generated: ', nodePath.join(RUN_CODE_DIR, testName))
);
return testName;
@@ -403,7 +425,6 @@ function esbuildBundle(entry, result, minify) {
entryPoints: entry,
bundle: true,
minify: minify,
- plugins: [echartsResolvePlugin, zrenderResolverPlugin],
define: {
'process.env.NODE_ENV': JSON.stringify(minify ? 'production' : 'development')
},
@@ -497,12 +518,12 @@ async function runExamples(jsFiles, result) {
}
});
- await page.goto(`${baseUrl}/test/template.html`, {
+ await page.goto(`${baseUrl}/e2e/template.html`, {
waitUntil: 'networkidle0',
timeout: 10000
});
await page.addScriptTag({
- url: `${baseUrl}/test/tmp/bundles/${basename}.js`
+ url: `${baseUrl}/e2e/tmp/bundles/${basename}.js`
});
await waitTime(200);
@@ -572,13 +593,15 @@ async function main() {
const result = {};
await prepare();
- if (args.fetch) {
- console.log(chalk.gray('Downloading packages'));
- await downloadPackages(config);
- }
+ if (!args.no_check_npm) {
+ if (!args.local) {
+ console.log(chalk.gray('Downloading packages'));
+ await downloadPackages(config);
+ }
- console.log(chalk.gray('Installing packages'));
- await installPackages(config);
+ console.log(chalk.gray('Installing packages'));
+ await installPackages(config);
+ }
console.log(chalk.gray('Generating codes'));
diff --git a/package.json b/package.json
index f27af75..5da2daa 100644
--- a/package.json
+++ b/package.json
@@ -9,8 +9,8 @@
"release": "npm run build && node build/copyResource.js --env asf",
"dev": "npx concurrently --kill-others \"npm:watch\" \"npm:server\"",
"build:example": "node tool/build-example.js && node tool/build-example.js --source data-gl",
- "test:e2e": "node e2e/main.js --bundler webpack -m --fetch",
- "test:e2e:esbuild": "node e2e/main.js --bundler esbuild -m --fetch",
+ "test:e2e": "node e2e/main.js --bundler webpack -m",
+ "test:e2e:esbuild": "node e2e/main.js --bundler esbuild -m",
"server": "node build/server.js"
},
"devDependencies": {
@@ -26,7 +26,7 @@
"download-git-repo": "^3.0.2",
"echarts": "^5.0.0",
"echarts-stat": "^1.2.0",
- "esbuild": "^0.8.26",
+ "esbuild": "^0.8.31",
"file-loader": "^4.3.0",
"fs-extra": "^8.1.0",
"globby": "^10.0.1",
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org