即時通訊運行一個rails應用程序,即時通訊運行單元測試在Javascript端(使用茶匙/茉莉花)。單元測試中的「ReferenceError:Can not find variable:Mustache」?
有趣的是,在函數我打電話我知道Mustache.render
功能正在工作(我能夠console.log它的返回值(這是Mustache.render
函數),並看到它正在工作。但是,當我調用該函數從我的單元測試即時得到一個:
Failure/Error: ReferenceError: Can't find variable: Mustache
僅供參考我真的不叫鬍子渲染功能直接IM簡單地調用使用它的功能,並抓住它的返回值再次檢查
。我已經能夠成功地gr ab和使用各種其他功能,並使用它們就好,這只是給我麻煩。 Mustache.render對象可以不存在於它自己的文件或範圍之外嗎?
編輯:示例代碼:
_makeSomething: function viewMakeSomething(data) {
const template = templates.something;
return Mustache.render(document.querySelector(template).innerHTML, data);
}
和我的測試代碼很簡單:
it('_makeSomething object', function() {
let obj = {id: 1234, content: "_makeSomething Assertion", author: "Test User"}
let $something = _makeSomething(obj);
});
(現在我只是在拍攝之前,我斷言任何東西,或分裂它的/ etc ...但它只是在調用它)
你能顯示代碼,好嗎? – Torben
當然,我會添加一個編輯。 – msmith1114