question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fixtures not loaded through 'jasmine-jquery'

See original GitHub issue

I’m trying to integrate Karma in a Backbone.js app. I’m using Jamine as Testing framework and jasmine-jquery as an extension. I’ve got a few fixtures (html and json) into the spec/javascript/fixtures folder and part of my karma.conf file looks like this:

// list of files / patterns to load in the browser
files = [
  JASMINE,
  JASMINE_ADAPTER,
  'public/javascripts/vendor/jquery.js',
  'public/javascripts/vendor/underscore-1.4.3.js',
  'public/javascripts/vendor/json2.js',
  'public/javascripts/vendor/backbone-0.9.2.js',
  'public/javascripts/**/*.js',
  'spec/javascripts/spec-helper.js',
  'spec/javascripts/support/jasmine-jquery-1.2.0.js',
  'spec/javascripts/support/jasmine-underscore.js',
  'spec/javascripts/support/sinon-1.1.1.js',
  'spec/javascripts/**/*.js',
  {
    pattern: 'spec/javascripts/fixtures/**/*.html',
    watched: true,
    included: false,
    served: true
  },
  {
    pattern: 'spec/javascripts/fixtures/*.json',
    watched: true,
    included: false,
    served: true
  }
];

In my spec-helper.js, I try to load the fixture with

'readFixtures("reference-data.json")'

and I start karma

karma start

I get that the fixture is not loaded and if I debug in the browser opened by Karma I get a 404 for the /spec/javascripts/fixtures/reference-data.json resource.

Missing anything?

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
vojtajinacommented, Apr 12, 2013

Just FYI, the karma object is exposed as window.__karma__ not window.karma.

1reaction
dignifiedquirecommented, Apr 11, 2013

You can test if you are using karma, e.g.

var path = '';
if (typeof window.karma !== 'undefined') {
  path += 'base/'
} 
jasmine.getFixtures().fixturesPath = path + 'spec/javascripts/fixtures';
Read more comments on GitHub >

github_iconTop Results From Across the Web

jasmine-jquery won't load any fixture - Stack Overflow
The fixtures need to be defined in the files list in karma.conf.js. Karma serves the files under the /base directory: ...
Read more >
Can't load HTML fixtures using jasmine-jquery : RSRP-337363
jasmine -jquery library https://github.com/velesin/jasmine-jquery provides a way to load HTML fixtures from external files. Unfortunately it does not load ...
Read more >
Loading External Fixtures with the Jasmine-jQuery Library
In today's tutorial, we used the jasmine-jquery library's set() function to provide a pre-initialized fixture. In the next instalment, ...
Read more >
HTML fixtures in Jasmine (using jasmine-jquery)
The most straightforward way is just to create a “fixture” jQuery element inside your spec, invoke your plugin on it and then set...
Read more >
[Solved]-Fixtures won't load in Karma-grunt.js
add it as a framework - frameworks: ['jasmine-jquery', 'jasmine'] · include your fixtures as patterns under the files array - { pattern: 'test/fixtures/*....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found