Ionic Framework SQLite testing with browser

2019-05-09 23:42发布

问题:

I followed this tutorial.

How can I test SQLite plugin and dbCopy with ionic serve on web browser?

I found this:

if(window.cordova) {
      // App syntax
      db = $cordovaSQLite.openDB("myapp.db");
    } else {
      // Ionic serve syntax
      db = window.openDatabase("myapp.db", "1.0", "My app", -1);
    }

But it is just for OpenDB but not for copyDB.

My developing environment is just Netbook.

So It has no KVM and it is difficult to install android studio. So I wish to test on web browser.

回答1:

We recently wrote a blog article about how to do integration tests of ionic. You might want to use node express to run the ionic app you're testing as it works better on ci's such as circleci. Try have a look at http://www.dovetaildigital.io/blog/2015/10/28/rails-and-ionic-make-love-part-three and let me know if you have any problems with it.



回答2:

You can compile your code using

>ionic build android

and then send the .apk file to your mobile phone.

Another option is to use genymotion .

PS: Does db = window.openDatabase("myapp.db", "1.0", "My app", -1); works in the browser?