Backbone.js 无法使用sinon+;填充主干集合;茉莉花

Backbone.js 无法使用sinon+;填充主干集合;茉莉花,backbone.js,jasmine,sinon,Backbone.js,Jasmine,Sinon,我的问题和别人问的一样 问题的作者提到,他能够通过在无头webkit上使用jasmine的独立版本来解决这个问题。 在我的测试中,我只使用了jasmine的独立版本,但仍然存在相同的问题。 这是我的密码: describe 'Shared Collections Specs', -> describe 'Channel Collection', -> describe 'When fetching channels', -> responseFixtur

我的问题和别人问的一样

问题的作者提到,他能够通过在无头webkit上使用jasmine的独立版本来解决这个问题。 在我的测试中,我只使用了jasmine的独立版本,但仍然存在相同的问题。 这是我的密码:

describe 'Shared Collections Specs', ->
  describe 'Channel Collection', ->
    describe 'When fetching channels', ->
      responseFixture = null
      channelCollection = null
      server = null

      beforeEach ->
        channelCollection = new ChannelCollection()
        responseFixture = [{id: 3, name: 'foo'}, {id: 1, name: 'bar'}, {id: 2, name: 'baz'}]
        server = sinon.fakeServer.create()
        server.respondWith('GET', 'enspoint/channels', [
          200, {'Content-Type':'application/json'}, JSON.stringify responseFixture
        ])

      afterEach ->
        server.restore()

      it 'should populate the collection', ->
        channelCollection.fetch()
        server.respond()
        expect(channelCollection.length).toEqual responseFixture.length
集合总是空的,而不是预期的长度3。它失败,预期0等于3。 我尝试使用jasmine
等待
运行
,因为我认为在这个过程中可能会有一些异步的东西,但我得到了相同的结果


有什么想法吗?

这只是一个天真的观察,但XHR装置中的URL“enspoint/channels”可能有输入错误。例如,您是指“端点/通道”吗?

您是否也可以发布主干模型代码?