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

Commit 7252032

Browse files
committed
Adding coverage report for server-side tests using istanbul
1 parent 1f0f1b7 commit 7252032

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

gruntfile.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ module.exports = function (grunt) {
176176
reporter: 'spec'
177177
}
178178
},
179+
mocha_istanbul: {
180+
coverage: {
181+
src: testAssets.tests.server,
182+
options: {
183+
print: 'detail',
184+
coverage: true,
185+
require: 'test.js',
186+
coverageFolder: 'coverage',
187+
check: {
188+
lines: 40,
189+
statements: 40
190+
}
191+
}
192+
}
193+
},
179194
karma: {
180195
unit: {
181196
configFile: 'karma.conf.js'
@@ -252,6 +267,9 @@ module.exports = function (grunt) {
252267
grunt.registerTask('test', ['env:test', 'lint', 'mkdir:upload', 'copy:localConfig', 'server', 'mochaTest', 'karma:unit']);
253268
grunt.registerTask('test:server', ['env:test', 'lint', 'server', 'mochaTest']);
254269
grunt.registerTask('test:client', ['env:test', 'lint', 'server', 'karma:unit']);
270+
// Run project coverage
271+
grunt.registerTask('coverage', ['env:test', 'lint', 'mocha_istanbul:coverage']);
272+
255273
// Run the project in development mode
256274
grunt.registerTask('default', ['env:dev', 'lint', 'mkdir:upload', 'copy:localConfig', 'concurrent:default']);
257275

modules/articles/tests/server/article.server.model.tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ describe('Article Model Unit Tests:', function () {
4040

4141
describe('Method Save', function () {
4242
it('should be able to save without problems', function (done) {
43+
this.timeout(10000);
4344
return article.save(function (err) {
4445
should.not.exist(err);
4546
done();

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"grunt-env": "~0.4.4",
7575
"grunt-karma": "~0.11.2",
7676
"grunt-mocha-test": "~0.12.7",
77+
"grunt-mocha-istanbul": "^2.4.0",
7778
"grunt-ng-annotate": "^1.0.1",
7879
"grunt-node-inspector": "~0.2.0",
7980
"grunt-nodemon": "~0.4.0",

test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
var app, db, config;
7+
8+
var path = require('path');
9+
var app = require(path.resolve('./config/lib/app'));
10+
11+
app.init(function (app, db, config) {
12+
console.log('Initialized test automation');
13+
});

0 commit comments

Comments
 (0)