首页 > 解决方案 > 测试覆盖颜色 - React Native App 的后端

问题描述

npm 运行测试:cov

服务器端编程非常新,需要一些指导。
在我下面的测试报告中,它说“如果”不包括在内。

在此处输入图像描述

无论我如何编写 if 逻辑,它都会引发此错误。
我该如何解决??
我应该在哪里寻找什么?

更新:

下面是我的测试数据:

const input = {
      applicationId,
      subApplicationId: 'test',
      alert: '0 General',
      badge: 1,
      sound: 'default',
      createDate: '2020-03-30T03:43:45.773Z',
      data: JSON.stringify({
        data: JSON.stringify({}),
      }),
    };
    await notificationService.create(input);

  });

  

  it('General', async () => {
    expect(
      await notificationController.retrieve(
        {
          applicationId,
          targetId: 'B9EF21EE-EA9B-4C9E-9D77-949A7A944AF9',
          requestDate: '2020-04-01T00:00:00.000Z',
        },
        buildRequest({ isAuthorized: false }),
      ),
    ).toHaveLength(3);
  });

  it('General + Personal', async () => {
    expect(
      await notificationController.retrieve(
        {
          applicationId,
          userId: '2019040913083656642537',
          targetId: 'B9EF21EE-EA9B-4C9E-9D77-949A7A944AF9',
          requestDate: '2020-04-01T00:00:00.000Z',
        },
        buildRequest({ isAuthorized: true }),
      ),
    ).toHaveLength(7);
  });

  it('General + Personal (with userId)', async () => {
    expect(
      await notificationController.retrieve(
        {
          applicationId,
          userId: '2019040913083656642537',
          requestDate: '2020-04-01T00:00:00.000Z',
        },
        buildRequest({ isAuthorized: true }),
      ),
    ).toHaveLength(2);
  });

标签: javascripttypescriptgraphqljestjsnestjs

解决方案


推荐阅读