Introduce a tests to automate testing as much as possible
Needs to
- Programatically test inputs/outputs of helper methods
- Test canvas image output of charts and diff them based on expected output
- Test chart edge cases - data extremes, sparse sets + awkward sizes.
Contributions / suggestions welcome for this!
Recommend Jasmine. Has a plugin for Gulp. Was planning on setting this up myself when I get a minute.
Yeah I'd been taking a look into that. Think that'd work nicely for testing out helper methods etc.
But with such a varied output - considering all the customisation options etc on charts, I'm not entirely sure the most efficient way to test those. I was thinking rendering as an image and diff-ing the output or something.
We could make a demo page that outputs each chart alongside the MD5 of the rendered PNG of that chart. Manually inspect them, hard-code the MD5s into the assertion for the test case for the respective render of each graph, Therefore, a failed test indicates something changed a graph from its prior verified state and requires review before publishing. Only problem is that if a new global default gets introduced that affects every graph, you have to redo all the hashes.
This could be semi-automated of course... the demo page could just be a visual inspection system and you click to confirm each render looks right and it writes the hash to a file which the test cases read from to verify that their rendered output matches-- otherwise it prompts you to review again... interesting but somewhat more involved...
The unit testing will be a good start anyway, much more straightforward.
For sure. Ideally I'd like to get some kind of testing in place before removing the -beta tag from the 1.0 release. I think starting with helper methods then moving onto public API methods in each chart type would be a good start.
I've been taking a look at http://humblesoftware.github.io/js-imagediff/index.html which looks like an interesting solution too. Could have a page that base64s an image on each animation frame and compares with a hard coded expected display.
Frame by frame would take some care in ensuring performance but I believe it's possible.
This weekend I'll get a chance to setup the initial test structure and start adding basic unit tests.
#519 just opened to begin addressing this.
@nnnick Would you mind assigning me to this issue so I can find it quicker? Thanks.
The v2.0 branch now has unit tests. Jasmine is the test framework with karma as the test runner. Istanbul is used for coverage analysis.