forked from tidev/alloy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.jake
executable file
·43 lines (37 loc) · 1.23 KB
/
test.jake
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
var fs = require('fs'),
path = require('path'),
jlib = require('../test/lib/jasmine'),
ConsoleReporter = require('../test/lib/ConsoleReporter'),
_ = require('../Alloy/lib/alloy/underscore');
process.env.ALLOY_TESTS = true;
path.existsSync = fs.existsSync || path.existsSync;
//globalize the Jasmine functions
_.extend(global, jlib);
//Set up Jasmine to print to the console with our custom printer
jasmine.getEnv().addReporter(new ConsoleReporter({
print: console.log,
showColors: true
}));
//run list of specs
function runSpecs(names) {
_.each(names, function(name) {
var fullpath = 'test/specs/' + name;
if (fs.statSync(fullpath).isDirectory()) {
fullpath = fullpath + '/index.js';
}
console.log('Loading test spec from "' + fullpath + '"');
require('../' + fullpath);
});
jasmine.getEnv().execute();
}
//Set up Jake namespace for testing
namespace('test', function() {
desc('run a specific Jasmine test spec, by name - e.g. jake test:spec[specName] or jake test:spec[spec1,spec2,spec3]');
task('spec', function() {
runSpecs(arguments);
});
desc('run all test specs in the spec directory - e.g. jake test:all');
task('all', function() {
runSpecs(fs.readdirSync(path.join(process.cwd(), 'test', 'specs')).reverse());
});
});