This is an automated email from the ASF dual-hosted git repository. sushuang pushed a commit to branch gh-pages in repository https://gitbox.apache.org/repos/asf/echarts-examples.git
commit b1085cff3f2bf4eb5422bf9f9eb9e1d09d9c4802 Author: sushuang <sushuang0...@gmail.com> AuthorDate: Fri Aug 27 02:41:03 2021 +0800 fix: some tweak for e2e test (but probably not important) --- e2e/main.js | 49 +++++++++++++++++++++++++++++++++---------------- e2e/package.json | 5 ----- package.json | 2 ++ 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/e2e/main.js b/e2e/main.js index 575488c..c086f26 100644 --- a/e2e/main.js +++ b/e2e/main.js @@ -45,7 +45,7 @@ parser.addArgument(['-t', '--tests'], { }); const args = parser.parseArgs(); -const EXAMPLE_DIR = `${__dirname}/../public/`; +const EXAMPLE_DIR = nodePath.resolve(`${__dirname}/../public`); const TMP_DIR = `${__dirname}/tmp`; const RUN_CODE_DIR = `${TMP_DIR}/tests`; const BUNDLE_DIR = `${TMP_DIR}/bundles`; @@ -173,17 +173,20 @@ async function installPackages(config) { if (packageJson.dependencies) { for (let depPkgName in packageJson.dependencies) { - if (!publishedPackages[depPkgName]) { - const depPkg = config.packages.find(a => a.name === depPkgName); - if (depPkg) { - publishPackage(depPkg); - // Come back. - shell.cd(pkg.dir); - } + const depPkg = config.packages.find(a => a.name === depPkgName); + if (depPkg && !publishedPackages[depPkgName]) { + publishPackage(depPkg); + // Come back. + shell.cd(pkg.dir); } shell.exec(`npm install`); - shell.exec(`npm install ${publishedPackages[depPkgName]} --no-save`); + + if (depPkg) { + console.log(chalk.gray(`Installing dependency ${depPkgName} from "${publishedPackages[depPkgName]}" ...`)); + shell.exec(`npm install ${publishedPackages[depPkgName]} --no-save`); + console.log(chalk.gray(`Install dependency ${depPkgName} done.`)); + } } } @@ -202,8 +205,9 @@ async function installPackages(config) { shell.cd(__dirname); for (let pkg of config.packages) { - console.log(chalk.gray(`Installing ${pkg.name}`)) - shell.exec(`npm install ${publishedPackages[pkg.name]}`); + console.log(chalk.gray(`Installing ${pkg.name} from "${publishedPackages[pkg.name]}" ...`)); + shell.exec(`npm install ${publishedPackages[pkg.name]} --no-save`); + console.log(chalk.gray(`Install ${pkg.name} done.`)); } // Come back. @@ -282,7 +286,14 @@ async function buildRunCode() { } const optionCode = await fse.readFile(fileName, 'utf-8'); - const option = JSON.parse(optionCode); + let option; + try { + option = JSON.parse(optionCode); + } + catch (err) { + console.error(`Parse JSON error: fileName: ${fileName} | fileContent: ${optionCode}`); + throw err; + } const testCode = await fse.readFile(nodePath.join( EXAMPLE_DIR, isGL ? 'data-gl' : 'data', testName + '.js' ), 'utf-8'); @@ -378,10 +389,16 @@ async function compileTs(tsTestFiles, result) { }; if (diagnostic.file.fileName.endsWith(`${MINIMAL_POSTFIX}.ts`)) { const basename = nodePath.basename(diagnostic.file.fileName, `.${MINIMAL_POSTFIX}.ts`); + if (!result[basename]) { + throw new Error(`${basename} does not exists in result.`); + } result[basename].compileErrors.minimal.push(compilerError); } else { - const basename = nodePath.basename(diagnostic.file.fileName, `.ts`); + const basename = nodePath.basename(diagnostic.file.fileName, `.ts`); + if (!result[basename]) { + throw new Error(`${basename} does not exists in result.`); + } result[basename].compileErrors.full.push(compilerError); } // console.log(chalk.red(`${diagnostic.file.fileName} (${line + 1},${character + 1})`)); @@ -699,7 +716,7 @@ async function main() { ); if (isNotSkipped('bundle')) { - console.log(`Bundling with ${USE_WEBPACK ? 'webpack' : 'esbuild'}`); + console.log(chalk.green(`Bundling with ${USE_WEBPACK ? 'webpack' : 'esbuild'}`)); const jsFiles = []; for (let testName of testNames) { jsFiles.push( @@ -715,7 +732,7 @@ async function main() { } if (isNotSkipped('render')) { - console.log('Running examples'); + console.log(chalk.green('Running examples')); const bundleFiles = []; for (let testName of testNames) { bundleFiles.push( @@ -731,7 +748,7 @@ async function main() { } if (isNotSkipped('compare')) { - console.log('Comparing Results'); + console.log(chalk.green('Comparing Results')); await compareExamples(testNames, result); } else { diff --git a/e2e/package.json b/e2e/package.json index fd0973e..bb44880 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -10,10 +10,5 @@ "author": "", "license": "ISC", "dependencies": { - "echarts": "file:../../echarts", - "echarts-gl": "file:tmp/echarts-gl-2.0.0-rc.3.tgz", - "echarts-liquidfill": "file:tmp/echarts-liquidfill-3.0.0.tgz", - "echarts-wordcloud": "file:tmp/echarts-wordcloud-2.0.0.tgz", - "zrender": "file:tmp/zrender-5.0.1.tgz" } } diff --git a/package.json b/package.json index 0b15f2e..ce8c190 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "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", + "test:e2e:local": "node e2e/main.js --bundler webpack -m --local", "test:e2e:esbuild": "node e2e/main.js --bundler esbuild -m", + "test:e2e:esbuild:local": "node e2e/main.js --bundler esbuild -m --local", "server": "node build/server.js" }, "devDependencies": { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org For additional commands, e-mail: commits-h...@echarts.apache.org