Skip to content

Commit

Permalink
test with sauce
Browse files Browse the repository at this point in the history
  • Loading branch information
mcasimir committed Mar 13, 2016
1 parent 274dc52 commit 2ea1abe
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 67 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
@@ -1,9 +1,10 @@
language: node_js
node_js:
- '4.4.0'
sudo: required

services:
- docker
addons:
sauce_connect:
username: "mcasimir"
access_key:
secure: "SNGauHZ2ipnn2Ny7pwe0BIOmwdXHQpjSLrB1dKfCUYIwYXEQNMTx66uSBybvWG6CDxDt/pSXJx8u4NrUvQj0xHGKOnkhiNRfOy7CKWQ0wjBDUtYrNSPmgJTKsj94XQSb10hIw5AtD6RO+dk3vqX7NNJqtGiGB+xCo96YVuOor5Q="

script: node_modules/.bin/gulp test:ci
3 changes: 2 additions & 1 deletion config.js
Expand Up @@ -44,7 +44,8 @@ var config = {
'jasmine-core',
'karma-chrome-launcher',
'karma-jasmine',
'karma-mocha-reporter'
'karma-mocha-reporter',
'karma-sauce-launcher'
]
},
lint: ['./src/**/*.js', './test/**/*.js', './*.js']
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -47,6 +47,7 @@
"karma-chrome-launcher": "0.2.2",
"karma-jasmine": "0.3.7",
"karma-mocha-reporter": "2.0.0",
"karma-sauce-launcher": "0.3.1",
"require-all": "2.0.0"
}
}
44 changes: 1 addition & 43 deletions tasks/test.js
Expand Up @@ -3,39 +3,13 @@
var path = require('path');
var Server = require('karma').Server;
var seq = require('gulp-sequence');
var execSync = require('child_process').execSync;

module.exports = function(gulp) {
gulp.task('test:unit', function() {
return runUnitTest();
});

gulp.task('test:unit:xvfb', function() {
return startXvfb()
.then(runUnitTest)
.then(stopXvfb)
.catch(function(e) {
stopXvfb();
return Promise.reject(e);
});
});

gulp.task('test:unit:docker', function() {
return new Promise(function(resolve, reject) {
let cwd = process.cwd();
try {
let command = `docker run -v ${cwd}:${cwd} -w ${cwd} ` +
`jeroenknoops/docker-node-chrome-xvfb ` +
`node_modules/.bin/gulp test:unit:xvfb`;
execSync(command, {stdio: [0,1,2]});
resolve();
} catch (e) {
reject(e);
}
});
});

gulp.task('test:ci', seq('depcheck', 'lint', 'test:unit:docker'));
gulp.task('test:ci', seq('depcheck', 'lint', 'test:unit'));
};

function runUnitTest() {
Expand All @@ -50,19 +24,3 @@ function runUnitTest() {
}).start();
});
}

function startXvfb() {
return new Promise(function(resolve, reject) {
try {
resolve(execSync(`/etc/init.d/xvfb start`, {stdio: [0,1,2]}));
} catch (e) {
reject(e);
}
});
}

function stopXvfb() {
try {
execSync(`/etc/init.d/xvfb stop`, {stdio: [0,1,2]});
} catch (e) {}
}
58 changes: 39 additions & 19 deletions test/karma.conf.js
Expand Up @@ -2,6 +2,37 @@

var src = require('../config').globs.js;

var customLaunchersCi = {
ciChrome: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'Windows 7',
version: '35'
},
ciIphone: {
base: 'SauceLabs',
browserName: 'iphone',
platform: 'OS X 10.9',
version: '7.1'
}
};

var customLaunchersLocal = {
localChrome: {
base: 'Chrome'
}
};

var customLaunchers = process.env.CI ?
customLaunchersCi :
customLaunchersLocal;

var reporters = ['mocha'];

if (process.env.CI) {
reporters.push('saucelabs');
}

module.exports = function(config) {
config.set({
basePath: '..',
Expand All @@ -13,28 +44,17 @@ module.exports = function(config) {
'node_modules/angular-mocks/angular-mocks.js',
'test/unit/*.spec.js'
]),
// preprocessors: {
// 'src/js/**/*.js': ['coverage']
// },
// coverageReporter: {
// type: 'lcov',
// dir: 'coverage'
// },
reporters: ['mocha'],

sauceLabs: {
testName: `mobile-angular-ui@${process.env.TRAVIS_BRANCH || 'local'} (build #${process.env.TRAVIS_BUILD_NUMBER || 'local'})`
},
customLaunchers: customLaunchers,
browsers: Object.keys(customLaunchers),
port: 9876,
colors: true,
logLevel: config.LOG_INFO,

browsers: ['ChromeNoSandbox'],

customLaunchers: {
ChromeNoSandbox: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},

reporters: reporters,
singleRun: true,
concurrency: Infinity
concurrency: 1
});
};

0 comments on commit 2ea1abe

Please sign in to comment.