Skip to content

Commit 5d8a21d

Browse files
committed
fix(travis): use SauceLabs for e2e tests on travis
1 parent d386c4a commit 5d8a21d

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ before_script:
3939
- ./lib/sauce/sauce_connect_block.sh
4040

4141
script:
42-
- ./scripts/travis/travis_build.sh
42+
- ./travis_build.sh
4343

4444
after_success:
4545
- grunt release

Gruntfile.js

+13
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ module.exports = function(grunt) {
147147
}
148148
}
149149
},
150+
ci: {
151+
keepAlive: false,
152+
options: {
153+
args: {
154+
seleniumPort: 4444,
155+
baseUrl: 'http://localhost:9999',
156+
specs: ['.tmp/doc-scenarios/**/*.spec.js', 'test/e2e/**/*.spec.js'],
157+
sauceUser: process.env.SAUCE_USERNAME,
158+
sauceKey: process.env.SAUCE_ACCESS_KEY
159+
}
160+
}
161+
}
150162
auto: {
151163
keepAlive: true,
152164
options: {
@@ -415,6 +427,7 @@ module.exports = function(grunt) {
415427
grunt.registerTask('test:ci', ['clean', 'jshint', 'ngtemplates', 'serialsauce']);
416428
grunt.registerTask('test:docs', ['connect:testserver', 'protractor:docs']);
417429
grunt.registerTask('test:e2e', ['connect:testserver', 'protractor:singlerun']);
430+
grunt.registerTask('test:e2e:ci', ['connect:testserver', 'protractor:ci']);
418431

419432
// Test
420433
grunt.registerTask('test', 'Run tests on singleRun karma server', function() {

lib/grunt/plugins.js

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ module.exports = function(grunt) {
1616
*
1717
*/
1818

19+
grunt.registerMultiTask('tests', '**Use `grunt test` instead**', function(){
20+
util.startKarma.call(util, this.data, true, this.async());
21+
});
22+
1923
// Run tests on multiple versions of angular
2024
grunt.registerTask('karmangular', 'Run tests against multiple versions of angular', function() {
2125
// Start karma servers

lib/grunt/utils.js

+20
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ var util = module.exports = {
3131
return retFiles;
3232
},
3333

34+
startKarma: function(config, singleRun, done){
35+
var browsers = grunt.option('browsers');
36+
var reporters = grunt.option('reporters');
37+
var noColor = grunt.option('no-colors');
38+
var port = grunt.option('port');
39+
var p = spawn('node', ['node_modules/karma/bin/karma', 'start', config,
40+
singleRun ? '--single-run=true' : '',
41+
reporters ? '--reporters=' + reporters : '',
42+
browsers ? '--browsers=' + browsers : '',
43+
noColor ? '--no-colors' : '',
44+
port ? '--port=' + port : ''
45+
]);
46+
p.stdout.pipe(process.stdout);
47+
p.stderr.pipe(process.stderr);
48+
p.on('exit', function(code){
49+
if(code !== 0) grunt.fail.warn("Karma test(s) failed. Exit code: " + code);
50+
done();
51+
});
52+
},
53+
3454
customLaunchers: function() {
3555
return {
3656
'SL_Chrome': {

travis_build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if [ $JOB = "unit" ]; then
88
elif [ $JOB = "e2e" ]; then
99
# grunt clean build test:e2e --browsers=SL_Chrome
1010
grunt
11-
grunt test:e2e
11+
grunt test:e2e:ci
1212
else
1313
echo "Unknown job type. Please set JOB=unit or JOB=e2e."
1414
fi

0 commit comments

Comments
 (0)