'您好,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();
});
});