Skip to content

Commit c5c60ac

Browse files
committed
Add karma to grunt builds
Partial for #66
1 parent b7d0fe1 commit c5c60ac

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

Diff for: Gruntfile.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ module.exports = function(grunt) {
7878
}
7979
},
8080

81+
karma: {
82+
options: {
83+
configFile: 'karma.conf.js',
84+
autoWatch: false
85+
},
86+
unit: {
87+
singleRun: true
88+
}
89+
},
90+
8191
watch: {
8292
scripts: {
8393
options: {
@@ -92,19 +102,20 @@ module.exports = function(grunt) {
92102

93103
// Build a new version of the library
94104
this.registerTask('build', 'Builds a distributable version of the current project', ['eslint', 'babel', 'webpack']);
95-
this.registerTask('test', ['build', 'mochaTest']);
105+
this.registerTask('test', ['build', 'mochaTest', 'karma:unit']);
96106
this.registerTask('cover', ['test', 'mocha_istanbul:coverage', 'istanbul_check_coverage']);
97107

98108
// Load tasks from npm
99109
grunt.loadNpmTasks('grunt-contrib-clean');
100110
grunt.loadNpmTasks('grunt-contrib-watch');
101111
grunt.loadNpmTasks('grunt-babel');
102112
grunt.loadNpmTasks('grunt-eslint');
113+
grunt.loadNpmTasks('grunt-karma');
103114
grunt.loadNpmTasks('grunt-mocha-test');
104115
grunt.loadNpmTasks('grunt-mocha-istanbul');
105116
grunt.loadNpmTasks('grunt-webpack');
106117

107-
grunt.registerTask('travis', 'default');
118+
grunt.registerTask('travis', ['clean', 'build', 'karma:unit', 'cover']);
108119

109120
grunt.registerTask('dev', ['clean', 'watch']);
110121
grunt.registerTask('default', ['clean', 'build', 'cover']);

Diff for: karma.conf.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* eslint-env node */
2+
module.exports = function(config) {
3+
config.set({
4+
basePath: '',
5+
6+
frameworks: ['mocha'],
7+
8+
files: [
9+
'test/**/*.js'
10+
],
11+
preprocessors: {
12+
'test/**/*.js': ['webpack', 'sourcemap']
13+
},
14+
15+
webpack: {
16+
devtool: 'inline-source-map',
17+
module: {
18+
loaders: [
19+
{
20+
test: /\.jsx?$/,
21+
exclude: /node_modules/,
22+
loader: 'babel-loader?optional=runtime&loose=es6.modules'
23+
}
24+
]
25+
}
26+
},
27+
28+
webpackMiddleware: {
29+
noInfo: true
30+
},
31+
32+
reporters: ['progress'],
33+
34+
35+
port: 9876,
36+
colors: true,
37+
logLevel: config.LOG_INFO,
38+
autoWatch: true,
39+
singleRun: false,
40+
41+
browsers: ['PhantomJS']
42+
});
43+
};

Diff for: package.json

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"devDependencies": {
3535
"babel": "^5.8.20",
3636
"babel-core": "^5.8.20",
37+
"babel-loader": "^5.3.2",
3738
"colors": "^1.1.0",
3839
"eslint": "^1.0.0",
3940
"grunt": "^0.4.5",
@@ -43,11 +44,18 @@
4344
"grunt-contrib-clean": "^0.6.0",
4445
"grunt-contrib-watch": "^0.6.1",
4546
"grunt-eslint": "^17.0.0",
47+
"grunt-karma": "^0.12.0",
4648
"grunt-mocha-istanbul": "^2.4.0",
4749
"grunt-mocha-test": "^0.12.7",
4850
"grunt-webpack": "^1.0.11",
4951
"istanbul": "^0.3.2",
52+
"karma": "^0.13.8",
53+
"karma-mocha": "^0.2.0",
54+
"karma-phantomjs-launcher": "^0.2.1",
55+
"karma-sourcemap-loader": "^0.3.5",
56+
"karma-webpack": "^1.7.0",
5057
"mocha": "^2.2.4",
58+
"phantomjs": "^1.9.17",
5159
"should": "^6.0.1",
5260
"webpack": "^1.10.5",
5361
"webpack-dev-server": "^1.10.1"

0 commit comments

Comments
 (0)