Permalink
Browse files

chore(testing): update end to end tests to Protractor

  • Loading branch information...
1 parent 0e8516a commit 69c9416c8407fd5806aab3c63916dfcf0522ecbc @juliemr juliemr committed Jan 31, 2014
View
@@ -6,9 +6,11 @@ before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm install --quiet -g karma
+ - npm install --quiet -g protractor
- ./scripts/web-server.js > /dev/null &
- sleep 1 # give server time to start
script:
- karma start config/karma.conf.js --no-auto-watch --single-run --reporters=dots --browsers=Firefox
- - karma start config/karma-e2e.conf.js --reporters=dots --browsers=Firefox
+ - webdriver-manager update
+ - protractor config/protractor-conf.js --browser=firefox
View
@@ -66,21 +66,16 @@ or remote browser.
### End to end testing
-Angular ships with a baked-in end-to-end test runner that understands angular, your app and allows
-you to write your tests with jasmine-like BDD syntax.
+We recommend using [protractor](https://github.com/angular/protractor) for end-to-end tests. It
+uses native events and has special features for Angular applications.
Requires a webserver, node.js + `./scripts/web-server.js` or your backend server that hosts the angular static files.
-Check out the
-[end-to-end runner's documentation](http://docs.angularjs.org/guide/dev_guide.e2e-testing) for more
-info.
-
* create your end-to-end tests in `test/e2e/scenarios.js`
* serve your project directory with your http/backend server or node.js + `scripts/web-server.js`
-* to run do one of:
- * open `http://localhost:port/test/e2e/runner.html` in your browser
- * run the tests from console with [Karma](http://karma-runner.github.io) via
- `scripts/e2e-test.sh` or `script/e2e-test.bat`
+* to run:
+ * run the tests from console with [Protractor](https://github.com/angular/protractor) via
+ `scripts/e2e-test.sh` (on windows: `scripts\e2e-test.bat`)
### Continuous Integration
@@ -122,7 +117,7 @@ fetch the changes and merge them into your project with git.
partial2.html
config/karma.conf.js --> config file for running unit tests with Karma
- config/karma-e2e.conf.js --> config file for running e2e tests with Karma
+ config/protractor-conf.js --> config file for running e2e tests with Protractor
scripts/ --> handy shell/js/ruby scripts
e2e-test.sh --> runs end-to-end tests with Karma (*nix)
@@ -133,7 +128,6 @@ fetch the changes and merge them into your project with git.
test/ --> test source files and libraries
e2e/ -->
- runner.html --> end-to-end test runner (open in your browser to run)
scenarios.js --> end-to-end specs
lib/
angular/ --> angular testing libraries
View
@@ -16,7 +16,7 @@
<div>Angular seed app: v<span app-version></span></div>
<!-- In production use:
- <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
+ <script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<script src="lib/angular/angular.js"></script>
<script src="lib/angular/angular-route.js"></script>
@@ -1,37 +0,0 @@
-module.exports = function(config){
- config.set({
-
-
- basePath : '../',
-
- files : [
- 'test/e2e/**/*.js'
- ],
-
- autoWatch : false,
-
- browsers : ['Chrome'],
-
- frameworks: ['ng-scenario'],
-
- singleRun : true,
-
- proxies : {
- '/': 'http://localhost:8000/'
- },
-
- plugins : [
- 'karma-junit-reporter',
- 'karma-chrome-launcher',
- 'karma-firefox-launcher',
- 'karma-jasmine',
- 'karma-ng-scenario'
- ],
-
- junitReporter : {
- outputFile: 'test_out/e2e.xml',
- suite: 'e2e'
- }
-
-})}
-
@@ -0,0 +1,19 @@
+exports.config = {
+ allScriptsTimeout: 11000,
+
+ specs: [
+ '../test/e2e/*.js'
+ ],
+
+ capabilities: {
+ 'browserName': 'chrome'
+ },
+
+ baseUrl: 'http://localhost:8000/app/',
+
+ framework: 'jasmine',
+
+ jasmineNodeOpts: {
+ defaultTimeoutInterval: 30000
+ }
+};
View
@@ -7,6 +7,6 @@
"karma" : "~0.10",
"karma-junit-reporter" : "~0.1",
"karma-jasmine" : "~0.1",
- "karma-ng-scenario" : "~0.1"
+ "protractor" : "~0.17.0"
}
}
@@ -1,11 +1,12 @@
@echo off
REM Windows script for running e2e tests
-REM You have to run server and capture some browser first
+REM You have to run server first
REM
REM Requirements:
REM - NodeJS (http://nodejs.org/)
-REM - Karma (npm install -g karma)
+REM - Protractor (npm install -g protractor)
set BASE_DIR=%~dp0
-karma start "%BASE_DIR%\..\config\karma-e2e.conf.js" %*
+webdriver-manager update
+protractor "%BASE_DIR%\..\config\protractor-conf.js" %*
View
@@ -3,8 +3,16 @@
BASE_DIR=`dirname $0`
echo ""
-echo "Starting Karma Server (http://karma-runner.github.io)"
+echo "Updating WebDriver"
echo $BASE_DIR
echo "-------------------------------------------------------------------"
-$BASE_DIR/../node_modules/karma/bin/karma start $BASE_DIR/../config/karma-e2e.conf.js $*
+$BASE_DIR/../node_modules/protractor/bin/webdriver-manager update
+
+
+echo ""
+echo "Starting Protractor tests"
+echo $BASE_DIR
+echo "-------------------------------------------------------------------"
+
+$BASE_DIR/../node_modules/protractor/bin/protractor $BASE_DIR/../config/protractor-conf.js $*
@@ -17,7 +17,6 @@ cp -r $NG_BUILD_DIR/* app/lib/angular
rm -fr app/lib/angular/docs
rm app/lib/angular/*.zip
mv app/lib/angular/angular-mocks.js test/lib/angular
-mv app/lib/angular/angular-scenario.js test/lib/angular
cp app/lib/angular/version.txt test/lib/angular
# Update the inlined angular-loader in app/index-async.html
View
@@ -1,11 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <title>End2end Test Runner</title>
- <meta charset="utf-8">
- <script src="../lib/angular/angular-scenario.js" ng-autotest></script>
- <script src="scenarios.js"></script>
- </head>
- <body>
- </body>
-</html>
View
@@ -1,28 +1,25 @@
'use strict';
-/* http://docs.angularjs.org/guide/dev_guide.e2e-testing */
+/* https://github.com/angular/protractor/blob/master/docs/getting-started.md */
describe('my app', function() {
- beforeEach(function() {
- browser().navigateTo('app/index.html');
- });
-
+ browser.get('index.html');
it('should automatically redirect to /view1 when location hash/fragment is empty', function() {
- expect(browser().location().url()).toBe("/view1");
+ expect(browser.getLocationAbsUrl()).toMatch("/view1");
});
describe('view1', function() {
beforeEach(function() {
- browser().navigateTo('#/view1');
+ browser.get('index.html#/view1');
});
it('should render view1 when user navigates to /view1', function() {
- expect(element('[ng-view] p:first').text()).
+ expect(element.all(by.css('[ng-view] p')).first().getText()).
toMatch(/partial for view 1/);
});
@@ -32,12 +29,12 @@ describe('my app', function() {
describe('view2', function() {
beforeEach(function() {
- browser().navigateTo('#/view2');
+ browser.get('index.html#/view2');
});
it('should render view2 when user navigates to /view2', function() {
- expect(element('[ng-view] p:first').text()).
+ expect(element.all(by.css('[ng-view] p')).first().getText()).
toMatch(/partial for view 2/);
});
Oops, something went wrong.

0 comments on commit 69c9416

Please sign in to comment.