I'm currently developing an hybrid app using Ionic 2 (which is based on Angular 2). I'm using SQLite to store the data I need.
I've a service who reads and writes data into database.
I would like to unit test this service. I know how to run unit tests with Karma and Jasmine and inject services in it, but I'm a bit confused about the SQLite part.
I've written a DB service who connects to database and create the tables I need. I would like to test the functions firing the queries, test the format of data retrieved and some other functions using data retrieved from database.
So, should I mock functions executing the queries and test only the ones who process these data? Or is there a way to inject my DB service to get real queries executed?
BTW, as tests with Karma are ran into a browser, the Cordova SQLite plugin doesn't work so I need to mock SQLite somehow. I've read that we could use WebSQL instead to run the tests, but got no success so far.
My question isn't really about my particular code, it's more a general consideration about the best process to apply here.
Thanks for your inputs!
Aucun commentaire:
Enregistrer un commentaire