这个问题很可能是基于我以前没有使用node.js的经验,但我希望jasmine-node只是让我从命令行运行我的茉莉花规格。为什么茉莉花节点没有拿起我的帮手脚本?
TestHelper.js:
var helper_func = function() {
console.log("IN HELPER FUNC");
};
my_test.spec.js:
describe ('Example Test', function() {
it ('should use the helper function', function() {
helper_func();
expect(true).toBe(true);
});
});
那些在目录中仅有的两个文件。然后,当我这样做:
jasmine-node .
我得到
ReferenceError: helper_func is not defined
我敢肯定的答案,这是很容易的,但我没有找到任何超简单的前奏,或任何GitHub上明显。任何意见或帮助将不胜感激!
谢谢!
非常感谢!所以...要贪婪,可以以某种方式转换为运行在jasmine-node上并使用SpecRunner.html?当使用html版本时,我得到“出口未定义”和“需求未定义”。 – Hoopes 2012-04-10 18:45:26
我没有用过它,但我认为http://requirejs.org/会有所帮助。 – 2012-04-10 22:34:18
或者,如果(需要){... [加载文件] ...}'和'如果(!出口){var exports = window.helpers = {}}'',您可以做一些简单的解决方案 – 2012-04-10 22:38:04