Unit tests for ionic


Are there any documentations somewhere for writing unit tests for ionic framework ?
I didn’t find such documentations and simply created angularjs unit test under test/unit folder in root folder, however when I run npm test on this folder nothing happens.
I tried to move test folder under www, but then running npm test in www folder fails since package.json file doesn’t exist in this folder.


All our components get tested before we make commits or when make a new component. As far as unit tests go, there are some articles out there that are for angular


But this a good idea for the devs to write about how to write some tests for ionic apps. I’ll get in touch with them and let them know.



Any idea why running “npm test” doesn’t produce any output ? Is it because it didn’t find any tests to execute ?


Any update on this. We are starting a project in Ionic and hence very much interested to know how to do unit testing our work


Yes. I was finally able to execute unit tests using karma.
It took me a while to configure it properly though.
I defined a test folder, inside this folder I defined conf.js project with the following definitions:

frameworks: ['jasmine'],

files: [

plugins: [

Your list of files may look a bit different, depend what are you dependencies.
Notice you need to install also the 2 plugins defined above.

Look for some tutorials, such as this one:


for more info.


I also had to install karma-cli plugin to use command line menu like init, start etc.


This thing was never communicated to core devs?


@mhartington Is there any reason why angular-mocks isn’t included in Ionic 1.0.0? It can be pulled in using bower, but hopefully everyone is writing unit tests for their applications so it seems odd not to included it.