0
我想從本地文件夾中加載json,然後將其饋入函數來測試它。這裏是我想要做的事:Angular-Jasmine,加載json
it('should be able to use treatExpResultJSON() function to treat incoming JSON', function() {
require(['./jsonSampleData.json'], function(json){
expect(dirService.treatExpResultJSON(json)).not.toBeNull();
expect(dirService.treatExpResultJSON(json)).not.toBeUndefined();
console.log(json);
console.log("Testing json passed!");
});
});
expect
是不require
回調函數內的工作,我想,這是不是在所有的,因爲既.not.toBeNull()
,not.toBeUndefined()
和.toBeNull()
,toBeUndefined()
的測試顯示出成功稱爲。此外,console.log()
不在該功能內部工作。那麼,我應該如何加載json,然後將其提供給函數?