Jasmine跳过了我所有的'it‘测试,除了describe块中的最后一个--我在测试中使用了coffeescript,我相信这可能是原因。当我查看由我的.coffee测试创建的已编译JS时,我发现只有最后一个' it‘测试的前面有'return’这个词,这可能是跳过其余测试的原因。
我的问题是,如何让它“返回”所有的测试?
最后一个测试在编译时的样子:
return it("should filter a range of prices", function() {它前面的是什么样子的(specrunner跳过了这些):
it("should filter a specific price", function() {发布于 2012-06-12 15:43:11
我尝试用一种不同的方式填充这个集合,现在它可以工作了。
当第一个测试被跳过时,我的测试是什么样子的(specrunner说1个规范通过了,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()不会导致这个问题,因为它在第二个测试中有效。我不知道为什么这很重要..
https://stackoverflow.com/questions/10985318
复制相似问题