-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathnodetest.js
62 lines (53 loc) · 1.47 KB
/
nodetest.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
var jsdom = require("jsdom"),
fs = require("fs"),
requirejs = require("requirejs");
fs.readFile("qunit.html","utf8", function (err, data) {
jsdom.env(data, [], function(errors, window) {
//glabals needed for QUnit
(function() {
this.addEventListener = window.addEventListener;
this.location = this.location || {};
this.location.pathname= "";
this.location.search = "";
}.call());
document = window.document;
navigator = {userAgent: "nodejs"};
requirejs.config({
paths: {
Handlebars: 'libs/handlebars-1.0.8',
HandlebarsHelpers: 'ddl_builder/handlebarsHelpers',
DateFormat: 'libs/date.format',
DDLBuilder: 'ddl_builder',
QUnit: 'libs/qunit-1.10.0'
},
shim: {
Handlebars: {
exports: 'Handlebars'
},
DateFormat: {
exports: "dateFormat"
},
QUnit: {
exports: function () {
return { "test": test, "equal": equal, "ok": ok,
"load": QUnit.load, "done": QUnit.done };
}
}
}
});
// silly hack to push the proper jQuery reference into the requirejs cache
requirejs.define("jQuery", function () {
return require("jquery").create(window);
});
requirejs(["jQuery", "QUnit", "DDLBuilder/qunit/main"], function ($, QUnit) {
QUnit.load();
QUnit.done(function (details) {
console.log(details);
if ($("#qunit-tests li.fail").length) {
console.log($("#qunit-tests li.fail").html());
}
process.exit(details.failed);
});
});
});
});