Add Grunt to automate testing and linting. Add Karma to run tests
parent
10f23f21ab
commit
3a4436f5af
@ -0,0 +1,53 @@
|
|||||||
|
module.exports = function(grunt) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Load the grunt tasks
|
||||||
|
require('load-grunt-tasks')(grunt);
|
||||||
|
|
||||||
|
// Time the grunt tasks
|
||||||
|
require('time-grunt')(grunt);
|
||||||
|
|
||||||
|
grunt.initConfig({
|
||||||
|
karma: {
|
||||||
|
options: {
|
||||||
|
autowatch: false,
|
||||||
|
browsers: [
|
||||||
|
'PhantomJS'
|
||||||
|
],
|
||||||
|
configFile: 'test/karma.conf.js',
|
||||||
|
reporters: [ 'dots' ],
|
||||||
|
singleRun: true
|
||||||
|
},
|
||||||
|
unit: {}
|
||||||
|
},
|
||||||
|
jshint: {
|
||||||
|
grunt: {
|
||||||
|
src: [ 'Gruntfile.js' ],
|
||||||
|
options: {
|
||||||
|
node: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dev: {
|
||||||
|
src: [ 'localStorageModule.js' ],
|
||||||
|
options: {
|
||||||
|
jshintrc: '.jshintrc',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
src: [ 'test/spec/**/*.js' ],
|
||||||
|
options: {
|
||||||
|
jshintrc: 'test/.jshintrc',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
grunt.registerTask('test', [
|
||||||
|
'karma'
|
||||||
|
]);
|
||||||
|
|
||||||
|
grunt.registerTask('default', [
|
||||||
|
'jshint',
|
||||||
|
'test'
|
||||||
|
]);
|
||||||
|
};
|
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"node": true,
|
||||||
|
"browser": true,
|
||||||
|
"esnext": true,
|
||||||
|
"bitwise": true,
|
||||||
|
"camelcase": true,
|
||||||
|
"curly": true,
|
||||||
|
"eqeqeq": true,
|
||||||
|
"immed": true,
|
||||||
|
"indent": 2,
|
||||||
|
"latedef": true,
|
||||||
|
"newcap": true,
|
||||||
|
"noarg": true,
|
||||||
|
"quotmark": "single",
|
||||||
|
"regexp": true,
|
||||||
|
"undef": true,
|
||||||
|
"unused": true,
|
||||||
|
"strict": true,
|
||||||
|
"trailing": true,
|
||||||
|
"smarttabs": true,
|
||||||
|
"globals": {
|
||||||
|
"after": false,
|
||||||
|
"afterEach": false,
|
||||||
|
"angular": false,
|
||||||
|
"before": false,
|
||||||
|
"beforeEach": false,
|
||||||
|
"browser": false,
|
||||||
|
"describe": false,
|
||||||
|
"expect": false,
|
||||||
|
"inject": false,
|
||||||
|
"it": false,
|
||||||
|
"spyOn": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
|||||||
|
// Karma configuration
|
||||||
|
// http://karma-runner.github.io/0.10/config/configuration-file.html
|
||||||
|
|
||||||
|
module.exports = function(config) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var bower = 'test/lib/bower_components/';
|
||||||
|
|
||||||
|
config.set({
|
||||||
|
|
||||||
|
// enable / disable watching file and executing tests whenever any file changes
|
||||||
|
autoWatch: true,
|
||||||
|
|
||||||
|
// base path, that will be used to resolve files and exclude
|
||||||
|
basePath: '../',
|
||||||
|
|
||||||
|
// Start these browsers, currently available:
|
||||||
|
// - Chrome
|
||||||
|
// - ChromeCanary
|
||||||
|
// - Firefox
|
||||||
|
// - Opera
|
||||||
|
// - Safari (only Mac)
|
||||||
|
// - PhantomJS
|
||||||
|
// - IE (only Windows)
|
||||||
|
browsers: ['Chrome'],
|
||||||
|
|
||||||
|
// list of files / patterns to load in the browser
|
||||||
|
files: [
|
||||||
|
bower + 'angular/angular.js',
|
||||||
|
bower + 'angular-mocks/angular-mocks.js',
|
||||||
|
'localStorageModule.js',
|
||||||
|
'test/spec/**/*.js'
|
||||||
|
],
|
||||||
|
|
||||||
|
// testing framework to use (jasmine/mocha/qunit/...)
|
||||||
|
frameworks: ['jasmine'],
|
||||||
|
|
||||||
|
// level of logging
|
||||||
|
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
|
||||||
|
logLevel: config.LOG_INFO,
|
||||||
|
|
||||||
|
// web server port
|
||||||
|
port: 8080,
|
||||||
|
|
||||||
|
// Continuous Integration mode
|
||||||
|
// if true, it capture browsers, run tests and exit
|
||||||
|
singleRun: false
|
||||||
|
});
|
||||||
|
};
|
@ -0,0 +1,12 @@
|
|||||||
|
describe('Module: LocalStorageModule', function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Load the Angular module
|
||||||
|
beforeEach(module('LocalStorageModule'));
|
||||||
|
|
||||||
|
describe('constants', function() {
|
||||||
|
it('reads the constants', function() {
|
||||||
|
expect(true).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Reference in New Issue