app/Gruntfile.js
module.exports = (grunt) => {
grunt.file.setBase('..');
require('load-grunt-tasks')(grunt);
grunt.initConfig({
express: {
dev: {
options: {
script: 'app/index.js',
node_env: 'dev',
port: process.env.PORT,
output: 'started'
}
}
},
mochaTest: {
unit: {
options: {
reporter: 'spec',
quiet: false, // Optionally suppress output to standard out (defaults to false)
clearRequireCache: true
},
src: ['app/test/unit/**/*.test.js']
},
e2e: {
options: {
reporter: 'spec',
quiet: false, // Optionally suppress output to standard out (defaults to false)
clearRequireCache: true, // Optionally clear the require cache before running tests (defaults to false)
timeout: 100000,
},
src: ['app/test/e2e/**/*.spec.js']
}
},
watch: {
options: {
livereload: 35730
},
jssrc: {
files: [
'app/src/**/*.js',
],
tasks: ['express:dev'],
options: {
spawn: false
}
},
e2eTest: {
files: [
'app/test/e2e/**/*.spec.js',
],
tasks: ['express:test', 'mochaTest:e2e'],
options: {
spawn: true
}
},
},
nyc: {
cover: {
options: {
include: ['app/src/**'],
exclude: '*.test.*',
reporter: ['lcov', 'text-summary'],
reportDir: 'coverage',
all: true
},
cmd: false,
args: ['grunt', '--gruntfile', 'app/Gruntfile.js', 'mochaTest:e2e']
}
}
});
grunt.registerTask('e2eTest-watch', ['watch:e2eTest']);
grunt.registerTask('test', ['mochaTest:e2e', 'mochaTest:unit']);
grunt.registerTask('serve', ['express:dev', 'watch']);
grunt.registerTask('default', 'serve');
grunt.loadNpmTasks('grunt-simple-nyc');
};