After some struggle, I successfully have jasmine tests running using karma, but I can't seem to find an answer to this question:
How can I run my jasmine tests on an actual device to test functions related couchbase lite database?
I am using this: https://github.com/couchbaselabs/ng-couchbase-lite
This is my test:
describe('SetupService tests', function() {
it('SetupService should instantiate', function() {
expect(SetupService).toBeDefined();
});
it('it should instantiate database', function() {
var database = null;
SetupService.setupConfig();
expect(database).not.toBeNull();
});
});
So I need to run the tests on an actual device so the db can successfully be created. I am new to unit testing and currently only using karam cli.
The setup config showing that it requires couchbase lite and cordova:
var setupConfig = function() {
console.log("set up config");
var deferred = $q.defer();
if(!window.cblite) {
deferred.reject('Couchbase Lite not installed');
}
else {
cblite.getURL(function(err, url) {
console.log("cblite get url");
if(err) {
console.log(err);
deferred.reject("There was an error getting the database URL");
}
else{
database = new $couchbase(url, appDbName);
database.createDatabase().then(function(result) {
var views = setupViews();
database.createDesignDocument("_design/todo", views);
database.listen();
deferred.resolve(true);
}, function(error) {
// we will not reject this err, as it is caused when a db already exists
// so it will happen everytime
deferred.resolve(err);
});
}
});
}
return deferred.promise;
};