Buster.js - ReferenceError:断言没有定义,我做错了吗?

时间:2014-03-09 08:07:11

标签: javascript tdd assertion buster.js

这是错误消息:

 ReferenceError: assert is not defined
    at Object.buster.testCase.says hello to name var (./test/test-script.js:12:40)

file config buster.js:

var config = module.exports;

config["myTests"] = {
    rootPath: "../",
    environment: "browser",
    libs: ["*.js"],
    sources: ["start/script.js" ],
    tests: ["test/test-script.js"]
}; 

树文件:

main_dir/start : index.html; script.js
main_dir/test : buster.js; buster_063.js; test-script;
main_dir : jQuery.js; Mootools.js;

测试的script.js:

buster.testCase("Hello", {
    "says hello to name var": function(){ assert.equals( hello("Fulvio"), "Hello Fulvio" ); }
});

1 个答案:

答案 0 :(得分:4)

根据破坏者documentation,您应该采取以下措施:

var assert = buster.referee.assert;
var refute = buster.referee.refute;

assert.equals(42, 42);
refute.equals(42, 43);

根据您的test-script.js看起来如下:

buster.testCase("Hello", {
    "says hello to name var": function () {
        var assert = buster.referee.assert;

        assert.equals(hello("Fulvio"), "Hello Fulvio");
        return;
    }
});