-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
69 lines (66 loc) · 2.52 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module.exports = function (grunt) {
// Add the grunt-mocha-test tasks.
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-keepalive');
grunt.loadNpmTasks('grunt-shell-spawn');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.initConfig({
// Configure a mochaTest task
mochaTest: {
test: {
options: {
reporter: 'spec',
captureFile: './data/logs/tests/results.txt', // Optionally capture the reporter output to a file
quiet: false, // Optionally suppress output to standard out (defaults to false)
clearRequireCache: false, // Optionally clear the require cache before running tests (defaults to false)
slow: 1 //time threshold in ms after which test execution time is mentioned in the console
},
src: ['tests/**/*.js']
}
},
shell: {
mongodb: {
command: 'mongod --dbpath ./data/testDB/db',
options: {
async: true,
stdout: false,
stderr: true,
failOnError: true,
execOptions: {
cwd: '.'
}
}
},
nodemon: {
command: 'nodemon bin/www',
options: {
async: true,
stdout: false,
stderr: true,
failOnError: true,
execOptions: {
cwd: '.'
}
}
}
},
env: {
test: {
NODE_ENV: 'TEST',
TEST_DB_URI: 'mongodb://localhost/artifacts-test-db'
}
},
clean:{
localTestDB:['./data/testDB/db/*', '!./data/testDB/db/.gitignore']
}
});
grunt.registerTask('instantiateServer', 'Start a custom web server', function () {
var server = require('./bin/www');
grunt.log.writeln('Express server listening on port ' + server.address().port);
});
grunt.registerTask('testServer', ['env:test','clean:localTestDB', 'shell:mongodb', 'instantiateServer']);
grunt.registerTask('localServer', ['instantiateServer', 'keepalive']);
grunt.registerTask('test', ['testServer', 'mochaTest', 'shell:mongodb:kill']);
grunt.registerTask('default', ['mochaTest']);
};