1
- var testacular = require ( 'testacular' ) ;
1
+ // var testacular = require('testacular');
2
2
3
3
/*global module:false*/
4
4
module . exports = function ( grunt ) {
@@ -9,7 +9,8 @@ module.exports = function (grunt) {
9
9
grunt . loadNpmTasks ( 'grunt-contrib-jshint' ) ;
10
10
grunt . loadNpmTasks ( 'grunt-contrib-watch' ) ;
11
11
grunt . loadNpmTasks ( 'grunt-contrib-connect' ) ;
12
-
12
+ grunt . loadNpmTasks ( 'grunt-karma' ) ;
13
+
13
14
// Project configuration.
14
15
grunt . initConfig ( {
15
16
builddir : 'build' ,
@@ -55,44 +56,52 @@ module.exports = function (grunt) {
55
56
} ,
56
57
watch : {
57
58
files : [ 'src/*.js' , 'test/**/*.js' ] ,
58
- tasks : [ 'build' , 'test ']
59
+ tasks : [ 'build' , 'karma:unit ']
59
60
} ,
60
- connect : {
61
- server : { }
62
- }
61
+ // connect: {
62
+ // server: {}
63
+ // },
64
+ karma : {
65
+ unit : {
66
+ configFile : 'test/test-config.js' ,
67
+ runnerPort : 9999 ,
68
+ singleRun : true ,
69
+ browsers : [ 'PhantomJS' ]
70
+ }
71
+ }
63
72
} ) ;
64
73
65
- grunt . registerTask ( 'default' , [ 'build' , 'jshint' , 'test ' ] ) ;
74
+ grunt . registerTask ( 'default' , [ 'build' , 'jshint' , 'karma:unit ' ] ) ;
66
75
grunt . registerTask ( 'build' , 'Perform a normal build' , [ 'concat' , 'uglify' ] ) ;
67
76
grunt . registerTask ( 'dist' , 'Perform a clean build and generate documentation' , [ 'clean' , 'build' , 'jsdoc' ] ) ;
68
- grunt . registerTask ( 'dev' , 'Run dev server and watch for changes' , [ 'build' , 'connect' , ' watch'] ) ;
77
+ grunt . registerTask ( 'dev' , 'Run dev server and watch for changes' , [ 'build' , 'watch' ] ) ;
69
78
70
- grunt . registerTask ( 'test-server' , 'Start testacular server' , function ( ) {
71
- //Mark the task as async but never call done, so the server stays up
72
- var done = this . async ( ) ;
73
- testacular . server . start ( { configFile : 'test/test-config.js' } ) ;
74
- } ) ;
79
+ // grunt.registerTask('test-server', 'Start testacular server', function () {
80
+ // // Mark the task as async but never call done, so the server stays up
81
+ // var done = this.async();
82
+ // testacular.server.start({ configFile: 'test/test-config.js'});
83
+ // });
75
84
76
- grunt . registerTask ( 'test' , 'Run tests (make sure test-server task is run first)' , function ( ) {
77
- var done = this . async ( ) ;
78
- grunt . util . spawn ( {
79
- cmd : process . platform === 'win32' ? 'testacular .cmd' : 'testacular ' ,
80
- args : process . env . TRAVIS ? [ 'start' , 'test/test-config.js' , '--single-run' , '--no-auto-watch' , '--reporter=dots' , '--browsers=Firefox' ] : [ 'run' ]
81
- } , function ( error , result , code ) {
82
- if ( error ) {
83
- grunt . warn ( "Make sure the testacular server is online: run `grunt test-server`.\n" +
84
- "Also make sure you have a browser open to http://localhost:8080/.\n" +
85
- error . stdout + error . stderr ) ;
86
- //the testacular runner somehow modifies the files if it errors(??).
87
- //this causes grunt's watch task to re-fire itself constantly,
88
- //unless we wait for a sec
89
- setTimeout ( done , 1000 ) ;
90
- } else {
91
- grunt . log . write ( result . stdout ) ;
92
- done ( ) ;
93
- }
94
- } ) ;
95
- } ) ;
85
+ // grunt.registerTask('test', 'Run tests (make sure test-server task is run first)', function () {
86
+ // var done = this.async();
87
+ // grunt.util.spawn({
88
+ // cmd: process.platform === 'win32' ? 'karma .cmd' : 'karma ',
89
+ // args: process.env.TRAVIS ? ['start', 'test/test-config.js', '--single-run', '--no-auto-watch', '--reporter=dots', '--browsers=Firefox'] : ['run']
90
+ // }, function (error, result, code) {
91
+ // if (error) {
92
+ // grunt.warn("Make sure the testacular server is online: run `grunt test-server`.\n" +
93
+ // "Also make sure you have a browser open to http://localhost:8080/.\n" +
94
+ // error.stdout + error.stderr);
95
+ // // the testacular runner somehow modifies the files if it errors(??).
96
+ // // this causes grunt's watch task to re-fire itself constantly,
97
+ // // unless we wait for a sec
98
+ // setTimeout(done, 1000);
99
+ // } else {
100
+ // grunt.log.write(result.stdout);
101
+ // done();
102
+ // }
103
+ // });
104
+ // });
96
105
97
106
grunt . registerTask ( 'jsdoc' , 'Generate documentation' , function ( ) {
98
107
var done = this . async ( ) ;
0 commit comments