【问题标题】:nock: is there a way to get a list of unsatisfaedMocks?nock:有没有办法得到 unsatisfaedMocks 的列表?
【发布时间】:2017-01-25 17:11:51
【问题描述】:

我想要这样的代码:

describe('populate', function() {
    it('should grab ', function() {
        nock('http://someapi.com')
            .post('/attractions')
            .reply(200, [])

        return request
          .post('http://someapi.com/wrong')
          .send({destId: id})
          .catch(() => 
            expect(nock.unsatisfaedMocks()).is.eql(['http://someapi.com/wrong'])
          )
    })
})

有可能吗?

【问题讨论】:

    标签: node.js mocking tdd nock


    【解决方案1】:

    当然可以

    我们通常坚持 assert.strictEqual(nock.isDone(), true, nock.pendingMocks())

    nock.isDone() 检查所有定义的 nock 是否被触发(全局) nock.pendingMocks() 返回未调用的 nocks 数组

    【讨论】:

      猜你喜欢
      • 2022-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-20
      • 1970-01-01
      • 2021-04-30
      • 1970-01-01
      相关资源
      最近更新 更多