Skip to content

UNICEFLebanonInnovation/EquiTrackMobile

Repository files navigation

eTrips

Installation

Install required Cordova files:

$ sudo npm install -g cordova

Install required Ionic files:

$ sudo npm install -g ionic

Using git, clone to a local directory:

$ git clone https://github.com/unicef/eTools-eTrips

Install required development node.js packages:

$ npm install

Install Protractor testing framework:

$ sudo npm install -g protractor

Install Mocha for reporting and testing:

$ sudo npm install -g mocha

Install Bower for building:

$ npm install -g bower

Install required Ionic platforms:

$ mkdir www
$ ionic state reset

Install Bower components (and select latest version of Angular):

$ bower install

Update Selenium webdriver for integration tests:

$ ./node_modules/protractor/bin/webdriver-manager update

Build application and start Express server

$ gulp default --env [local/prod/test]

Optional: Integration tests can also be run using Docker

Build Application

To build and copy the application from a temporary to www folder (to run Ionic commands):

$ gulp build_www --env [local/prod/test]

Run Application

In a browser:

$ gulp serve --env [local/prod/test]

In a simulated device:

$ gulp --build [ios/android] --env [local/prod/test]
$ gulp --emulate [ios/android] --env [local/prod/test]

On an attached device

$ gulp --build [ios/android] --env [local/prod/test]
$ gulp --run [ios/android] --env [local/prod/test]

Run Integration Tests (local browser)

Start Selenium webdriver:

$ ./node_modules/protractor/bin/webdriver-manager start

In a separate terminal, start Ionic service:

$ gulp serve --env [local/prod/test]

Run protractor tests:

$ protractor tests/conf_dev.js

Optional: Run Integration Tests (Docker)

Start Docker Quickstart Terminal:

Applications => Docker => Docker Quickstart Terminal

Start Docker Selenium Grid (Chrome):

$ cd <eTrips directory>
$ gulp docker_selenium_start

Run protractor tests:

$ gulp protractor_docker

Access the Docker Selenium Grid image using VNC (optional):

$ gulp docker_selenium_vnc

Optional: Run Integration Tests (Android device)

Appium will be used to run the tests on an Android (non-emulator) device. Appium is an open source test automation framework for use with native, hybrid and mobile web apps. It drives iOS and Android apps using the WebDriver protocol.

To enable the tests to be run on the device:

  1. Connect the device to your local computer via USB
  2. Enable Android Debugging (Settings => Developer options => "Android Debugging")

Install Appium and WebDriver Protocol:

npm install -g appium
npm install -g wd

Update tests/conf_android.js to match the Android device values:

  capabilities: {
        platformName: 'android',
        platformVersion: '5.1.1',
        deviceName: 'oneplusone',
        browserName: "",
        autoWebview: true,
        app: '/Users/chris/unicef/eTrips/platforms/android/build/outputs/apk/android-debug.apk'
    },

Generate APK:

$ ionic build android

Start Appium:

$ appium

Run tests using Gulp:

gulp protractor_android