@@ -9,6 +9,56 @@ var stylish = require('gulp-jscs-stylish');
99var path = require ( 'path' ) ;
1010var karma = require ( 'karma' ) ;
1111
12+ function runTests ( singleRun , isCI , done ) {
13+ var reporters = [ 'mocha' ] ;
14+ var preprocessors = { } ;
15+
16+ var files = [
17+ path . join ( __dirname , 'test/vendor/*.js' ) , // PhantomJS 1.x polyfills
18+ path . join ( __dirname , 'github.js' ) ,
19+ path . join ( __dirname , 'test/*.js' )
20+ ] ;
21+
22+ if ( singleRun ) {
23+ files . forEach ( function ( path ) {
24+ preprocessors [ path ] = [ 'coverage' ] ;
25+ } ) ;
26+ reporters . push ( 'coverage' ) ;
27+ }
28+
29+ files . push ( path . join ( __dirname , 'test/user.json' ) ) ;
30+ files . push ( {
31+ pattern : path . join ( __dirname , 'test/gh.png' ) ,
32+ watched : false ,
33+ included : false
34+ } ) ;
35+ preprocessors [ 'test/user.json' ] = [ 'json_fixtures' ] ;
36+
37+ var localConfig = {
38+ files : files ,
39+ configFile : path . join ( __dirname , './karma.conf.js' ) ,
40+ singleRun : singleRun ,
41+ autoWatch : ! singleRun ,
42+ reporters : reporters ,
43+ preprocessors : preprocessors
44+ } ;
45+
46+ if ( isCI ) {
47+ localConfig . sauceLabs = {
48+ testName : 'GitHub.js UAT tests'
49+ } ;
50+ localConfig . customLaunchers = sauceLaunchers ;
51+ localConfig . browsers = Object . keys ( sauceLaunchers ) ;
52+ reporters . push ( 'saucelabs' ) ;
53+ }
54+
55+ var server = new karma . Server ( localConfig , function ( failCount ) {
56+ done ( failCount ? new Error ( 'Failed ' + failCount + ' tests.' ) : null ) ;
57+ } ) ;
58+
59+ server . start ( ) ;
60+ } // End runTests()
61+
1262gulp . task ( 'lint' , function ( ) {
1363 return gulp . src ( [
1464 path . join ( __dirname , '/*.js' ) ,
@@ -28,11 +78,15 @@ gulp.task('lint', function() {
2878} ) ;
2979
3080gulp . task ( 'test' , function ( done ) {
31- runTests ( true , done ) ;
81+ runTests ( true , false , done ) ;
82+ } ) ;
83+
84+ gulp . task ( 'test:ci' , function ( done ) {
85+ runTests ( true , true , done ) ;
3286} ) ;
3387
3488gulp . task ( 'test:auto' , function ( done ) {
35- runTests ( false , done ) ;
89+ runTests ( false , false , done ) ;
3690} ) ;
3791
3892gulp . task ( 'build' , function ( ) {
@@ -46,42 +100,45 @@ gulp.task('default', function() {
46100 gulp . start ( 'lint' , 'test' , 'build' ) ;
47101} ) ;
48102
49- function runTests ( singleRun , done ) {
50- var reporters = [ 'mocha' ] ;
51- var preprocessors = { } ;
52-
53- var files = [
54- path . join ( __dirname , 'github.js' ) ,
55- path . join ( __dirname , 'test/*.js' )
56- ] ;
57-
58- if ( singleRun ) {
59- files . forEach ( function ( path ) {
60- preprocessors [ path ] = [ 'coverage' ] ;
61- } ) ;
62- reporters . push ( 'coverage' ) ;
103+ var sauceLaunchers = {
104+ SL_Chrome : {
105+ base : 'SauceLabs' ,
106+ browserName : 'chrome' ,
107+ version : '45'
108+ } ,
109+ SL_Firefox : {
110+ base : 'SauceLabs' ,
111+ browserName : 'firefox' ,
112+ version : '39'
113+ } ,
114+ SL_Safari : {
115+ base : 'SauceLabs' ,
116+ browserName : 'safari' ,
117+ platform : 'OS X 10.10' ,
118+ version : '8'
119+ } ,
120+ SL_IE_9 : {
121+ base : 'SauceLabs' ,
122+ browserName : 'internet explorer' ,
123+ platform : 'Windows 2008' ,
124+ version : '9'
125+ } ,
126+ SL_IE_10 : {
127+ base : 'SauceLabs' ,
128+ browserName : 'internet explorer' ,
129+ platform : 'Windows 2012' ,
130+ version : '10'
131+ } ,
132+ SL_IE_11 : {
133+ base : 'SauceLabs' ,
134+ browserName : 'internet explorer' ,
135+ platform : 'Windows 8.1' ,
136+ version : '11'
137+ } ,
138+ SL_iOS : {
139+ base : 'SauceLabs' ,
140+ browserName : 'iphone' ,
141+ platform : 'OS X 10.10' ,
142+ version : '8.1'
63143 }
64-
65- files . push ( path . join ( __dirname , 'test/user.json' ) ) ;
66- files . push ( {
67- pattern : path . join ( __dirname , 'test/gh.png' ) ,
68- watched : false ,
69- included : false
70- } ) ;
71- preprocessors [ 'test/user.json' ] = [ 'json_fixtures' ] ;
72-
73- var localConfig = {
74- files : files ,
75- configFile : path . join ( __dirname , './karma.conf.js' ) ,
76- singleRun : singleRun ,
77- autoWatch : ! singleRun ,
78- reporters : reporters ,
79- preprocessors : preprocessors
80- } ;
81-
82- var server = new karma . Server ( localConfig , function ( failCount ) {
83- done ( failCount ? new Error ( 'Failed ' + failCount + ' tests.' ) : null ) ;
84- } ) ;
85-
86- server . start ( ) ;
87- }
144+ } ;
0 commit comments