为什么我的模拟商店不能在Jest / Enzyme上使用?

时间:2019-01-17 22:31:00

标签: javascript reactjs unit-testing ecmascript-6 jestjs

根据Jest测试日志,我在下面的代码块中缺少第67行的覆盖范围

export default compose(
  connect(store => ({ // LINE 67
    accountGuid: store.global.accountGuid,
    shipmentsCSV: store.shipments.shipmentsCSV,
  })),
  translate(),
)(DownloadCSVItem);

这是我对该组件的测试:

import React from 'react';
import { mount } from 'enzyme';
import DownloadCSVItem from '../../DownloadCSVItem';
import createMockStore from '../../../../utils/createMockStore';

describe('DownloadCSVItem component', () => {
  let props;

  beforeEach(() => {
    props = {
      t: k => k,
      accountGuid: 'abcd-1234',
      shipmentsCSV: {
        itemsCount: 2,
        shipments: [
          {
            Courier: 'Hand Delivery',
            Note: 'Testing the data transfer request system. ',
          },
          {
            Courier: null,
            Note: null,
          },
        ],
      },
    };
  });

  it('renders DownloadCSVItem and check if class exists', () => {
    const wrapper = mount(
      <DownloadCSVItem.WrappedComponent {...props}
        store={createMockStore({
          global: { accountGuid: props.accountGuid },
          shipments: {
            totalCount: props.shipmentsCSV.itemsCount,
            shipments: props.shipmentsCSV.shipments,
          },
        })}
      />,
    );
    expect(wrapper.find('button')).toHaveLength(1);
  });

});

我编写了该测试并运行了该命令以对其进行测试,但仍然显示缺少第67行的覆盖范围。

在这种情况下我该怎么办?

0 个答案:

没有答案