Added karma testing to the gruntfile

This commit is contained in:
Colin Eberhardt
2015-08-11 14:42:21 +01:00
parent ffa64f6fd3
commit 74925f4439
3 changed files with 22 additions and 45 deletions

View File

@@ -6,7 +6,8 @@ module.exports = function(grunt) {
paths: {
distFolder: 'dist',
srcFolder: 'src'
srcFolder: 'src',
testFolder: 'src/__tests__',
},
clean: ['<%= paths.distFolder %>'],
@@ -32,14 +33,31 @@ module.exports = function(grunt) {
'<%= paths.distFolder %>/css-layout.min.js': ['<%= paths.srcFolder %>/Layout.js']
}
}
},
karma: {
main: {
options: {
files: [
'<%= paths.srcFolder %>/Layout.js',
'<%= paths.srcFolder %>/Layout-test-utils.js',
'<%= paths.testFolder %>/Layout-test.js',
'<%= paths.testFolder %>/Layout-consts-test.js'
],
browsers: ['Chrome'],
frameworks: ['jasmine'],
singleRun: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-karma');
grunt.registerTask('build', ['clean', 'copy', 'uglify']);
grunt.registerTask('build', ['clean', 'karma' ,'copy', 'uglify']);
grunt.registerTask('default', ['build']);

View File

@@ -1,42 +0,0 @@
'use strict';
module.exports = function (config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: 'src',
// frameworks to use
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'Layout.js',
'Layout-test-utils.js',
'__tests__/Layout-test.js',
'__tests__/Layout-consts-test.js'
],
plugins: [
'karma-chrome-launcher',
'karma-jasmine'
],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
browsers: ['Chrome'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
singleRun: false
});
};

View File

@@ -24,8 +24,9 @@
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-uglify": "^0.9.1",
"grunt-karma": "^0.12.0",
"jasmine-core": "^2.2.0",
"karma": "^0.12.31",
"karma": "^0.13.8",
"karma-chrome-launcher": "^0.1.7",
"karma-jasmine": "^0.3.5"
}