-
Notifications
You must be signed in to change notification settings - Fork 785
Test Guidelines : Unit tests
overview
Piskel unit tests rely on :
- Jasmine testing framework : http://jasmine.github.io/.
- Karma runner : http://karma-runner.github.io/.
Please follow the installation guide at http://karma-runner.github.io/0.12/intro/installation.html to install karma-cli as a global before going further.
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. As for the normal applications, the load order for files in src/js is defined in src/piskel-script-list.js
.
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
New tests are automatically picked up by the tester, no need to declare them in a test suite.
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