-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhelper.js
45 lines (37 loc) · 1.09 KB
/
helper.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
"use strict";
// allow production modules to expose internal
// functions and properties for testing
process.env.NODE_ENV = "test";
var path = require("path");
var chai = require("chai");
var sinonChai = require("sinon-chai");
var Cylon = require("cylon");
Cylon.config({ logging: { logger: false } });
global.chai = chai;
global.should = chai.should();
global.expect = chai.expect;
global.assert = chai.assert;
global.AssertionError = chai.AssertionError;
global.sinon = require("sinon");
global.spy = sinon.spy;
global.stub = sinon.stub;
global.lib = function(src) {
var resource = path.normalize("../lib/" + src);
return require(resource);
};
// can be used when you expect a function to throw an error
global.err = function(fn, msg) {
try {
fn();
throw new chai.AssertionError({ message: "Expected an error" });
} catch (err) {
if (typeof msg === "string") {
chai.expect(err.message).to.equal(msg);
} else {
chai.expect(err.message).to.match(msg);
}
}
};
chai.use(sinonChai);
// if you want a detailed error stack output
// chai.Assertion.includeStack = true;