Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Moodle Mobile 2 (Ionic 1) End To End Testing

From MoodleDocs

Protractor is an end-to-end test framework for AngularJS applications. Protractor runs tests against your application running in a real browser, interacting with it as a user would.

Setting-up testing environment

This currently only covers testing on Android 4.4 onwards and Chrome. iOS testing is a work in progress.

  • Install Chromium browser for development
  • Install Node.js(Don’t use node 4.0 or higher, there are incompatibilities with some of the packages we use. Please use v0.12.7 instead)
  • Install ionic
    • npm cache clean
    • npm install -g cordova ionic
  • Clone the code base into a local directory in your computer
  • Head to the root directory of your MM instance.
  • Install the packages required for testing
    • npm install (do not use the -g option)
    • npm install -g bower
    • npm install -g gulp
  • Add the iOS and Android platforms and install the required Cordova plugins
    • ionic platform add android@4.1.1
    • ionic platform add ios@3.9.1
    • ionic state restore
  • Install bower globally and the required javascript files
    • bower install
  • Run gulp’s default tasks (in order to create the build files)
    • gulp
  • Open the app in the browser
    • ionic serve --browser chromium
  • Install the Chrome webdriver
    • ./node_modules/protractor/bin/webdriver-manager update
  • Make sure your checkout is up to date, all the cordova plugins are installed and the android platform is set-up. The following should be enough.
    • gulp
    • ionic state restore
    • ionic build android

Once this is done, you will need to generate a protactor configuration file for the platform you intend to test the app on.

Generating Protractor config file

Protractor config file contains all the information for running the tests, as well as to provide the tests with information about the site being tested.

  • For Android
    • gulp e2e-build --target android --device abcdefg --version 4.4
  • For Chrome
    • gulp e2e-build --target browser

Running the suite

  • Run the ionic first
    • ionic serve -b -a
  • Start the web driver
    • For Android: ./node_modules/appium/bin/appium.js
    • For Chrome : ./node_modules/protractor/bin/webdriver-manager start
  • Wait for the driver to be fully started
  • Run Protractor
    • moodlemobiledirectory/node_modules/protractor/bin/protractor ../../../e2e/build/protractor.conf.js