简体   繁体   中英

ReferenceError: loadFixtures is not defined

I'm setting up jasmine and jasmine-jquery libs in my project to test the jquery code. Jasmine is working fine but I'm not able to load jasmine-jquery.

I saw this but I don't know where to put jasmine-jquery lib?

GemFile:

  gem 'jasmine', '~> 2.3'
  gem 'jasmine-jquery-rails', '~> 2.0'

Error:

ReferenceError: loadFixtures is not defined
ReferenceError: loadFixtures is not defined
    at UserContext.<anonymous> (http://localhost:8888/__spec__/toggle_reviews_spec.js:3:5)
    at attempt (http://localhost:8888/__jasmine__/jasmine.js:4478:46)
    at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4402:20)
    at QueueRunner.execute (http://localhost:8888/__jasmine__/jasmine.js:4384:10)
    at Spec.queueRunnerFactory (http://localhost:8888/__jasmine__/jasmine.js:964:35)
    at Spec.execute (http://localhost:8888/__jasmine__/jasmine.js:563:10)
    at UserContext.fn (http://localhost:8888/__jasmine__/jasmine.js:5541:37)
    at attempt (http://localhost:8888/__jasmine__/jasmine.js:4486:26)
    at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4402:20)
    at QueueRunner.execute (http://localhost:8888/__jasmine__/jasmine.js:4384:10)

File that I want to test: toggle_review_spec.js

describe("toggle review", function(){
  beforeEach(function() {
    loadFixtures('toggle_reviews.html');
  });

  it("by default it shows created", function(){
    expect("#review-text").toHaveText("Created");
  });
});

I have a fixtures folder where I have created toggle_reviews.html

I want to load jasmine-jquery but I don't how to load it. Any idea where can I add jasmine-jquery lib?

Got it fixed by loading jquery.js and jasmine-jquery.js in yourProject/config/initializers/assets.rb file.

code:

Rails.application.config.assets.precompile += %w[jquery.js jasmine-jquery.js]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM