Recently, I have been struggling with setting up some continuous development servers for my cordova-plugin-geofence. I had been already using Travis to kick off tests in iOS environment for some time, but android also had been screaming for attention long enough. I decided to go for Circle CI as my android tests savior. Anyway, not everything went so smooth, that’s why I’ve felt compelled to share my solution with you guys.
Testing Cordova plugin
What I want to say at first place is that testing Cordova plugin is not so trivial. Especially if you have to support many versions of various operating systems. It is impossible to test on every device and every system, but it is necessary to have something at least. What I needed was a nice green badge in my github readme file which will tell people straight up that the plugin should work fine. Another thing was the ability to have a quick glance on new pull requests if they are not breaking anything. I’ve been testing using cordova-plugin-test-framework for some time and I think this is a good solution if you don’t want to write tests using native platform language. It allows you to write some functional tests with the use of jasmine and also a manual set of tests. Testing Cordova plugins could be a topic for a new blog post. I want to concentrate mostly on CI here.
All you have to do to start using Circle CI is: register, hook up with your github account and set up circle.yml config file in your repository. Sounds like a piece of cake, and if you have been using Travis before, the configuration is very similar.
I had found some Cordova plugins which were using Circle CI and I was trying to just
quickly adjust configuration for my needs. After experimenting I came up with
circle.ymlfile like this:
I would like to notice a few things here:
- I don’t like to install npm packages globally, I always want to get the right version of
package specified in
packages.jsonthat’s why I’ve extended
- My plugin is using Google Play Services. On Circle CI there is no preinstalled avd along with Google Play Services, in that case you should install needed sdk and add new avd by yourself.
Then just kick off your avd in emulator
- I am running tests using cordova-paramedic and as I said before, “how to test” - that’s the topic for a separate post.
That’s it! Happy testing.