X Tutup
Skip to content

Commit 0e85ca9

Browse files
juliemrIgorMinar
authored andcommitted
chore(testing): run end to end tests on firefox and safari as well as chrome
Update the Travis and Jenkins configs to run protractor tests on Safari and Firefox as well, and make the Travis tests run output XML and turn off color. Fix tests which were failing in Firefox due to clear() not working as expected. Fix tests which were failing in Safari due to SafariDriver not understanding the minus key, and disable tests which SafariDriver has no support for.
1 parent e7face4 commit 0e85ca9

File tree

12 files changed

+99
-19
lines changed

12 files changed

+99
-19
lines changed

Gruntfile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ module.exports = function(grunt) {
9191

9292

9393
runprotractor: {
94-
normal: 'protractor-conf.js'
94+
normal: 'protractor-conf.js',
95+
jenkins: 'protractor-jenkins-conf.js'
9596
},
9697

9798

@@ -291,6 +292,7 @@ module.exports = function(grunt) {
291292
grunt.registerTask('test:docs', 'Run the doc-page tests with Karma', ['package', 'tests:docs']);
292293
grunt.registerTask('test:unit', 'Run unit, jQuery and Karma module tests with Karma', ['tests:jqlite', 'tests:jquery', 'tests:modules']);
293294
grunt.registerTask('test:protractor', 'Run the end to end tests with Protractor and keep a test server running in the background', ['webdriver', 'connect:testserver', 'runprotractor:normal']);
295+
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', 'runprotractor:jenkins']);
294296
grunt.registerTask('test:e2e', 'Alias for test:protractor', ['test:protractor']);
295297
grunt.registerTask('test:docgen', ['jasmine_node']);
296298
grunt.registerTask('test:promises-aplus',['build:promises-aplus-adapter','shell:promises-aplus-tests']);

docs/content/guide/expression.ngdoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ prevent accidental access to the global state (a common source of subtle bugs).
110110
</doc:source>
111111
<doc:protractor>
112112
it('should calculate expression in binding', function() {
113+
if (browser.params.browser = 'safari') {
114+
// Safari can't handle dialogs.
115+
return;
116+
};
113117
element(by.css('[ng-click="greet()"]')).click();
114118

115119
var alertDialog = browser.switchTo().alert();

docs/src/ngdoc.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,14 +1113,25 @@ function scenarios(docs){
11131113
function writeProtractorTest(doc){
11141114
var lines = [];
11151115
lines.push('describe("' + doc.section + '/' + doc.id + '", function() {');
1116-
lines.push(' beforeEach(function() {');
1117-
lines.push(' browser.get("index-nocache.html#!/' + doc.section + '/' + doc.id + '");');
1118-
lines.push(' });');
1116+
lines.push(' describe("angular+jqLite", function() {')
1117+
lines.push(' beforeEach(function() {');
1118+
lines.push(' browser.get("index-nocache.html#!/' + doc.section + '/' + doc.id + '");');
1119+
lines.push(' });');
11191120
lines.push('');
11201121
doc.protractorTests.forEach(function(test){
1121-
lines.push(indentCode(trim(test), 2));
1122+
lines.push(indentCode(trim(test), 4));
1123+
lines.push('');
1124+
});
1125+
lines.push(' });');
1126+
lines.push(' describe("angular+jQuery", function() {')
1127+
lines.push(' beforeEach(function() {');
1128+
lines.push(' browser.get("index-jq-nocache.html#!/' + doc.section + '/' + doc.id + '");');
1129+
lines.push(' });');
1130+
doc.protractorTests.forEach(function(test){
1131+
lines.push(indentCode(trim(test), 4));
11221132
lines.push('');
11231133
});
1134+
lines.push(' });');
11241135
lines.push('});');
11251136
lines.push('');
11261137
return lines.join('\n');

jenkins_build.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ then
1313
BROWSERS="Chrome,Firefox,Opera,/Users/jenkins/bin/safari.sh,/Users/jenkins/bin/ie8.sh,/Users/jenkins/bin/ie9.sh"
1414
fi
1515

16-
if [[ -z "$BROWSERS_E2E" ]]
17-
then
18-
BROWSERS_E2E="Chrome,Firefox,/Users/jenkins/bin/safari.sh"
19-
fi
20-
21-
2216
# CLEAN #
2317
rm -f angular.min.js.gzip.size
2418
rm -f angular.js.size
@@ -28,14 +22,18 @@ rm -f angular.js.size
2822
npm install --color false
2923
grunt ci-checks package --no-color
3024

25+
mkdir test_out
26+
3127
# DOCS generator unit tests #
3228
grunt test:docgen --no-color
3329

3430
# UNIT TESTS #
3531
grunt test:unit --browsers $BROWSERS --reporters=dots,junit --no-colors --no-color
3632

3733
# END TO END TESTS #
38-
grunt test:protractor
34+
grunt test:ci-protractor
35+
grunt test:ci-protractor --browser safari
36+
grunt test:ci-protractor --browser firefox
3937

4038
# Promises/A+ TESTS #
4139
grunt test:promises-aplus --no-color

lib/grunt/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ module.exports = {
141141
// Skip the webdriver-manager update on Travis, since the browsers will
142142
// be provided remotely.
143143
done();
144+
return;
144145
}
145146
var p = spawn('node', ['node_modules/protractor/bin/webdriver-manager', 'update']);
146147
p.stdout.pipe(process.stdout);
@@ -156,11 +157,16 @@ module.exports = {
156157
var sauceKey = grunt.option('sauceKey');
157158
var tunnelIdentifier = grunt.option('capabilities.tunnel-identifier');
158159
var sauceBuild = grunt.option('capabilities.build');
160+
var browser = grunt.option('browser');
159161
var args = ['node_modules/protractor/bin/protractor', config];
160162
if (sauceUser) args.push('--sauceUser=' + sauceUser);
161163
if (sauceKey) args.push('--sauceKey=' + sauceKey);
162164
if (tunnelIdentifier) args.push('--capabilities.tunnel-identifier=' + tunnelIdentifier);
163165
if (sauceBuild) args.push('--capabilities.build=' + sauceBuild);
166+
if (browser) {
167+
args.push('--browser=' + browser);
168+
args.push('--params.browser=' + browser);
169+
}
164170

165171

166172
var p = spawn('node', args);

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
"promises-aplus-tests": "~1.3.2",
4444
"semver": "~2.1.0",
4545
"lodash": "~2.1.0",
46-
"browserstacktunnel-wrapper": "~1.1.1"
46+
"browserstacktunnel-wrapper": "~1.1.1",
47+
"grunt-jscs-checker": "~0.3.2",
48+
"jasmine-reporters": "~0.2.1"
4749
},
4850
"licenses": [
4951
{

protractor-jenkins-conf.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
exports.config = {
2+
allScriptsTimeout: 11000,
3+
4+
specs: [
5+
'build/docs/ptore2e/**/*.js',
6+
'test/e2e/docsAppE2E.js'
7+
],
8+
9+
capabilities: {
10+
'browserName': 'chrome'
11+
},
12+
13+
baseUrl: 'http://localhost:8000/build/docs/',
14+
15+
framework: 'jasmine',
16+
17+
onPrepare: function() {
18+
// Disable animations so e2e tests run more quickly
19+
var disableNgAnimate = function() {
20+
angular.module('disableNgAnimate', []).run(function($animate) {
21+
$animate.enabled(false);
22+
});
23+
};
24+
25+
browser.addMockModule('disableNgAnimate', disableNgAnimate);
26+
27+
require('jasmine-reporters');
28+
jasmine.getEnv().addReporter(
29+
new jasmine.JUnitXmlReporter('test_out/e2e-' + this.capabilities.browserName + '-', true, true));
30+
},
31+
32+
jasmineNodeOpts: {
33+
defaultTimeoutInterval: 30000,
34+
showColors: false
35+
}
36+
};

scripts/travis/build.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +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-
grunt test:protractor --sauceUser $SAUCE_USERNAME \
13+
export SAUCE_OPTIONS="--sauceUser $SAUCE_USERNAME \
1414
--sauceKey $SAUCE_ACCESS_KEY \
1515
--capabilities.tunnel-identifier=$TRAVIS_JOB_NUMBER \
16-
--capabilities.build=$TRAVIS_BUILD_NUMBER
16+
--capabilities.build=$TRAVIS_BUILD_NUMBER"
17+
grunt test:protractor $SAUCE_OPTIONS
18+
grunt test:protractor $SAUCE_OPTIONS --browser=firefox
19+
grunt test:protractor $SAUCE_OPTIONS --browser=safari
1720
else
1821
echo "Unknown job type. Please set JOB=unit or JOB=e2e."
1922
fi

src/ng/directive/input.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,11 +955,17 @@ var VALID_CLASS = 'ng-valid',
955955
</file>
956956
<file name="protractorTest.js">
957957
it('should data-bind and become invalid', function() {
958+
if (browser.params.browser = 'safari') {
959+
// SafariDriver can't handle contenteditable.
960+
return;
961+
};
958962
var contentEditable = element(by.css('.doc-example-live [contenteditable]'));
959963
960964
expect(contentEditable.getText()).toEqual('Change me!');
961965
962-
contentEditable.clear();
966+
// Firefox driver doesn't trigger the proper events on 'clear', so do this hack
967+
contentEditable.click();
968+
contentEditable.sendKeys(protractor.Key.chord(protractor.Key.COMMAND, "a"));
963969
contentEditable.sendKeys(protractor.Key.BACK_SPACE);
964970
965971
expect(contentEditable.getText()).toEqual('');

src/ng/directive/ngInclude.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,21 @@
119119
});
120120
121121
it('should load template2.html', function() {
122+
if (browser.params.browser == 'firefox') {
123+
// Firefox can't handle using selects
124+
// See https://github.com/angular/protractor/issues/480
125+
return;
126+
}
122127
templateSelect.click();
123128
templateSelect.element.all(by.css('option')).get(2).click();
124129
expect(includeElem.getText()).toMatch(/Content of template2.html/);
125130
});
126131
127132
it('should change to blank', function() {
133+
if (browser.params.browser == 'firefox') {
134+
// Firefox can't handle using selects
135+
return;
136+
}
128137
templateSelect.click();
129138
templateSelect.element.all(by.css('option')).get(0).click();
130139
expect(includeElem.isPresent()).toBe(false);

0 commit comments

Comments
 (0)
X Tutup