[英]How to access Nested component in Enzyme React testing
import React from "react";
import Adapter from "enzyme-adapter-react-16";
import { configure, shallow, mount } from "enzyme";
import Banking, { BankingForm } from './Banking';
configure({ adapter: new Adapter() });
describe('FormikHandlers', () => {
describe('handleChange', () => {
it('change value for firstBankName', async () => {
const component = shallow(<Banking />);
expect(component.find(BankingForm)).toHaveLength(1);
});
});
});
在這里,我具有“銀行業務”作為父組件,而“銀行業務窗體”作為具有所有字段的子組件。 我在Baking父組件中使用formik render prop。 該測試失敗,因為淺淺呈現時無法在組件內部獲取“ BankingForm”組件。 我在做些錯誤的觀點嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.