-
Notifications
You must be signed in to change notification settings - Fork 0
/
specs.js
49 lines (40 loc) · 1.39 KB
/
specs.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
var jasmine = require('jasmine-node');
var Path= require('path');
var SPEC_FOLDER= Path.join(process.cwd(), 'spec'),
SPEC_MATCHER_REGEX= "Spec\.(js|coffee)$",
HELPER_MATCHER_REGEX= "Helper\.(js|coffee)$";
for (var key in jasmine)
global[key] = jasmine[key];
var isVerbose = false;
var showColors = true;
var spec = SPEC_MATCHER_REGEX;
function escapeRegex(text) {
return text.replace(escapeRegex._escapeRegex, '\\$1');
}
/** The special characters in a string that need escaping for regular expressions. */
escapeRegex.specialCharacters= ['/', '.', '*', '+', '?', '|',
'(', ')', '[', ']', '{', '}', '\\'];
/** A regular expression that will match any special characters that need to be
escaped to create a valid regular expression. */
escapeRegex._escapeRegex= new RegExp('(\\'+ escapeRegex.specialCharacters.join("|\\") + ')', 'g');
process.argv.forEach(function(arg, index){
switch(arg){
case '--color':
showColors = true;
break;
case '--noColor':
showColors = false;
break;
case '--verbose':
isVerbose = true;
break;
default:
if (index>1)
spec= "^.*/" + escapeRegex(arg) + "$";
break;
}
});
jasmine.loadHelpersInFolder(SPEC_FOLDER, HELPER_MATCHER_REGEX);
jasmine.executeSpecsInFolder(SPEC_FOLDER, function(runner, log){
process.exit(runner.results().failedCount);
}, isVerbose, showColors, spec);