-
Notifications
You must be signed in to change notification settings - Fork 37
/
Gruntfile.js
112 lines (101 loc) · 2.75 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
* Example Gruntfile for Mocha setup
*/
'use strict';
module.exports = function(grunt) {
var port = 8981;
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
'tasks/**/*.js', ],
options: {
jshintrc: '.jshintrc'
}
},
watch: {
// If you want to watch files and run tests automatically on change
test: {
files: [
'example/js/**/*.js',
'example/test/spec/**/*.js',
'example-requirejs/js/**/*.js',
'example-requirejs/test/spec/**/*.js',
'phantomjs/*',
'tasks/*',
'Gruntfile.js'
],
tasks: 'test'
}
},
blanket_mocha : {
test: {
src: ['example/test.html'],
options : {
threshold : 60,
globalThreshold : 65,
log : true,
logErrors: true,
moduleThreshold : 60,
modulePattern : "./src/(.*?)/",
customThreshold: {
'./src/spelling/plurals.js': 50
}
}
},
test_requirejs: {
src: ['example-requirejs/test.html'],
options : {
threshold : 60,
globalThreshold : 65,
log : true,
logErrors: true,
moduleThreshold : 60,
modulePattern : "./src/(.*?)/",
customThreshold: {
'./src/spelling/plurals.js': 50
}
}
}
},
connect: {
testUrls: {
options: {
port: port,
base: '.'
}
},
testDest: {
options: {
port: port + 1,
base: '.'
}
}
}
});
grunt.registerTask('verifyDestResults', function () {
var expected = ['spec', 'xunit'];
expected.forEach(function (reporter) {
var output = 'example/test/results/' + reporter + '.out';
// simply check if the file is non-empty since verifying if the output is
// correct based on the spec is kind of hard due to changing test running
// times and different ways to report this time in reporters.
if (!grunt.file.read(output, 'utf8'))
grunt.fatal('Empty reporter output: ' + reporter);
// Clean-up
grunt.file.delete(output);
grunt.log.ok('Reporter output non-empty for %s', reporter);
});
});
// IMPORTANT: Actually load this plugin's task(s).
// To use grunt-mocha, replace with grunt.loadNpmTasks('grunt-mocha')
grunt.loadTasks('tasks');
// grunt.loadNpmTasks('grunt-mocha');
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-connect');
// By default, lint and run all tests.
grunt.task.registerTask('default', [
'jshint', 'blanket_mocha:test', 'blanket_mocha:test_requirejs'
]);
};