jazmín + coffeescript - pruebas de omisión de jazmín

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() {

preguntado el 11 de junio de 12 a las 19:06

the specrunner is telling me 1 spec passed when in fact there are 2 specs. I fixed it, but I don't know why it fixed it. read below -

1 Respuestas

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..

Respondido 28 Jul 15, 14:07

I don't see any relevant change either. The return value should not matter (as it's the invocation of it that registers the test and not the return value). Sidenote: you can get rid of the round braches in your products.add calls, which would improve readability (IMO). - Joaquín Sauer

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.