Skip to content

Commit

Permalink
chore(travis): reorganize protractor configs to group by spec instead…
Browse files Browse the repository at this point in the history
… of by browser

Use the multiConfiguration ability of Protractor to start tests on multiple browsers
from the same travis cell. Group tests by type (jquery, jqlite, or docs tests) instead
of by browser. Turn on tests for jQuery.
  • Loading branch information
juliemr committed Feb 22, 2014
1 parent 1293cc8 commit 39c82f3
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 74 deletions.
9 changes: 3 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ branches:
env:
matrix:
- JOB=unit
- JOB=e2e BROWSER=chrome JQVERSION=jqlite
- JOB=e2e BROWSER=firefox JQVERSION=jqlite
# - JOB=e2e BROWSER=safari JQVERSION=jqlite
# - JOB=e2e BROWSER=chrome JQVERSION=jquery
# - JOB=e2e BROWSER=firefox JQVERSION=jquery
# - JOB=e2e BROWSER=safari JQVERSION=jquery
- JOB=e2e TEST_TARGET=jqlite
- JOB=e2e TEST_TARGET=jquery
- JOB=e2e TEST_TARGET=doce2e
global:
- SAUCE_USERNAME=angular-ci
- SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987
Expand Down
6 changes: 3 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = function(grunt) {

protractor: {
normal: 'protractor-conf.js',
jquery: 'protractor-jquery-conf.js',
travis: 'protractor-travis-conf.js',
jenkins: 'protractor-jenkins-conf.js'
},

Expand Down Expand Up @@ -293,8 +293,8 @@ module.exports = function(grunt) {
grunt.registerTask('test:docs', 'Run the doc-page tests with Karma', ['package'/*, 'tests:docs'*/]);
grunt.registerTask('test:unit', 'Run unit, jQuery and Karma module tests with Karma', ['tests:jqlite', 'tests:jquery', 'tests:modules']);
grunt.registerTask('test:protractor', 'Run the end to end tests with Protractor and keep a test server running in the background', ['webdriver', 'connect:testserver', 'protractor:normal']);
grunt.registerTask('test:jq-protractor', 'Run the end to end tests against jquery with Protractor and keep a test server running in the background', ['webdriver', 'connect:testserver', 'protractor:jquery']);
grunt.registerTask('test:ci-protractor', 'Run the end to end tests with Protractor and keep a test server running in the background', ['webdriver', 'connect:testserver', 'protractor:jenkins']);
grunt.registerTask('test:travis-protractor', 'Run the end to end tests with Protractor for Travis CI builds', ['connect:testserver', 'protractor:travis']);
grunt.registerTask('test:ci-protractor', 'Run the end to end tests with Protractor for Jenkins CI builds', ['webdriver', 'connect:testserver', 'protractor:jenkins']);
grunt.registerTask('test:e2e', 'Alias for test:protractor', ['test:protractor']);
grunt.registerTask('test:promises-aplus',['build:promises-aplus-adapter','shell:promises-aplus-tests']);

Expand Down
39 changes: 23 additions & 16 deletions docs/config/processors/protractor-generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ var trimIndentation = require('dgeni/lib/utils/trim-indentation');
var code = require('dgeni/lib/utils/code');
var protractorFolder;

function createProtractorDoc(example, file, env) {
var protractorDoc = {
docType: 'e2e-test',
id: 'protractorTest' + '-' + example.id,
template: 'protractorTests.template.js',
outputPath: path.join(protractorFolder, example.id, env + '_test.js'),
innerTest: file.fileContents,
pathPrefix: '.', // Hold for if we test with full jQuery
exampleId: example.id,
description: example.doc.id
};

if (env === 'jquery') {
protractorDoc.examplePath = example.outputFolder + '/index-jquery.html'
} else {
protractorDoc.examplePath = example.outputFolder + '/index.html'
}
return protractorDoc;
}

module.exports = {
name: 'protractor-generate',
description: 'Generate a protractor test file from the e2e tests in the examples',
Expand All @@ -23,22 +43,9 @@ module.exports = {
return;
}

// Create a new file for the test.
// TODO - at the moment, only jqLite is being used. Will need to generate
// another doc for jQuery if we want to test against that.
var protractorDoc = {
docType: 'e2e-test',
id: 'protractorTest' + '-' + example.id,
template: 'protractorTests.template.js',
outputPath: path.join(protractorFolder, example.id, 'jqlite' + '_test.js'),
innerTest: file.fileContents,
pathPrefix: '.', // Hold for if we test with full jQuery
exampleId: example.id,
description: example.doc.id,
examplePath: example.outputFolder + '/index.html'
};

docs.push(protractorDoc);
// Create new files for the tests.
docs.push(createProtractorDoc(example, file, 'jquery'));
docs.push(createProtractorDoc(example, file, 'jqlite'));
});
});
}
Expand Down
3 changes: 2 additions & 1 deletion lib/grunt/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,15 @@ module.exports = {
var tunnelIdentifier = grunt.option('capabilities.tunnel-identifier');
var sauceBuild = grunt.option('capabilities.build');
var browser = grunt.option('browser');
var specs = grunt.option('specs');
var args = ['node_modules/protractor/bin/protractor', config];
if (sauceUser) args.push('--sauceUser=' + sauceUser);
if (sauceKey) args.push('--sauceKey=' + sauceKey);
if (tunnelIdentifier) args.push('--capabilities.tunnel-identifier=' + tunnelIdentifier);
if (sauceBuild) args.push('--capabilities.build=' + sauceBuild);
if (specs) args.push('--specs=' + specs);
if (browser) {
args.push('--browser=' + browser);
args.push('--params.browser=' + browser);
}


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"karma-sauce-launcher": "0.2.0",
"karma-script-launcher": "0.1.0",
"karma-browserstack-launcher": "0.0.7",
"protractor": "~0.18.0",
"protractor": "~0.19.0",
"yaml-js": "~0.0.8",
"rewire": "1.1.3",
"promises-aplus-tests": "~1.3.2",
Expand Down
38 changes: 9 additions & 29 deletions protractor-conf.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
exports.config = {
allScriptsTimeout: 11000,
var config = require('./protractor-shared-conf').config;

specs: [
'build/docs/ptore2e/**/*jqlite_test.js',
'test/e2e/docsAppE2E.js'
],
config.specs = [
'build/docs/ptore2e/**/*.js',
'test/e2e/docsAppE2E.js'
];

capabilities: {
'browserName': 'chrome',
'name': 'Angular E2E: jqlite'
},

baseUrl: 'http://localhost:8000/build/docs/',

framework: 'jasmine',

onPrepare: function() {
// Disable animations so e2e tests run more quickly
var disableNgAnimate = function() {
angular.module('disableNgAnimate', []).run(function($animate) {
$animate.enabled(false);
});
};

browser.addMockModule('disableNgAnimate', disableNgAnimate);
},

jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
config.capabilities = {
browserName: 'chrome',
};

exports.config = config;
15 changes: 5 additions & 10 deletions protractor-jquery-conf.js → protractor-shared-conf.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
exports.config = {
allScriptsTimeout: 11000,

specs: [
'build/docs/ptore2e/**/*jquery_test.js',
'test/e2e/docsAppE2E.js'
],

capabilities: {
'browserName': 'chrome',
'name': 'Angular E2E: jquery'
},

baseUrl: 'http://localhost:8000/build/docs/',

framework: 'jasmine',
Expand All @@ -24,6 +14,11 @@ exports.config = {
};

browser.addMockModule('disableNgAnimate', disableNgAnimate);

// Store the name of the browser that's currently being used.
browser.getCapabilities().then(function(caps) {
browser.params.browser = caps.get('browserName');
});
},

jasmineNodeOpts: {
Expand Down
25 changes: 25 additions & 0 deletions protractor-travis-conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var config = require('./protractor-shared-conf').config;

config.sauceUser = process.env.SAUCE_USERNAME;
config.sauceKey = process.env.SAUCE_ACCESS_KEY;

config.multiCapabilities = [{
'browserName': 'chrome',
'name': 'Angular E2E',
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
'build': process.env.TRAVIS_BUILD_NUMBER
}, {
'browserName': 'firefox',
'name': 'Angular E2E',
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
'build': process.env.TRAVIS_BUILD_NUMBER
}, {
browserName: 'safari',
'platform': 'OS X 10.9',
'version': '7',
'name': 'Angular E2E',
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
'build': process.env.TRAVIS_BUILD_NUMBER
}];

exports.config = config;
14 changes: 6 additions & 8 deletions scripts/travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ if [ $JOB = "unit" ]; then
grunt test:promises-aplus
grunt test:unit --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_8,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
elif [ $JOB = "e2e" ]; then
export GRUNT_TARGET="test:protractor"
if [ $JQVERSION = "jquery" ]; then
GRUNT_TARGET="test:jq-protractor"
export TARGET_SPECS="build/docs/ptore2e/**/*jqlite_test.js"
if [ $TEST_TARGET = "jquery" ]; then
TARGET_SPECS="build/docs/ptore2e/**/*jquery_test.js"
elif [ $TEST_TARGET = "doce2e" ]; then
TARGET_SPECS="test/e2e/docsAppE2E.js"
fi
grunt $GRUNT_TARGET --sauceUser $SAUCE_USERNAME \
--sauceKey $SAUCE_ACCESS_KEY \
--capabilities.tunnel-identifier=$TRAVIS_JOB_NUMBER \
--capabilities.build=$TRAVIS_BUILD_NUMBER \
--browser=$BROWSER
grunt test:travis-protractor --specs "$TARGET_SPECS"
else
echo "Unknown job type. Please set JOB=unit or JOB=e2e-*."
fi

0 comments on commit 39c82f3

Please sign in to comment.