Skip to content

Instantly share code, notes, and snippets.

@psahni
Last active August 29, 2015 14:04
Show Gist options
  • Save psahni/e5645030f4cd1d87a3f5 to your computer and use it in GitHub Desktop.
Save psahni/e5645030f4cd1d87a3f5 to your computer and use it in GitHub Desktop.
Integration (End 2 End) Testing of Angular apps.

Definitions:-

  • Jasmine - Used for BDD
  • PhantomJs - A headless browser. Which helps in testing javascript, can access to dom. Jasmine is used on the top of it.
  • Karma - A testing framework for Angular js that uses PhantomJs, jasminejs
  • Protactor - Protractor is an end to end testing framework for AngularJS applications. It uses webdriver to control browser activities, it runs on the top of Selenium because it is based on webdriver protocols. Protractor uses Jasmine for its test syntax. So its a nice wrapper over selenium and jasmine.

E2E Testing

For E2E testing there are two frameworks

  • Angular Scenario
  • Protractor

  • But Angular Scenario is deprecated as i found on angular documentation, and official site recommends protactor.

##Installation

  1. Install Node Js (We need node and node package manager)
  2. Install Protactor as a node module npm install -g protractor
  3. Update webdriver-manager sudo webdriver-manager update

Getting Started

  1. Make a protractor configuration file Example
exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',

  capabilities: {
    'browserName': 'chrome'
  },

  specs: ['./test/e2e/**/*.spec.js'],

  jasmineNodeOpts: {
    showColors: true
  }
}
  1. Write some test case and put it inside test/e2e/ Read this ref: https://github.com/daniellmb/angular-test-patterns/blob/master/patterns/e2e.md#end-to-end-testing-angularjs

  2. Start the webdriver manager webdriver-manager start

  3. Execute through protractor protractor protractor-conf.js`

Issues

  1. Chrome version issue http://lostechies.com/gabrielschenker/2014/04/18/angular-jspart-14-end-to-end-tests/

  2. Error: Invalid or corrupt jarfile selenium webdriver-manager

sudo rm /usr/lib/node_modules/protractor/selenium/selenium-server-standalone-2.42.2.jar

sudo touch /usr/lib/node_modules/protractor/selenium/selenium-server-standalone-2.42.2.jar

sudo curl http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar -o /usr/lib/node_modules/protractor/selenium/selenium-server-standalone-2.42.2.jar

Useful Resources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment