jasmine-jquery now has JSON Fixtures

On my current project, I found the need for some pretty large data structures to test some of our growing Javascript code base. We’re using jasmine and jasmine-jquery. `jasmine-jquery` gives us the ability to easily pull in HTML fixture data on which we can run plugins etc. But there was no way to get JSON fixture data easily into the test framework. Instead of writing huge chunks at the top of the spec file that read

var test_data = [
   blah blah blah

var more_complex_test_data = {
   blah blah

I decided to add that functionality into jasmine-jquery. And my pull request was accepted in no time.

Now with jasmine-jquery, you can add to your jasmine specs (these are in CoffeeScript, but you get the idea) :

describe 'MyNewThing', ->
  beforeEach ->
    fixture1 = getJsonFixture('fixture1.json')
    @testable = new MyNewThing(fixture1)
  it 'does the right thing with data' ->
    expect(@testable).to ...

Thanks to Travis Jeffery for merging in the pull request.

Keep testing!


One thought on “jasmine-jquery now has JSON Fixtures

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s