title: Ionic Couchbase Lite Karma Jasmine Unit Testing
body: <p>After some struggle, I successfully have jasmine tests running using karma, but I can't seem to find an answer to this question:</p>
  <h3>How can I run my jasmine tests on an actual device to test functions related couchbase lite database?</h3>
  <p>I am using this: <a href="https://github.com/couchbaselabs/ng-couchbase-lite" rel="noreferrer">https://github.com/couchbaselabs/ng-couchbase-lite</a></p>
  <p>This is my test:</p>
  <pre><code>     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();
          });  
      });
  </code></pre>
  <p>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.</p>
  <p>The setup config showing that it requires couchbase lite and cordova:</p>
  <pre><code>    var setupConfig = function() {
           console.log(&quot;set up config&quot;);
           var deferred = $q.defer();
  
           if(!window.cblite) { 
               deferred.reject('Couchbase Lite not installed');  
           } 
           else {
               cblite.getURL(function(err, url) {
                   console.log(&quot;cblite get url&quot;);
                   if(err) {
                       console.log(err);
                       deferred.reject(&quot;There was an error getting the database URL&quot;);  
                   }
                   else{
                       database = new $couchbase(url, appDbName);  
                       database.createDatabase().then(function(result) {
                           var views = setupViews();
                           database.createDesignDocument(&quot;_design/todo&quot;, 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;
       };
  </code></pre>