unit Test
코드검사
- 동료검토
- Code linter
- 코드검사(Code Coverage)
- run ./test/*.jsmocha before each
1
var module = require("../module");
2
3
var chai = require("chai");
4
var expect = char.expect;
5
6
describe("module", function () {
7
it("test name 1", function () {
8
expect(module("variables1", ...)).to.equal("expectedValue1");
9
...
10
});
11
it("test name 2", function () {
12
expect(module("variables2", ...)).to.euqal("expectedValue2");
13
...
14
});
15
...
16
});
error test1
describe("User", function () {
2
var user;
3
beforeEach(function () {
4
user = new User({
5
firstName: "fname",
6
lastName: "lname"
7
});
8
});
9
10
it("something", function () {
11
expect(user.getName()).to.equal("fname lname");
12
});
13
//...
14
})
not1
//...
2
it("throws an error", function() {
3
expect(function() { capitalize(123); }).to.throw(Error);
4
});
5
//...
1
//...
2
if("changes the value", function () {
3
expect(capitalize("foo")).not.to.expect("foo");
4
});
5
//...
EndPoint Test