1
我是jasmine.js框架的新手。Jasmine.js V2.0.0 - 讀取燈具數據 - TypeError:undefined不是函數在對象
什麼是這個代碼的問題:
beforeEach(function(){
var fixtureUrl = "/../path/to/templates/home.html";
var html = jasmine.getFixtures().read(fixtureUrl);
console.log(html);
});
我得到一個錯誤:
類型錯誤:未定義是不是對象的函數。
TypeError: undefined is not a function at Object<anonymous> (http://{MY_LOCAL_DOMAIN}/test/jasmine2/spec/home.view.spec.js:15:23)
at attemptSync (http://{MY_LOCAL_DOMAIN}/test/jasmine2/libs/jasmine-2.0.0/jasmine.js:1510:12)
at QueueRunner.run (http://{MY_LOCAL_DOMAIN}/test/jasmine2/libs/jasmine-2.0.0/jasmine.js:1498:9)
at QueueRunner.execute (http://{MY_LOCAL_DOMAIN}/test/jasmine2/libs/jasmine-2.0.0/jasmine.js:1485:10)
at Spec.Env.queueRunnerFactory (http://{MY_LOCAL_DOMAIN}/test/jasmine2/libs/jasmine-2.0.0/jasmine.js:518:35)
at Spec.execute (http://{MY_LOCAL_DOMAIN}/test/jasmine2/libs/jasmine-2.0.0/jasmine.js:306:10)
at Object.<anonymous> (http://{MY_LOCAL_DOMAIN}/test/jasmine2/libs/jasmine-2.0.0/jasmine.js:1708:37)
at attemptAsync (http://{MY_LOCAL_DOMAIN}/test/jasmine2/libs/jasmine-2.0.0/jasmine.js:1520:12)
at QueueRunner.run (http://{MY_LOCAL_DOMAIN}/test/jasmine2/libs/jasmine-2.0.0/jasmine.js:1496:16)
at QueueRunner.execute (http://{MY_LOCAL_DOMAIN}/test/jasmine2/libs/jasmine-2.0.0/jasmine.js:1485:10)
我使用: Jasmine.js,茉莉花,html.js和茉莉版本boot.js 2.0.0和茉莉花,jQuery的版本2.1.0
在我應用程序中,我使用spec.config.js加載所有必要的文件包括:按以下順序:
paths: {
...,
...,
...,
'jasmine': '../test/jasmine2/libs/jasmine-2.0.0/jasmine',
'jasmine-html':'../test/jasmine2/libs/jasmine-2.0.0/jasmine-html',
'boot': '../test/jasmine2/libs/jasmine-2.0.0/boot',
'jasmine-jquery':'../test/jasmine2/libs/jasmine-2.0.0/jasmine-jquery',
'sinon': '../test/jasmine2/libs/sinon-1.9.1/sinon',
}
而且我定義爲我的規格文件爲:
describe('Home', function() {
define(['views/home.view','jasmine','jasmine-jquery'], function(HomeView,Jasmine,JasmineJQuery) {
....
var home_view = new HomeView();
var jasmine = Jasmine;
var jasmine_jquery = JasmineJQuery;
....
});
beforeEach(function(){
var fixtureUrl = "/../path/to/templates/home.html";
var html = jasmine.getFixtures().read(fixtureUrl);
console.log(html);
});
it('should check home is rendred', function() {
{SOME TESTING HERE...}
});
});
任何一個可以幫助我讀燈具數據,並檢查toHaveId( 「{} SOME_DIV_ID」)?