Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Add Karma unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rudijs committed Nov 4, 2013
1 parent 9af341b commit 673ac81
Show file tree
Hide file tree
Showing 10 changed files with 452 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.nodemonignore
.sass-cache/
node_modules/
public/lib
public/lib
test/coverage/
24 changes: 14 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"name": "mean",
"version": "0.1.0",
"dependencies": {
"bootstrap": "2.3.2",
"angular": "1.0.6",
"angular-resource": "1.0.6",
"angular-cookies": "1.0.6",
"angular-bootstrap": "0.6.0",
"angular-ui-utils": "0.0.4"
}
"name": "mean",
"version": "0.1.0",
"dependencies": {
"bootstrap": "2.3.2",
"angular": "1.0.6",
"angular-resource": "1.0.6",
"angular-cookies": "1.0.6",
"angular-bootstrap": "0.6.0",
"angular-ui-utils": "0.0.4",
"angular-mocks": "~1.0.8"
},
"resolutions": {
"angular": "1.0.6"
}
}
12 changes: 9 additions & 3 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function(grunt) {
}
},
jshint: {
all: ['gruntfile.js', 'public/js/**/*.js', 'test/**/*.js', 'app/**/*.js']
all: ['gruntfile.js', 'public/js/**/*.js', 'test/mocha/**/*.js', 'test/karma/**/*.js', 'app/**/*.js']
},
nodemon: {
dev: {
Expand All @@ -50,7 +50,7 @@ module.exports = function(grunt) {
}
},
concurrent: {
tasks: ['nodemon', 'watch'],
tasks: ['nodemon', 'watch', 'karma:unit'],
options: {
logConcurrentOutput: true
}
Expand All @@ -59,19 +59,25 @@ module.exports = function(grunt) {
options: {
reporter: 'spec'
},
src: ['test/**/*.js']
src: ['test/mocha/**/*.js']
},
env: {
test: {
NODE_ENV: 'test'
}
},
karma: {
unit: {
configFile: 'test/karma/karma.conf.js'
}
}
});

//Load NPM tasks
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-env');
Expand Down
111 changes: 61 additions & 50 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,63 @@
{
"name": "mean",
"description": "MEAN - A Modern Stack: MongoDB, ExpressJS, AngularJS, NodeJS. (BONUS: Passport User Support).",
"version": "0.1.0",
"private": false,
"author": "Amos Haviv",
"repository": {
"type": "git",
"url": "https://github.com/linnovate/mean.git"
},
"engines": {
"node": "0.10.x",
"npm": "1.2.x"
},
"scripts": {
"start": "node node_modules/grunt-cli/bin/grunt",
"test": "node node_modules/grunt-cli/bin/grunt test",
"postinstall": "bower install"
},
"dependencies": {
"express": "latest",
"jade": "latest",
"mongoose": "latest",
"connect-mongo": "latest",
"connect-flash": "latest",
"crypto": "latest",
"passport": "latest",
"passport-local": "latest",
"passport-facebook": "latest",
"passport-twitter": "latest",
"passport-github": "latest",
"passport-google-oauth": "latest",
"underscore": "latest",
"async": "latest",
"view-helpers": "latest",
"mean-logger": "latest",
"forever": "latest",
"bower": "latest",
"grunt": "latest",
"grunt-cli": "latest",
"grunt-env": "latest"
},
"devDependencies": {
"supertest": "latest",
"should": "latest",
"grunt-contrib-watch": "latest",
"grunt-contrib-jshint": "latest",
"grunt-nodemon": "latest",
"grunt-concurrent": "latest",
"grunt-mocha-test": "latest"
}
"name": "mean",
"description": "MEAN - A Modern Stack: MongoDB, ExpressJS, AngularJS, NodeJS. (BONUS: Passport User Support).",
"version": "0.1.0",
"private": false,
"author": "Amos Haviv",
"repository": {
"type": "git",
"url": "https://github.com/linnovate/mean.git"
},
"engines": {
"node": "0.10.x",
"npm": "1.2.x"
},
"scripts": {
"start": "node node_modules/grunt-cli/bin/grunt",
"test": "node node_modules/grunt-cli/bin/grunt test",
"postinstall": "bower install"
},
"dependencies": {
"express": "latest",
"jade": "latest",
"mongoose": "latest",
"connect-mongo": "latest",
"connect-flash": "latest",
"crypto": "latest",
"passport": "latest",
"passport-local": "latest",
"passport-facebook": "latest",
"passport-twitter": "latest",
"passport-github": "latest",
"passport-google-oauth": "latest",
"underscore": "latest",
"async": "latest",
"view-helpers": "latest",
"mean-logger": "latest",
"forever": "latest",
"bower": "latest",
"grunt": "latest",
"grunt-cli": "latest",
"grunt-env": "latest"
},
"devDependencies": {
"supertest": "latest",
"should": "latest",
"grunt-contrib-watch": "latest",
"grunt-contrib-jshint": "latest",
"grunt-nodemon": "latest",
"grunt-concurrent": "latest",
"grunt-mocha-test": "latest",
"karma-script-launcher": "~0.1.0",
"karma-chrome-launcher": "~0.1.0",
"karma-firefox-launcher": "~0.1.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.3",
"karma-requirejs": "~0.1.0",
"karma-coffee-preprocessor": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.0",
"karma": "~0.10.4",
"grunt-karma": "~0.6.2",
"karma-coverage": "~0.1.0"
}
}
99 changes: 99 additions & 0 deletions test/karma/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Karma configuration
// Generated on Sat Oct 05 2013 22:00:14 GMT+0700 (ICT)

module.exports = function (config) {
config.set({

// base path, that will be used to resolve files and exclude
basePath: '../../',


// frameworks to use
frameworks: ['jasmine'],


// list of files / patterns to load in the browser
files: [
'public/lib/angular/angular.js',
'public/lib/angular-mocks/angular-mocks.js',
'public/lib/angular-cookies/angular-cookies.js',
'public/lib/angular-resource/angular-resource.js',
'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',
'public/lib/angular-bootstrap/ui-bootstrap.js',
'public/lib/angular-ui-utils/modules/route/route.js',
'public/js/app.js',
'public/js/config.js',
'public/js/directives.js',
'public/js/filters.js',
'public/js/services/global.js',
'public/js/services/articles.js',
'public/js/controllers/articles.js',
'public/js/controllers/index.js',
'public/js/controllers/header.js',
'public/js/init.js',
'test/karma/unit/**/*.js'
],


// list of files to exclude
exclude: [

],


// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
//reporters: ['progress'],
reporters: ['progress', 'coverage'],

// coverage
preprocessors: {
// source files, that you wanna generate coverage for
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
'public/js/controllers/*.js': ['coverage'],
'public/js/services/*.js': ['coverage']
},

coverageReporter: {
type : 'html',
dir : 'test/coverage/'
},

// 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,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['PhantomJS'],


// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};
Loading

0 comments on commit 673ac81

Please sign in to comment.