Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 39c82f3

Browse files
committed
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.
1 parent 1293cc8 commit 39c82f3

9 files changed

+77
-74
lines changed

.travis.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ branches:
99
env:
1010
matrix:
1111
- JOB=unit
12-
- JOB=e2e BROWSER=chrome JQVERSION=jqlite
13-
- JOB=e2e BROWSER=firefox JQVERSION=jqlite
14-
# - JOB=e2e BROWSER=safari JQVERSION=jqlite
15-
# - JOB=e2e BROWSER=chrome JQVERSION=jquery
16-
# - JOB=e2e BROWSER=firefox JQVERSION=jquery
17-
# - JOB=e2e BROWSER=safari JQVERSION=jquery
12+
- JOB=e2e TEST_TARGET=jqlite
13+
- JOB=e2e TEST_TARGET=jquery
14+
- JOB=e2e TEST_TARGET=doce2e
1815
global:
1916
- SAUCE_USERNAME=angular-ci
2017
- SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987

Gruntfile.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ module.exports = function(grunt) {
9292

9393
protractor: {
9494
normal: 'protractor-conf.js',
95-
jquery: 'protractor-jquery-conf.js',
95+
travis: 'protractor-travis-conf.js',
9696
jenkins: 'protractor-jenkins-conf.js'
9797
},
9898

@@ -293,8 +293,8 @@ module.exports = function(grunt) {
293293
grunt.registerTask('test:docs', 'Run the doc-page tests with Karma', ['package'/*, 'tests:docs'*/]);
294294
grunt.registerTask('test:unit', 'Run unit, jQuery and Karma module tests with Karma', ['tests:jqlite', 'tests:jquery', 'tests:modules']);
295295
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']);
296-
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']);
297-
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']);
296+
grunt.registerTask('test:travis-protractor', 'Run the end to end tests with Protractor for Travis CI builds', ['connect:testserver', 'protractor:travis']);
297+
grunt.registerTask('test:ci-protractor', 'Run the end to end tests with Protractor for Jenkins CI builds', ['webdriver', 'connect:testserver', 'protractor:jenkins']);
298298
grunt.registerTask('test:e2e', 'Alias for test:protractor', ['test:protractor']);
299299
grunt.registerTask('test:promises-aplus',['build:promises-aplus-adapter','shell:promises-aplus-tests']);
300300

docs/config/processors/protractor-generate.js

+23-16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ var trimIndentation = require('dgeni/lib/utils/trim-indentation');
55
var code = require('dgeni/lib/utils/code');
66
var protractorFolder;
77

8+
function createProtractorDoc(example, file, env) {
9+
var protractorDoc = {
10+
docType: 'e2e-test',
11+
id: 'protractorTest' + '-' + example.id,
12+
template: 'protractorTests.template.js',
13+
outputPath: path.join(protractorFolder, example.id, env + '_test.js'),
14+
innerTest: file.fileContents,
15+
pathPrefix: '.', // Hold for if we test with full jQuery
16+
exampleId: example.id,
17+
description: example.doc.id
18+
};
19+
20+
if (env === 'jquery') {
21+
protractorDoc.examplePath = example.outputFolder + '/index-jquery.html'
22+
} else {
23+
protractorDoc.examplePath = example.outputFolder + '/index.html'
24+
}
25+
return protractorDoc;
26+
}
27+
828
module.exports = {
929
name: 'protractor-generate',
1030
description: 'Generate a protractor test file from the e2e tests in the examples',
@@ -23,22 +43,9 @@ module.exports = {
2343
return;
2444
}
2545

26-
// Create a new file for the test.
27-
// TODO - at the moment, only jqLite is being used. Will need to generate
28-
// another doc for jQuery if we want to test against that.
29-
var protractorDoc = {
30-
docType: 'e2e-test',
31-
id: 'protractorTest' + '-' + example.id,
32-
template: 'protractorTests.template.js',
33-
outputPath: path.join(protractorFolder, example.id, 'jqlite' + '_test.js'),
34-
innerTest: file.fileContents,
35-
pathPrefix: '.', // Hold for if we test with full jQuery
36-
exampleId: example.id,
37-
description: example.doc.id,
38-
examplePath: example.outputFolder + '/index.html'
39-
};
40-
41-
docs.push(protractorDoc);
46+
// Create new files for the tests.
47+
docs.push(createProtractorDoc(example, file, 'jquery'));
48+
docs.push(createProtractorDoc(example, file, 'jqlite'));
4249
});
4350
});
4451
}

lib/grunt/utils.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,15 @@ module.exports = {
247247
var tunnelIdentifier = grunt.option('capabilities.tunnel-identifier');
248248
var sauceBuild = grunt.option('capabilities.build');
249249
var browser = grunt.option('browser');
250+
var specs = grunt.option('specs');
250251
var args = ['node_modules/protractor/bin/protractor', config];
251252
if (sauceUser) args.push('--sauceUser=' + sauceUser);
252253
if (sauceKey) args.push('--sauceKey=' + sauceKey);
253254
if (tunnelIdentifier) args.push('--capabilities.tunnel-identifier=' + tunnelIdentifier);
254255
if (sauceBuild) args.push('--capabilities.build=' + sauceBuild);
256+
if (specs) args.push('--specs=' + specs);
255257
if (browser) {
256258
args.push('--browser=' + browser);
257-
args.push('--params.browser=' + browser);
258259
}
259260

260261

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"karma-sauce-launcher": "0.2.0",
3737
"karma-script-launcher": "0.1.0",
3838
"karma-browserstack-launcher": "0.0.7",
39-
"protractor": "~0.18.0",
39+
"protractor": "~0.19.0",
4040
"yaml-js": "~0.0.8",
4141
"rewire": "1.1.3",
4242
"promises-aplus-tests": "~1.3.2",

protractor-conf.js

+9-29
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,12 @@
1-
exports.config = {
2-
allScriptsTimeout: 11000,
1+
var config = require('./protractor-shared-conf').config;
32

4-
specs: [
5-
'build/docs/ptore2e/**/*jqlite_test.js',
6-
'test/e2e/docsAppE2E.js'
7-
],
3+
config.specs = [
4+
'build/docs/ptore2e/**/*.js',
5+
'test/e2e/docsAppE2E.js'
6+
];
87

9-
capabilities: {
10-
'browserName': 'chrome',
11-
'name': 'Angular E2E: jqlite'
12-
},
13-
14-
baseUrl: 'http://localhost:8000/build/docs/',
15-
16-
framework: 'jasmine',
17-
18-
onPrepare: function() {
19-
// Disable animations so e2e tests run more quickly
20-
var disableNgAnimate = function() {
21-
angular.module('disableNgAnimate', []).run(function($animate) {
22-
$animate.enabled(false);
23-
});
24-
};
25-
26-
browser.addMockModule('disableNgAnimate', disableNgAnimate);
27-
},
28-
29-
jasmineNodeOpts: {
30-
defaultTimeoutInterval: 30000
31-
}
8+
config.capabilities = {
9+
browserName: 'chrome',
3210
};
11+
12+
exports.config = config;

protractor-jquery-conf.js protractor-shared-conf.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
exports.config = {
22
allScriptsTimeout: 11000,
33

4-
specs: [
5-
'build/docs/ptore2e/**/*jquery_test.js',
6-
'test/e2e/docsAppE2E.js'
7-
],
8-
9-
capabilities: {
10-
'browserName': 'chrome',
11-
'name': 'Angular E2E: jquery'
12-
},
13-
144
baseUrl: 'http://localhost:8000/build/docs/',
155

166
framework: 'jasmine',
@@ -24,6 +14,11 @@ exports.config = {
2414
};
2515

2616
browser.addMockModule('disableNgAnimate', disableNgAnimate);
17+
18+
// Store the name of the browser that's currently being used.
19+
browser.getCapabilities().then(function(caps) {
20+
browser.params.browser = caps.get('browserName');
21+
});
2722
},
2823

2924
jasmineNodeOpts: {

protractor-travis-conf.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var config = require('./protractor-shared-conf').config;
2+
3+
config.sauceUser = process.env.SAUCE_USERNAME;
4+
config.sauceKey = process.env.SAUCE_ACCESS_KEY;
5+
6+
config.multiCapabilities = [{
7+
'browserName': 'chrome',
8+
'name': 'Angular E2E',
9+
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
10+
'build': process.env.TRAVIS_BUILD_NUMBER
11+
}, {
12+
'browserName': 'firefox',
13+
'name': 'Angular E2E',
14+
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
15+
'build': process.env.TRAVIS_BUILD_NUMBER
16+
}, {
17+
browserName: 'safari',
18+
'platform': 'OS X 10.9',
19+
'version': '7',
20+
'name': 'Angular E2E',
21+
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
22+
'build': process.env.TRAVIS_BUILD_NUMBER
23+
}];
24+
25+
exports.config = config;

scripts/travis/build.sh

+6-8
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ if [ $JOB = "unit" ]; then
1010
grunt test:promises-aplus
1111
grunt test:unit --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_8,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
1212
elif [ $JOB = "e2e" ]; then
13-
export GRUNT_TARGET="test:protractor"
14-
if [ $JQVERSION = "jquery" ]; then
15-
GRUNT_TARGET="test:jq-protractor"
13+
export TARGET_SPECS="build/docs/ptore2e/**/*jqlite_test.js"
14+
if [ $TEST_TARGET = "jquery" ]; then
15+
TARGET_SPECS="build/docs/ptore2e/**/*jquery_test.js"
16+
elif [ $TEST_TARGET = "doce2e" ]; then
17+
TARGET_SPECS="test/e2e/docsAppE2E.js"
1618
fi
17-
grunt $GRUNT_TARGET --sauceUser $SAUCE_USERNAME \
18-
--sauceKey $SAUCE_ACCESS_KEY \
19-
--capabilities.tunnel-identifier=$TRAVIS_JOB_NUMBER \
20-
--capabilities.build=$TRAVIS_BUILD_NUMBER \
21-
--browser=$BROWSER
19+
grunt test:travis-protractor --specs "$TARGET_SPECS"
2220
else
2321
echo "Unknown job type. Please set JOB=unit or JOB=e2e-*."
2422
fi

0 commit comments

Comments
 (0)