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

Commit

Permalink
Merge pull request #811 from lirantal/feature/code-coverage
Browse files Browse the repository at this point in the history
Adding coverage report for server-side tests using istanbul
  • Loading branch information
lirantal committed Sep 1, 2015
2 parents 0e3f638 + 7c286b0 commit 7051345
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/meanjs/mean?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/meanjs/mean.svg?branch=master)](https://travis-ci.org/meanjs/mean)
[![Dependencies Status](https://david-dm.org/meanjs/mean.svg)](https://david-dm.org/meanjs/mean)
[![Coverage Status](https://coveralls.io/repos/meanjs/mean/badge.svg?branch=master&service=github)](https://coveralls.io/github/meanjs/mean?branch=master)

MEAN.JS is a full-stack JavaScript open-source solution, which provides a solid starting point for [MongoDB](http://www.mongodb.org/), [Node.js](http://www.nodejs.org/), [Express](http://expressjs.com/), and [AngularJS](http://angularjs.org/) based applications. The idea is to solve the common issues with connecting those frameworks, build a robust framework to support daily development needs, and help developers use better practices while working with popular JavaScript components.

Expand Down
28 changes: 28 additions & 0 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ module.exports = function (grunt) {
reporter: 'spec'
}
},
mocha_istanbul: {
coverage: {
src: testAssets.tests.server,
options: {
print: 'detail',
coverage: true,
require: 'test.js',
coverageFolder: 'coverage',
reportFormats: ['cobertura','lcovonly'],
check: {
lines: 40,
statements: 40
}
}
}
},
karma: {
unit: {
configFile: 'karma.conf.js'
Expand Down Expand Up @@ -204,6 +220,15 @@ module.exports = function (grunt) {
}
});

grunt.event.on('coverage', function(lcovFileContents, done) {
require('coveralls').handleInput(lcovFileContents, function(err) {
if (err) {
return done(err);
}
done();
});
});

// Load NPM tasks
require('load-grunt-tasks')(grunt);

Expand Down Expand Up @@ -252,6 +277,9 @@ module.exports = function (grunt) {
grunt.registerTask('test', ['env:test', 'lint', 'mkdir:upload', 'copy:localConfig', 'server', 'mochaTest', 'karma:unit']);
grunt.registerTask('test:server', ['env:test', 'lint', 'server', 'mochaTest']);
grunt.registerTask('test:client', ['env:test', 'lint', 'server', 'karma:unit']);
// Run project coverage
grunt.registerTask('coverage', ['env:test', 'lint', 'mocha_istanbul:coverage']);

// Run the project in development mode
grunt.registerTask('default', ['env:dev', 'lint', 'mkdir:upload', 'copy:localConfig', 'concurrent:default']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('Article Model Unit Tests:', function () {

describe('Method Save', function () {
it('should be able to save without problems', function (done) {
this.timeout(10000);
return article.save(function (err) {
should.not.exist(err);
done();
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"grunt-env": "~0.4.4",
"grunt-karma": "~0.11.2",
"grunt-mocha-test": "~0.12.7",
"grunt-mocha-istanbul": "^2.4.0",
"grunt-ng-annotate": "^1.0.1",
"grunt-node-inspector": "~0.2.0",
"grunt-nodemon": "~0.4.0",
Expand Down Expand Up @@ -107,6 +108,7 @@
"load-grunt-tasks": "^3.2.0",
"run-sequence": "^1.1.1",
"should": "^7.0.1",
"supertest": "^1.0.1"
"supertest": "^1.0.1",
"coveralls": "^2.11.4"
}
}
13 changes: 13 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

/**
* Module dependencies.
*/
var app;

var path = require('path');
var app = require(path.resolve('./config/lib/app'));

app.init(function () {
console.log('Initialized test automation');
});

0 comments on commit 7051345

Please sign in to comment.