@@ -9,27 +9,58 @@ var karma = require('karma');
9
9
10
10
var $ = require ( 'gulp-load-plugins' ) ( ) ;
11
11
12
+ function runUnitTestsOn ( browsers , done ) {
13
+ var src_files = [ ] ;
14
+ var src_glob = path . join ( conf . paths . src , '/app/**/*.js' ) ;
15
+
16
+ var preprocessors = { } ;
17
+ preprocessors [ src_glob ] = [ 'coverage' ] ;
18
+
19
+ gulp . src ( src_glob )
20
+ . pipe ( $ . angularFilesort ( ) )
21
+ . on ( 'data' , function ( file ) {
22
+ src_files . push ( file . path ) ;
23
+ } ) . on ( 'end' , function ( ) {
24
+ var server = new karma . Server ( {
25
+ browsers : browsers ,
26
+ frameworks : [ 'mocha' , 'chai-sinon' ] ,
27
+ files :
28
+ mainBowerFiles ( { includeDev : true } )
29
+ . concat (
30
+ // Note: es5-shim needed to fix some phantomjs issues,
31
+ // including no Function.prototype.bind . This can be
32
+ // removed (along with the es5-shim dependency) once an
33
+ // upgrade to phantomjs2 is complete
34
+ 'node_modules/es5-shim/es5-shim.js' ,
35
+ src_files ,
36
+ path . join ( conf . paths . test , '/karma/**/*.js' ) ) ,
37
+ singleRun : true ,
38
+ reporters : [ 'progress' , 'coverage' ] ,
39
+ preprocessors : preprocessors
40
+ } ) ;
41
+
42
+ server . on ( 'run_complete' , function ( browsers , results ) {
43
+ // NB If the argument of done() is not null or not undefined,
44
+ // e.g. a string, the next task in a series won't run.
45
+ done ( results . error ? 'There are test failures' : null ) ;
46
+ } ) ;
47
+ server . start ( ) ;
48
+ } ) ;
49
+ }
50
+
12
51
gulp . task ( 'test:unit' , function ( done ) {
13
- var server = new karma . Server ( {
14
- browsers : [ 'PhantomJS' ] ,
15
- frameworks : [ 'mocha' , 'chai-sinon' ] ,
16
- files : mainBowerFiles ( { includeDev : true } ) . concat ( [
17
- 'dist/scripts/app-*.js' ,
18
- 'test/karma/**/*.js'
19
- ] ) ,
20
- logLevel : 'DEBUG' ,
21
- singleRun : true
22
- } ) ;
23
-
24
- server . on ( 'run_complete' , function ( browsers , results ) {
25
- // NB If the argument of done() is not null or not undefined,
26
- // e.g. a string, the next task in a series won't run.
27
- done ( results . error ? 'There are test failures' : null ) ;
28
- } ) ;
29
-
30
- server . start ( ) ;
52
+ runUnitTestsOn ( [ 'PhantomJS' ] , done )
53
+ } ) ;
54
+
55
+ gulp . task ( 'test-browsers:unit' , function ( done ) {
56
+ runUnitTestsOn ( [ 'PhantomJS' , 'Firefox' , 'Chrome' ] , done )
31
57
} ) ;
32
58
33
59
gulp . task ( 'test' , function ( cb ) {
34
- runSequence ( 'build' , 'test:unit' , cb ) ;
60
+ runSequence ( 'test:unit' , cb ) ;
61
+ } ) ;
62
+
63
+
64
+ gulp . task ( 'test-browsers' , function ( cb ) {
65
+ runSequence ( 'test-browsers:unit' , cb ) ;
35
66
} ) ;
0 commit comments