這個問題很可能是基於我以前沒有使用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