Skip to content

Test guidelines

Julian Descottes edited this page Aug 25, 2014 · 9 revisions

Piskel currently uses 2 testing solutions :

  • unit tests with Karma runner / Jasmine
  • drawing tests (integration tests for drawing tools) with a custom record/replay utility

We would also like to use Selenium for additional integration/ui testing. It seems for now Piskel is incompatible with Selenium (can't detect the page load event).

Unit tests

overview

Unit tests are written using the Jasmine testing framework : http://jasmine.github.io/. They are executed using Karma runner : http://karma-runner.github.io/. Please follow the installation guide at http://karma-runner.github.io/0.12/intro/installation.html .

conf

The configuration file for Karma can be found at the root of the project : /karma.conf.js.

Most importantly, this configuration defines which files are loaded to run the tests. All javascript files from src/js/**/*.js and test/js/**/*.js are loaded.

writing tests

New unit tests should be located under test/js and should respect the folder hierarchy of the class being tested. By convention, append Test to the filename :

  • /src/js/service/HistoryService.js
  • /test/js/service/HistoryServiceTest.js

running tests

By default, the tests are run against PhantomJS. You can start them using the grunt task grunt unit-test.

If you want to start the Karma test server and rerun the test on each file change you can use the following command : karma start karma.conf.js --log-level debug --no-single-run --auto-watch --browsers Chrome

Clone this wiki locally