-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
82 lines (77 loc) · 2.04 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
70
71
72
73
74
75
76
77
78
79
80
81
82
var path = require("path");
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
qunit: {
files: ['test/test.html'],
options: {
inject: [
path.resolve("test/coverage-bridge.js"),
require.resolve("grunt-contrib-qunit/phantomjs/bridge")
],
'--web-security': 'no'
}
},
instrument: {
files: 'public/js/*.js',
options: {
lazy: false,
basePath: 'coverage/instrumented/'
}
},
copy: {
// Moves files around during coverage runs
"save-origs": {
src: "public/js/cuchubo.js",
dest: "public/js/cuchubo.tmp.js"
},
"instrumented-to-origs": {
src: "coverage/instrumented/public/js/cuchubo.js",
dest: "public/js/cuchubo.js"
},
"restore-origs": {
src: "public/js/cuchubo.tmp.js",
dest: "public/js/cuchubo.js"
}
},
makeReport: {
src: 'coverage/reports/**/*.json',
options: {
type: 'lcov',
dir: 'coverage/reports',
print: 'detail'
}
},
coveralls: {
options: { // Options relevant to all targets
force: false
},
qunit: { //
src: 'coverage/reports/lcov.info',
options: { // Any options for just this target
}
}
}
});
grunt.event.on("qunit.coverage", function(coverage) {
var reportPath = "coverage/reports/ghini/coverage.json";
// Create the coverage file
grunt.file.write(reportPath, JSON.stringify(coverage));
});
// Load plugins
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-istanbul');
grunt.loadNpmTasks('grunt-coveralls');
// Task to run tests
grunt.registerTask('test', 'qunit');
grunt.registerTask('coverage', [
'test', // run first plain: if anything is wrong we stop here
'instrument',
'copy:save-origs',
'copy:instrumented-to-origs',
'test',
'copy:restore-origs',
'makeReport',
'coveralls']);
};