G2 5.0 测试重构
#4606
Replies: 2 comments 1 reply
-
|
playwright 和 node-canvas 属于是两套不一样的东西,node-canvas 是node端实现的 canvas,playwright 则包含了完整的浏览器。不过 playwright 确实可以完成 node-canvas 做的事情,唯一可能存在的不足也许是截图的分辨率也许会稍低一点。 另外的话,使用 playwright 需要在测试机上启动集成测试环境,不过这块问题应该不带,解决方案都有现成的。 |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
主要解决的问题:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
G2 5.0 测试重构
解决目前 G2 测试相关的问题。
存在问题
思路
对于集成测试而言,每一个图表需要真实的浏览器预览环境,以及能被多次快照断言。浏览器预览环境使用 Vite 搭建,多次快照断言使用 jest + 可以截图的环境(node-canvas,jsdom 或者 playwirte)。
所以每一个图表都对应一个集成测试,每一个集成测试包含两个东西:
其中渲染文件一方面给 vite 用于预览,一方面给测试文件用 jest 测试。渲染文件会暴露一个函数,改函数的函数签名如下:
目录结构
API
Spec
toMatchCanvasSnapshot
查看:https://jestjs.io/docs/26.x/expect#expectextendmatchers
TODO
Beta Was this translation helpful? Give feedback.
All reactions