Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Aviance School is one of the largest web solutions platform in India for developers to learn and share their programming knowledge and build their careers.
Testing your Ionic app
There are four ways to test your app as you develop:
1.Desktop browser testing
2.Simulator testing
3.Mobile browser testing
4.Testing as a native app
Testing your Ionic app
There are four ways to test your app as you develop:
Testing your app in a web browser is simple.Just type below command in your project’s root folder from the terminal.
$ ionic serve
This will start a live-reload server for your project. When changes are made to any HTML, CSS, or JavaScript files, the browser will automatically reload when the files are saved.
You can also test right in the simulator using the cordova commands. For example, to test in the android simulator, run:
$ ionic cordova build android
$ ionic cordova emulate android
If you want to get advanced, you can also open up the project file for a specific platform by opening the required Xcode or Android Eclipse project in platforms/PLATFORM inside the root of your project. Then, you can build and test from inside the platform-specific IDE. Note: if you go this route, I recommend still working inside of the root www folder, and when you’ve made changes to this folder, run the command:
$ ionic cordova prepare android
Which will update the android specific project with the code from the www folder. Note: this will overwrite any changes you’ve made to the platforms/android/www and other platform-specific folders.
You can also test the app directly in a mobile browser .Kindly use Chrome for remote debugging. If you are using the local server method from the Desktop testing section and you are on the same network as the desktop computer, you can connect to the ip address of the desktop computer to test. So, if our desktop is running a test server at 103.26.219.135:8000, we can just load that address into our mobile Chrome to test the project Or App.
One problem with testing in a mobile browser is that it’s probably the furthest of the three options from the actual app experience. This is largely because the browser app is meant for browsing websites, so it often adds functionality that conflicts with your app. For example, Chrome and Safari both listen for drag events on the sides of the app which let you switch between open tabs. They also have issues with the URL bars getting in the way, and some scrolling behavior is not the same as it is in the web view running in Cordova. It is fine for small tests, but not recommended for more complex apps.
Testing on Android is much easier and faster. To test on the device, simply plug it in, and run
$ ionic cordova run android
If this doesn’t work, make sure you have USB debugging enabled on your device.