Пример #1
0
var test = require("suitestack"),
    assert = require("assert"),
    noOfTests = 0

// report
test.on("error", function (err) {
    console.error("FAIL:", err.message)
})

test.on("pass", function (name) {
    console.log("PASS:"******"test", function () {
    noOfTests++
})

test.on("test end", function () {
    noOfTests--
})

test.on("end", function () {
    assert(noOfTests === 0, "all tests did not finish")
    console.log("test finished")
})


// tests
test("A synchronous unit test", function () {
    assert.equal(true, true, "JavaScript hates us :(")
})
Пример #2
0
var test = require("suitestack"),
    assert = require("assert"),
    total = 0

// report
test.on("error", function (err, name) {
    console.error("FAIL:", err.message, err.stack, name)
})

test.on("test", function () {
    total++
})

test.on("test end", function () {
    total--
})

test.on("pass", function (name) {
    console.log("PASS:"******"end", function () {
    assert(total === 0, "tests did not finish")
    console.log("test finished")
})

// tests
test("test is a function", function () {
    assert(typeof test === "function", "test is not a function")
})