From 2eee76679f88c5780c58931956ed4aa68432d6c2 Mon Sep 17 00:00:00 2001 From: chenshenhai Date: Thu, 10 Jun 2021 12:02:08 +0800 Subject: [PATCH] chore: update testing script --- __tests__/e2e.test.js | 14 +++-- dev.md | 2 +- package.json | 3 +- packages/board/examples/test/scale-004.html | 62 +++++++++++++++++++++ 4 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 packages/board/examples/test/scale-004.html diff --git a/__tests__/e2e.test.js b/__tests__/e2e.test.js index e0f5d65..839f96e 100644 --- a/__tests__/e2e.test.js +++ b/__tests__/e2e.test.js @@ -20,7 +20,7 @@ async function diff() { const { page, port } = ctx; const width = p.w; const height = p.h; - console.log(`[${i+1}/${pageList.length}] E2E Testing: ${p.path}`) + await page.setViewport( { width: p.w, height: p.h } ); const pageUrl = `http://127.0.0.1:${port}/packages/${p.path || ''}`; await page.goto(pageUrl); @@ -36,7 +36,11 @@ async function diff() { if (failRate > 0) { (await jimp.read(diffBuf)).scale(1).quality(100).write(parsePicPath(path.join(diffDir, p.path))); } - diffRateList.push(failRate); + diffRateList.push({ + path: p.path, + rate: failRate, + }); + console.log(`[${i+1}/${pageList.length}] E2E Testing: ${p.path} | diff: ${failRate}`) await next(); }); }); @@ -59,9 +63,9 @@ describe('Screenshot testing', function() { assert.ok(Array.isArray(rateList)); assert.ok(rateList.length > 0); - rateList.forEach((rate) => { - console.log('diff-rate =', rate); - assert.ok(rate < 0.05); + rateList.forEach((data) => { + // console.log(`${data.path}]diff-rate: ${data.rate}`, ); + assert.ok(data.rate < 0.05); }); done(); diff --git a/dev.md b/dev.md index 796f38f..c010d3f 100644 --- a/dev.md +++ b/dev.md @@ -5,5 +5,5 @@ lerna add @idraw/util --scope=@idraw/core ``` ```sh -lerna publish --force-publish +npm run build && lerna publish --force-publish ``` \ No newline at end of file diff --git a/package.json b/package.json index 10969ff..827bb1a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "lint": "eslint --fix --ext .ts packages/*/src/**", "precommit": "npm run lint", "prepush": "npm run lint", - "clear:jest": "rm -rf ./packages/*/__tests__/__snapshots__" + "clear:jest": "rm -rf ./packages/*/__tests__/__snapshots__", + "pu": "npm run build && lerna publish --force-publish" }, "devDependencies": { "@babel/core": "^7.13.14", diff --git a/packages/board/examples/test/scale-004.html b/packages/board/examples/test/scale-004.html new file mode 100644 index 0000000..f3c47f6 --- /dev/null +++ b/packages/board/examples/test/scale-004.html @@ -0,0 +1,62 @@ + + + + + + + + +
+ + + + + + \ No newline at end of file