Skip to content

Commit 5a4c3a8

Browse files
committed
Merge pull request #125 from mithro/master
Add "grunt sauce:xxxx" tasks to allow checking of unit tests on many browsers
2 parents 2cdad5a + 4e0815a commit 5a4c3a8

File tree

5 files changed

+91
-20
lines changed

5 files changed

+91
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ web-animations-*.min.js.map
99
web-animations.min.js
1010
web-animations.min.js.map
1111
*~
12+
sauce_connect.log

Gruntfile.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module.exports = function(grunt) {
22
grunt.loadNpmTasks('grunt-contrib-uglify');
33
grunt.loadNpmTasks('grunt-gjslint');
44
grunt.loadNpmTasks('grunt-checkrepo');
5+
grunt.loadNpmTasks('grunt-karma');
6+
grunt.loadNpmTasks('grunt-saucelabs');
57
grunt.loadNpmTasks('grunt-git-status');
68

79
var targetConfig = require('./target-config.js');
@@ -69,6 +71,7 @@ module.exports = function(grunt) {
6971
}
7072
},
7173
test: testTargets,
74+
sauce: testTargets,
7275
});
7376

7477
grunt.task.registerMultiTask('gen', 'Generate web-animations-<target>.js, web-animations-<target>.html, test/runner-<target>.js', function() {
@@ -102,7 +105,7 @@ module.exports = function(grunt) {
102105

103106
grunt.task.registerMultiTask('test', 'Run <target> tests under Karma', function() {
104107
var done = this.async();
105-
var karmaConfig = require('./test/karma-config.js');
108+
var karmaConfig = require('karma/lib/config').parseConfig(require('path').resolve('test/karma-config.js'), {});
106109
var config = targetConfig[this.target];
107110
karmaConfig.files = ['test/runner.js'].concat(config.src, config.test);
108111
var karmaServer = require('karma').server;
@@ -111,6 +114,18 @@ module.exports = function(grunt) {
111114
});
112115
});
113116

117+
grunt.task.registerMultiTask('sauce', 'Run <target> tests under Karma on Saucelabs', function() {
118+
var done = this.async();
119+
var karmaConfig = require('karma/lib/config').parseConfig(require('path').resolve('test/karma-config-ci.js'), {});
120+
var config = targetConfig[this.target];
121+
karmaConfig.files = ['test/runner.js'].concat(config.src, config.test);
122+
karmaConfig.sauceLabs.testName = 'web-animation-next ' + this.target + ' Unit tests';
123+
var karmaServer = require('karma').server;
124+
karmaServer.start(karmaConfig, function(exitCode) {
125+
done(exitCode === 0);
126+
});
127+
});
128+
114129
grunt.task.registerTask('clean', 'Remove files generated by grunt', function() {
115130
grunt.file.expand('web-animations-*').concat(grunt.file.expand('test/runner-*.html')).forEach(function(file) {
116131
grunt.file.delete(file);

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"karma-firefox-launcher": "~0.1.3",
1919
"karma-ie-launcher": "~0.1.5",
2020
"karma-safari-launcher": "~0.1.1",
21+
"karma-sauce-launcher": "~0.2.3",
22+
"grunt-checkrepo": "~0.1.0",
23+
"grunt-saucelabs": "~4.0.2",
2124
"grunt-checkrepo": "~0.1.0",
2225
"grunt-git-status": "~1.0.0"
2326
},

test/karma-config-ci.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module.exports = function(config) {
2+
var customLaunchers = {
3+
sl_chrome: {
4+
base: 'SauceLabs',
5+
browserName: 'chrome',
6+
platform: 'Windows 7'
7+
},
8+
sl_firefox: {
9+
base: 'SauceLabs',
10+
browserName: 'firefox',
11+
version: '27'
12+
},
13+
sl_ios_safari: {
14+
base: 'SauceLabs',
15+
browserName: 'iphone',
16+
platform: 'OS X 10.9',
17+
version: '7.1'
18+
},
19+
sl_ie_11: {
20+
base: 'SauceLabs',
21+
browserName: 'internet explorer',
22+
platform: 'Windows 8.1',
23+
version: '11'
24+
}
25+
};
26+
27+
config.set({
28+
frameworks: ['mocha', 'chai'],
29+
plugins: [
30+
'karma-mocha',
31+
'karma-chai',
32+
'karma-sauce-launcher',
33+
],
34+
sauceLabs: {
35+
testName: 'Web App Unit Tests'
36+
},
37+
customLaunchers: customLaunchers,
38+
browsers: Object.keys(customLaunchers),
39+
basePath: '..',
40+
files: [
41+
// Populated in `grunt test` task.
42+
],
43+
singleRun: true,
44+
port: 9876,
45+
reporters: ['dots', 'saucelabs'],
46+
colors: true,
47+
autoWatch: false,
48+
captureTimeout: 300000,
49+
});
50+
};

test/karma-config.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
module.exports = {
2-
frameworks: ['mocha', 'chai'],
3-
plugins: [
4-
'karma-mocha',
5-
'karma-chai',
6-
'karma-chrome-launcher',
7-
'karma-firefox-launcher'
8-
],
9-
browsers: ['Firefox'],
10-
// browsers: ['Safari', 'Chrome', 'ChromeCanary', 'Firefox', 'IE'],
11-
basePath: '.',
12-
files: [
13-
// Populated in `grunt test` task.
14-
],
15-
singleRun: true,
16-
port: 9876,
17-
reporters: ['dots'],
18-
colors: true,
19-
autoWatch: false,
1+
module.exports = function(config) {
2+
config.set({
3+
frameworks: ['mocha', 'chai'],
4+
plugins: [
5+
'karma-mocha',
6+
'karma-chai',
7+
'karma-chrome-launcher',
8+
'karma-firefox-launcher'
9+
],
10+
browsers: ['Firefox'],
11+
// browsers: ['Safari', 'Chrome', 'ChromeCanary', 'Firefox', 'IE'],
12+
basePath: '..',
13+
files: [
14+
// Populated in `grunt test` task.
15+
],
16+
singleRun: true,
17+
port: 9876,
18+
reporters: ['dots'],
19+
colors: true,
20+
autoWatch: false,
21+
});
2022
};

0 commit comments

Comments
 (0)