4

I am currently in a project where I'm building charts using various libraries (d3 and nvd3 most of the time). I would like to build a set of automated tests and see if the data I'm feeding into the API I'm making is actually spitting out the data correctly.

How do you actually test charts? Is unit testing the right way to go for this, or is eyeballing the chart the only way to do this?

4

2 回答 2

0

您可以使用 PhantomJS 截取一些屏幕截图:https ://github.com/ariya/phantomjs/wiki/Screen-Capture

您还可以比较生成的 DOM 结构(这就是我在这个项目中所做的:https ://github.com/angular-d3/line-chart )

于 2013-07-31T12:24:30.953 回答
0

您可以使用 tape.js 编写特定于图表的单元测试

您也可以查看专门为测试图表而编写的这个库: https ://github.com/magiq-tests/magiq-tests

于 2019-11-22T05:18:12.463 回答