问题
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>
回答1:
Make sure that you are loading Jasmine before you load the Jasmine-jQuery library.
回答2:
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)
回答3:
I ran into this when installing package with bower, but not initing bower_components directory first.
In this case, run:
bower init
and then re-install
bower install jasmine-jquery --save
来源:https://stackoverflow.com/questions/24531674/jasmine-jquery-loadfixtures-is-not-defined