茉莉花穿梭在咕噜噜唧唧喳喳的失败

我为我的插件创build了一些茉莉花testing。

他们都通过浏览器(铬),但由于某种原因,当我在我的terminal使用“grunt-contrib-jasmine”任务,他们大多失败。

这里是一个例子:

it("scroll to the correct floor", function() { // return and instance of my plugin (ascensor) var ascensor = getInstanceOfAscensor({}); var floorArray; // Triggered when 'next' is triggered ascensor.on("scrollStart", function(event, floor) { // floor look like {from:0, to:1} floorArray = floor; }); // trigger an 'next' event which // trigger a 'scrollStart' // event inside the plugin ascensor.trigger("next"); // Spec expect(floorArray.from).toBe(0); expect(floorArray.to).toBe(1); }); Terminal Output: TypeError: 'undefined' is not an object (evaluating 'floorArray.from') 

完整的testing: https : //github.com/kirkas/Ascensor.js/blob/master/test/spec/optionsSpec.js

我发现这个问题,我使用了jasmine-jquery中的loadFixtures函数,它指向一个相对path( "spec/javascripts/fixtures" )。

解决的办法是把这条线放在我testing的顶部,这是指夹具文件夹。

 jasmine.getFixtures().fixturesPath = 'path/to/your/fixture';