我如何通过Nock检查Chai的状态

时间:2018-09-02 11:28:56

标签: node.js unit-testing chai nock

我正在编写单元测试,我遇到了问题,我的问题是我无法处理http状态。这就是我所做的,

  describe('Should return 400 bad request', () => {
    before(() => {
      const { get400, baseUrl } = BillingMock.getPaymentSummary;
      const mockHttp = nock(baseUrl);

      mockHttp.get(get400.req.path).reply(get400.res.httpStatus, get400.res);
    });
    it('Should return 400 bad request', async () => {
      const { get400 } = BillingMock.getPaymentSummary;
      const { req, res } = get400;
      const callback = () => BillingApi.getPaymentSummary(req);
      await callback().should.have.status(404);
    });
  });

0 个答案:

没有答案