玩笑测试失败,并带有Expect(jest.fn())。toHaveBeenCalled()

时间:2018-12-12 18:55:21

标签: reactjs jestjs

'您好,Jest Testing的新手,我试图创建一个验证运行功能的测试。但是,它失败了,但我不确定为什么。具有相同结构的其他测试已通过。任何见解,将不胜感激。

从'react'导入React;

import Feed from 'components/Feed/Feed';
import feedContent from 'components/Feed/mock-data.json';

describe('Component', () => {
    let spyFuncArr = ['_renderCards'];
    let wrapper;
    let instanceSpies = {};


  beforeEach(() => {
    wrapper = shallow(<Feed content={feedContent} />);
    instanceSpies = createSpyArr(spyFuncArr, Feed);
  });


  describe('--- Rendering ---', () => {
    it("Component Renders", () => {
      expect(wrapper).toMatchSnapshot();
    });
  });

  describe('--- Functionality ---', () => {
    it("should run _renderCards", () => {
      expect(instanceSpies["_renderCards"]).toHaveBeenCalled();
    });
  });

0 个答案:

没有答案