From 39c82f3fb7a8459304d5e07dc87bd0623ad1efd0 Mon Sep 17 00:00:00 2001 From: Julie Date: Wed, 19 Feb 2014 21:01:54 -0800 Subject: [PATCH] chore(travis): reorganize protractor configs to group by spec instead 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. --- .travis.yml | 9 ++--- Gruntfile.js | 6 +-- docs/config/processors/protractor-generate.js | 39 +++++++++++-------- lib/grunt/utils.js | 3 +- package.json | 2 +- protractor-conf.js | 38 +++++------------- ...query-conf.js => protractor-shared-conf.js | 15 +++---- protractor-travis-conf.js | 25 ++++++++++++ scripts/travis/build.sh | 14 +++---- 9 files changed, 77 insertions(+), 74 deletions(-) rename protractor-jquery-conf.js => protractor-shared-conf.js (73%) create mode 100644 protractor-travis-conf.js diff --git a/.travis.yml b/.travis.yml index d22001fc90ef..bf0814588737 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Gruntfile.js b/Gruntfile.js index 74ddd1eb9d03..a5a611ec1907 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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' }, @@ -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']); diff --git a/docs/config/processors/protractor-generate.js b/docs/config/processors/protractor-generate.js index 39c792126442..100202b43600 100644 --- a/docs/config/processors/protractor-generate.js +++ b/docs/config/processors/protractor-generate.js @@ -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', @@ -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')); }); }); } diff --git a/lib/grunt/utils.js b/lib/grunt/utils.js index 1c356c18887e..b9affd822601 100644 --- a/lib/grunt/utils.js +++ b/lib/grunt/utils.js @@ -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); } diff --git a/package.json b/package.json index a36fb83f95d2..cf7b9d927db6 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/protractor-conf.js b/protractor-conf.js index c21ee68f36eb..9c937c843432 100644 --- a/protractor-conf.js +++ b/protractor-conf.js @@ -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; diff --git a/protractor-jquery-conf.js b/protractor-shared-conf.js similarity index 73% rename from protractor-jquery-conf.js rename to protractor-shared-conf.js index 6b93994b7206..147bb00676f9 100644 --- a/protractor-jquery-conf.js +++ b/protractor-shared-conf.js @@ -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', @@ -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: { diff --git a/protractor-travis-conf.js b/protractor-travis-conf.js new file mode 100644 index 000000000000..d2d6c21f2bdb --- /dev/null +++ b/protractor-travis-conf.js @@ -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; diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index 9a0d268fff7b..34422648e871 100755 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -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