Cooper Maruyama
Cooper Maruyama

Reputation: 1612

jasmine + coffeescript - jasmine skipping tests

Jasmine is skipping all my 'it' tests except the last one in a describe block - I'm using coffeescript in my tests and I believe this may be the reason. When i look at the compiled JS created by my .coffee tests, I see that only the last 'it' test has the word 'return' before it, which is probably why the rest of the tests are being skipped.

My question is, how can I get it to 'return' all the tests?

what the last test looks like when compiled:

return it("should filter a range of prices", function() {

what the ones before it look like (these are being skipped by the specrunner):

it("should filter a specific price", function() {

Upvotes: 2

Views: 1606

Answers (1)

Cooper Maruyama
Cooper Maruyama

Reputation: 1612

I tried populating the collection a different way and now it works.

What my tests looked like when the first one was being skipped (specrunner said 1 spec passed, 0 skipped with this code):

describe "Products Collection", ->
    it "should filter a specific price", ->
        products = new Wishlist.Collections.Products
        products.add({name: 'product1', price: 15.99})
        products.add({name: 'product2', price: 21.99})
        products.add({name: 'product3', price: 21.99})
        products.add({name: 'product4', price: 1.99} )
        match = products.where({price: 21.99})
        expect(match.length).toBe(2)

    it "should filter a range of prices", ->
        products = new Wishlist.Collections.Products
        products.add({name: 'product1', price: 15.99})
        products.add({name: 'product2', price: 21.99})
        products.add({name: 'product3', price: 21.99})
        products.add({name: 'product4', price: 1.99})
        expect(products.priceFilter(16,25).size()).toBe(2)

what they look like now (working correctly):

describe "Products Collection", ->
    it "should filter a specific price", ->
        products = new Wishlist.Collections.Products [{name: 'product1', price: 15.99}, {name: 'product2', price: 21.99}, {name: 'product3', price: 21.99}, {name: 'product4', price: 1.99}]
        match = products.where({price: 21.99})
        expect(match.length).toBe(2)

    it "should filter a range of prices", ->
        products = new Wishlist.Collections.Products
        products.add({name: 'product1', price: 15.99})
        products.add({name: 'product2', price: 21.99})
        products.add({name: 'product3', price: 21.99})
        products.add({name: 'product4', price: 1.99})
        expect(products.priceFilter(16,25).size()).toBe(2)

As you can see, using products.add() couldn't be causing the issue, since it works in the 2nd test. I've no clue why it mattered..

Upvotes: 1

Related Questions