InterviewSolution
| 1. |
How to test Ionic Applications? |
|
Answer» Ionic application is developed using AngularJS. AngularJS has a collection of test libraries and frameworks such as Karma, Jasmine test runner, etc. Ionic uses these frameworks for testing of an application. Testing your app in a browser is as simple as running the server command. $ 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.
We can also test in the simulator using cordova commands. For eg: to test in IOS simulator, run:
We can also test the app directly in a mobile browser. For OS X users, Safari on OS X can debug websites and simulator applications. First, we have to enable the remote web inspector on both the device and Safari on the desktop. To do this with iOS 7 and OS X Mavericks, enable Web Inspector option in the iOS Settings -> Safari -> Advanced section, and also enable the Developer Menu in the Advanced section of Safari OS X settings. One problem 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 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 allows switching between open tabs. They 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 definitely not RECOMMENDED for more complex apps.
Since we are building a native app, we can test it. There are several ways to do this. If you are building for iOS devices, you’ll need to sign up for an Apple Developer account to test as a native app on an iPhone or iPad. Once you have an account and you need to have set up Xcode with your certificates to enable device testing, you’ll want to open the Xcode project from platforms/ios/ and do your testing from Xcode. Testing on Android is much easier and faster. To test on a device, simply plug it in and run. |
|