mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 10:08:34 +00:00
chore: update testing script
This commit is contained in:
parent
3e17251662
commit
2eee76679f
4 changed files with 74 additions and 7 deletions
|
|
@ -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();
|
||||
|
|
|
|||
2
dev.md
2
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
|
||||
```
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
62
packages/board/examples/test/scale-004.html
Normal file
62
packages/board/examples/test/scale-004.html
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<html>
|
||||
<head>
|
||||
<style></style>
|
||||
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
|
||||
<style>
|
||||
html,body { margin: 0; padding: 0; }
|
||||
#mount canvas {
|
||||
border-right: 1px solid #aaaaaa40;
|
||||
border-bottom: 1px solid #aaaaaa40;
|
||||
background-image:
|
||||
linear-gradient(#aaaaaa40 1px, transparent 0),
|
||||
linear-gradient(90deg, #aaaaaa40 1px, transparent 0),
|
||||
linear-gradient(#aaa 1px, transparent 0),
|
||||
linear-gradient(90deg, #aaa 1px, transparent 0);
|
||||
background-size: 10px 10px, 10px 10px, 50px 50px, 50px 50px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="mount"></div>
|
||||
|
||||
<script src="./../../dist/index.global.js"></script>
|
||||
<script>
|
||||
const { Board } = window.iDraw;
|
||||
const mount = document.querySelector('#mount');
|
||||
const opts = {
|
||||
width: 600,
|
||||
height: 400,
|
||||
contextWidth: 800,
|
||||
contextHeight: 600,
|
||||
devicePixelRatio: 4
|
||||
}
|
||||
const board = new Board(mount, opts);
|
||||
|
||||
const ctx = board.getContext();
|
||||
|
||||
ctx.setFillStyle('#ffffff');
|
||||
ctx.fillRect(0, 0, opts.contextWidth, opts.contextHeight);
|
||||
|
||||
ctx.setFillStyle('#f0f0f0');
|
||||
ctx.fillRect(10, 10, 200, 120);
|
||||
|
||||
ctx.setFillStyle('#cccccc');
|
||||
ctx.fillRect(80, 80, 200, 120);
|
||||
|
||||
ctx.setFillStyle('#c0c0c0');
|
||||
ctx.fillRect(160, 160, 200, 120);
|
||||
|
||||
ctx.setFillStyle('#e0e0e0');
|
||||
ctx.fillRect(400 - 10, 300 - 10, 200, 100);
|
||||
|
||||
ctx.setFillStyle('#000');
|
||||
ctx.fillRect(400 - 10, 300 - 10, 20, 20);
|
||||
|
||||
board.scale(0.5);
|
||||
board.draw();
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue