2012-06-11 2 views
2

Jasmine은 설명 블록의 마지막 테스트를 제외한 모든 'it'테스트를 건너 뜁니다. 테스트에 coffeescript를 사용하고 있는데 이것이 이유라고 생각합니다. 내 .coffee 테스트로 작성된 컴파일 된 JS를 보면 마지막 'it'테스트에만 'return'이라는 단어가 있다는 것을 볼 수 있는데, 나머지 테스트가 생략 된 것일 수 있습니다.jasmine + coffeescript - jasmine 스킵 테스트

내 질문은 어떻게 모든 테스트를 '반환'할 수 있습니까? 마지막 테스트가 컴파일 할 때의 모습

:

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

가 (이이 specrunner가 생략되고있다)과 같이 전에 사람들 무엇 :

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

specrunner는 실제로 2 개의 스펙이있을 때 specrunner가 1 스펙을 전달한다고 말하고있다. 나는 그것을 고쳤지만, 왜 고쳐야할지 모르겠다. 아래에서 읽으십시오 –

답변

1

나는 컬렉션 a를 채우는 시도 다른 방법과 지금 그것은 작동합니다. 내 테스트는 첫 번째가 생략 될 때 어떻게 생겼는지

(specrunner는 0이 코드를 생략 한 사양 통과했다) :

그들은 지금 어떤 모습인지
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) 

(제대로 작동) :

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) 

두 번째 테스트에서 작동하므로 products.add()를 사용하면 문제가 발생하지 않을 수 있습니다. 나는 그것이 중요한 이유를 전혀 모른다.

+1

관련 변경 사항이 표시되지 않습니다. 반환 값은 중요하지 않아야합니다 (반환 값이 아닌 테스트를 등록하는 'it'호출이므로). Sidenote :'products.add' 호출에서 라운드 가드를 없애면 가독성이 향상됩니다 (IMO). –

관련 문제