最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jasmine-jQuery loadFixtures is not defined - Stack Overflow

programmeradmin5浏览0评论

I'm still new to the whole jasmine things and in past few hours I stuck in this problem. I tried to load an external fixture file using loadFixture(). I use Jasmine 2.0.0 and Jasmine-jQuery 2.0.5.

ReferenceError: loadFixtures is not defined
  at Suite.<anonymous> (--appname--/app/assets/Tester/spec/ChannelSpec.js:5:6)
  at Env.describe (--appname--/app/assets/Tester/lib/jasmine-2.0.0/jasmine.js:613:25)
  at jasmineInterface.describe (--appname--/app/assets/Tester/lib/jasmine-2.0.0/boot.js:37:18)
  at Suite.<anonymous>  (--appname--/app/assets/Tester/spec/ChannelSpec.js:2:3)
  at Env.describe (--appname--/app/assets/Tester/lib/jasmine-2.0.0/jasmine.js:613:25)
  at jasmineInterface.describe (--appname--/app/assets/Tester/lib/jasmine-2.0.0/boot.js:37:18)
  at --appname--/app/assets/Tester/spec/ChannelSpec.js:1:1

while in Chromium console

Uncaught TypeError: Cannot set property 'spiedEventsKey' of undefined

this is the line in ChannelSpec.js

1. describe('Channel', function() {
2.  describe('Test Restriction', function() {
3.     var $httpBackend,service;
4.     // jasmine.getFixtures().proxyCallTo_('load', 'fixtures.html')
5.     loadFixtures('fixtures.html');

I work on Ubuntu 14.04 and primarily use Chromium but I tried on Firefox as some people suggested that it's Same-Origin Policy, but it produced similar error.

---Solved---

It's solved by loading jasmine-jquery last

<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/boot.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-jquery.js"></script>

I'm still new to the whole jasmine things and in past few hours I stuck in this problem. I tried to load an external fixture file using loadFixture(). I use Jasmine 2.0.0 and Jasmine-jQuery 2.0.5.

ReferenceError: loadFixtures is not defined
  at Suite.<anonymous> (--appname--/app/assets/Tester/spec/ChannelSpec.js:5:6)
  at Env.describe (--appname--/app/assets/Tester/lib/jasmine-2.0.0/jasmine.js:613:25)
  at jasmineInterface.describe (--appname--/app/assets/Tester/lib/jasmine-2.0.0/boot.js:37:18)
  at Suite.<anonymous>  (--appname--/app/assets/Tester/spec/ChannelSpec.js:2:3)
  at Env.describe (--appname--/app/assets/Tester/lib/jasmine-2.0.0/jasmine.js:613:25)
  at jasmineInterface.describe (--appname--/app/assets/Tester/lib/jasmine-2.0.0/boot.js:37:18)
  at --appname--/app/assets/Tester/spec/ChannelSpec.js:1:1

while in Chromium console

Uncaught TypeError: Cannot set property 'spiedEventsKey' of undefined

this is the line in ChannelSpec.js

1. describe('Channel', function() {
2.  describe('Test Restriction', function() {
3.     var $httpBackend,service;
4.     // jasmine.getFixtures().proxyCallTo_('load', 'fixtures.html')
5.     loadFixtures('fixtures.html');

I work on Ubuntu 14.04 and primarily use Chromium but I tried on Firefox as some people suggested that it's Same-Origin Policy, but it produced similar error.

---Solved---

It's solved by loading jasmine-jquery last

<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/boot.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-jquery.js"></script>
Share Improve this question edited May 23, 2017 at 12:01 CommunityBot 11 silver badge asked Jul 2, 2014 at 12:56 Riyad RivandiRiyad Rivandi 681 silver badge8 bronze badges 4
  • Can you see that jasmine-jquery.js is loading properly if you look in firebug/developer tools? – Nick Commented Jul 2, 2014 at 13:09
  • Sorry for the late response. Using Firefox, in console i can click on the link to jasmine-jquery.js (left of the error definition) with no problem. It also shows on "Debugger -> Source". I've also redownloaded it twice in case of corrupted file. – Riyad Rivandi Commented Jul 3, 2014 at 2:29
  • Are you loading all of the relevant jasmine libs before jasmine-jquery? I am loading jasmine.js, jasmine-html.js and boot.js first. – Nick Commented Jul 3, 2014 at 8:08
  • Derp, that solved it! I didn't know that script order is very important in JS. Thanks Nick ! – Riyad Rivandi Commented Jul 3, 2014 at 8:37
Add a ment  | 

3 Answers 3

Reset to default 4

Make sure that you are loading Jasmine before you load the Jasmine-jQuery library.

Yes, and if you use require.js you should set up dependencies in shim configuration:

requirejs.s.contexts._.config.shim["jasmine-jquery"] = {
   deps: ['jasmine', 'jquery'], 
   exports: 'jasmine-jquery'
}

just for example, if you start your tests on the same port and use the same require.js config, as in main application ("requirejs.s.contexts._.config" is a quick way to patch require config in jasmine runner)

I ran into this when installing package with bower, but not initing bower_ponents directory first.

In this case, run:

bower init

and then re-install

bower install jasmine-jquery --save
发布评论

评论列表(0)

  1. 暂无评论