Returned empty shallowWrapper for every .find()
See original GitHub issueCurrent behavior
Exist component list based on custom ui-library components, it renders two cases - empty list and list of users
User list
function PatientList({ role, t, requestGetPatientList, patients: { data: patients = [] } = {} }) {
return (
<PageWrapper>
<Paper data-test="patientListBlock">
<Search placeholder={t('searchPlaceholder')} data-test="searchPatientInput" />
<FlexTableRow heading>
<FlexTableCol basis={250}>{t('patient.patientName')}</FlexTableCol>
<FlexTableCol basis={250}>{t('patient.patientId')}</FlexTableCol>
<FlexTableCol basis={200}>{t('dob')}</FlexTableCol>
<FlexTableCol basis={250}>{t('patient.deviceVendor')}</FlexTableCol>
<FlexTableCol>{t('patient.activationDate')}</FlexTableCol>
</FlexTableRow>
{mapIndex(
(item, index) => (
<PatientListRow key={index} index={index} {...item} />
),
patients,
)}
</Paper>
{patients.length > 0 ? (
<PaginationSection
activePage={1}
onPageChange={() => {}}
textKey="pagination.patients"
total={36}
/>
) : (
<FlexTableRow className={s.noPatientBlock}>No patients</FlexTableRow>
)}
</PageWrapper>
);
}
My tests covered that two cases, where I try use .find()
method for shallow wrapper
User list tests
describe('PatientList', () => {
let subject;
let patients
let requestGetPatientList;
let t;
beforeEach(() => {
requestGetPatientList = jest.fn();
t = fn => fn;
patients = { data: [...new Array(10)].map(() => ({})) }
});
const buildSubject = ({...rest}) => {
const props = {
patients,
requestGetPatientList,
t,
...rest
}
return shallow(
<PatientList {...props} />
)
}
it('renders correctly with patients', () => {
subject = buildSubject()
>>>>>>>>>> console.log(subject.find('div'))
expect(subject).toMatchSnapshot();
});
it('renders correctly with empty patients list', () => {
subject = buildSubject({ patients: {} })
expect(subject).toMatchSnapshot();
});
});
Snapshots
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`PatientList renders correctly with empty patients list 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <PatientList
patients={Object {}}
requestGetPatientList={[MockFunction]}
role="RC"
t={[Function]}
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"checkPropTypes": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<Unknown />,
<Paper
className={null}
data-test="patientListBlock"
>
<Search
className={null}
data-test="searchPatientInput"
placeholder="searchPlaceholder"
/>
<FlexTableRow
className={null}
component="div"
heading={true}
variant="default"
>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>
</FlexTableRow>
</Paper>,
<FlexTableRow
className="noPatientBlock"
component="div"
heading={false}
variant="default"
>
No patients
</FlexTableRow>,
],
"tight": false,
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<Search
className={null}
data-test="searchPatientInput"
placeholder="searchPlaceholder"
/>,
<FlexTableRow
className={null}
component="div"
heading={true}
variant="default"
>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>
</FlexTableRow>,
Array [],
],
"className": null,
"data-test": "patientListBlock",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"className": null,
"data-test": "searchPatientInput",
"placeholder": "searchPlaceholder",
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>,
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>,
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>,
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>,
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>,
],
"className": null,
"component": "div",
"heading": true,
"variant": "default",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.patientName",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.patientName",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.patientId",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.patientId",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 200,
"children": "dob",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "dob",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.deviceVendor",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.deviceVendor",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": undefined,
"children": "patient.activationDate",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.activationDate",
"type": [Function],
},
],
"type": [Function],
},
],
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "No patients",
"className": "noPatientBlock",
"component": "div",
"heading": false,
"variant": "default",
},
"ref": null,
"rendered": "No patients",
"type": [Function],
},
],
"type": [Function],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<Unknown />,
<Paper
className={null}
data-test="patientListBlock"
>
<Search
className={null}
data-test="searchPatientInput"
placeholder="searchPlaceholder"
/>
<FlexTableRow
className={null}
component="div"
heading={true}
variant="default"
>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>
</FlexTableRow>
</Paper>,
<FlexTableRow
className="noPatientBlock"
component="div"
heading={false}
variant="default"
>
No patients
</FlexTableRow>,
],
"tight": false,
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<Search
className={null}
data-test="searchPatientInput"
placeholder="searchPlaceholder"
/>,
<FlexTableRow
className={null}
component="div"
heading={true}
variant="default"
>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>
</FlexTableRow>,
Array [],
],
"className": null,
"data-test": "patientListBlock",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"className": null,
"data-test": "searchPatientInput",
"placeholder": "searchPlaceholder",
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>,
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>,
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>,
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>,
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>,
],
"className": null,
"component": "div",
"heading": true,
"variant": "default",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.patientName",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.patientName",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.patientId",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.patientId",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 200,
"children": "dob",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "dob",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.deviceVendor",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.deviceVendor",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": undefined,
"children": "patient.activationDate",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.activationDate",
"type": [Function],
},
],
"type": [Function],
},
],
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "No patients",
"className": "noPatientBlock",
"component": "div",
"heading": false,
"variant": "default",
},
"ref": null,
"rendered": "No patients",
"type": [Function],
},
],
"type": [Function],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"legacyContextMode": "parent",
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getChildContext": Object {
"calledByRenderer": false,
},
"getDerivedStateFromProps": Object {
"hasShouldComponentUpdateBug": false,
},
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;
exports[`PatientList renders correctly with patients 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <PatientList
patients={
Object {
"data": Array [
Object {},
Object {},
Object {},
Object {},
Object {},
Object {},
Object {},
Object {},
Object {},
Object {},
],
}
}
requestGetPatientList={[MockFunction]}
role="RC"
t={[Function]}
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"checkPropTypes": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<Unknown />,
<Paper
className={null}
data-test="patientListBlock"
>
<Search
className={null}
data-test="searchPatientInput"
placeholder="searchPlaceholder"
/>
<FlexTableRow
className={null}
component="div"
heading={true}
variant="default"
>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>
</FlexTableRow>
<PatientListRow
index={0}
/>
<PatientListRow
index={1}
/>
<PatientListRow
index={2}
/>
<PatientListRow
index={3}
/>
<PatientListRow
index={4}
/>
<PatientListRow
index={5}
/>
<PatientListRow
index={6}
/>
<PatientListRow
index={7}
/>
<PatientListRow
index={8}
/>
<PatientListRow
index={9}
/>
</Paper>,
<Unknown
activePage={1}
onPageChange={[Function]}
textKey="pagination.patients"
total={36}
/>,
],
"tight": false,
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<Search
className={null}
data-test="searchPatientInput"
placeholder="searchPlaceholder"
/>,
<FlexTableRow
className={null}
component="div"
heading={true}
variant="default"
>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>
</FlexTableRow>,
Array [
<PatientListRow
index={0}
/>,
<PatientListRow
index={1}
/>,
<PatientListRow
index={2}
/>,
<PatientListRow
index={3}
/>,
<PatientListRow
index={4}
/>,
<PatientListRow
index={5}
/>,
<PatientListRow
index={6}
/>,
<PatientListRow
index={7}
/>,
<PatientListRow
index={8}
/>,
<PatientListRow
index={9}
/>,
],
],
"className": null,
"data-test": "patientListBlock",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"className": null,
"data-test": "searchPatientInput",
"placeholder": "searchPlaceholder",
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>,
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>,
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>,
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>,
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>,
],
"className": null,
"component": "div",
"heading": true,
"variant": "default",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.patientName",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.patientName",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.patientId",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.patientId",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 200,
"children": "dob",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "dob",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.deviceVendor",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.deviceVendor",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": undefined,
"children": "patient.activationDate",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.activationDate",
"type": [Function],
},
],
"type": [Function],
},
Object {
"instance": null,
"key": "0",
"nodeType": "function",
"props": Object {
"index": 0,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "1",
"nodeType": "function",
"props": Object {
"index": 1,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "2",
"nodeType": "function",
"props": Object {
"index": 2,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "3",
"nodeType": "function",
"props": Object {
"index": 3,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "4",
"nodeType": "function",
"props": Object {
"index": 4,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "5",
"nodeType": "function",
"props": Object {
"index": 5,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "6",
"nodeType": "function",
"props": Object {
"index": 6,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "7",
"nodeType": "function",
"props": Object {
"index": 7,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "8",
"nodeType": "function",
"props": Object {
"index": 8,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "9",
"nodeType": "function",
"props": Object {
"index": 9,
},
"ref": null,
"rendered": null,
"type": [Function],
},
],
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"activePage": 1,
"onPageChange": [Function],
"textKey": "pagination.patients",
"total": 36,
},
"ref": null,
"rendered": null,
"type": [Function],
},
],
"type": [Function],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<Unknown />,
<Paper
className={null}
data-test="patientListBlock"
>
<Search
className={null}
data-test="searchPatientInput"
placeholder="searchPlaceholder"
/>
<FlexTableRow
className={null}
component="div"
heading={true}
variant="default"
>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>
</FlexTableRow>
<PatientListRow
index={0}
/>
<PatientListRow
index={1}
/>
<PatientListRow
index={2}
/>
<PatientListRow
index={3}
/>
<PatientListRow
index={4}
/>
<PatientListRow
index={5}
/>
<PatientListRow
index={6}
/>
<PatientListRow
index={7}
/>
<PatientListRow
index={8}
/>
<PatientListRow
index={9}
/>
</Paper>,
<Unknown
activePage={1}
onPageChange={[Function]}
textKey="pagination.patients"
total={36}
/>,
],
"tight": false,
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<Search
className={null}
data-test="searchPatientInput"
placeholder="searchPlaceholder"
/>,
<FlexTableRow
className={null}
component="div"
heading={true}
variant="default"
>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>
</FlexTableRow>,
Array [
<PatientListRow
index={0}
/>,
<PatientListRow
index={1}
/>,
<PatientListRow
index={2}
/>,
<PatientListRow
index={3}
/>,
<PatientListRow
index={4}
/>,
<PatientListRow
index={5}
/>,
<PatientListRow
index={6}
/>,
<PatientListRow
index={7}
/>,
<PatientListRow
index={8}
/>,
<PatientListRow
index={9}
/>,
],
],
"className": null,
"data-test": "patientListBlock",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"className": null,
"data-test": "searchPatientInput",
"placeholder": "searchPlaceholder",
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientName
</FlexTableCol>,
<FlexTableCol
basis={250}
style={Object {}}
>
patient.patientId
</FlexTableCol>,
<FlexTableCol
basis={200}
style={Object {}}
>
dob
</FlexTableCol>,
<FlexTableCol
basis={250}
style={Object {}}
>
patient.deviceVendor
</FlexTableCol>,
<FlexTableCol
style={Object {}}
>
patient.activationDate
</FlexTableCol>,
],
"className": null,
"component": "div",
"heading": true,
"variant": "default",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.patientName",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.patientName",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.patientId",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.patientId",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 200,
"children": "dob",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "dob",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": 250,
"children": "patient.deviceVendor",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.deviceVendor",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"basis": undefined,
"children": "patient.activationDate",
"className": undefined,
"style": Object {},
},
"ref": null,
"rendered": "patient.activationDate",
"type": [Function],
},
],
"type": [Function],
},
Object {
"instance": null,
"key": "0",
"nodeType": "function",
"props": Object {
"index": 0,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "1",
"nodeType": "function",
"props": Object {
"index": 1,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "2",
"nodeType": "function",
"props": Object {
"index": 2,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "3",
"nodeType": "function",
"props": Object {
"index": 3,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "4",
"nodeType": "function",
"props": Object {
"index": 4,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "5",
"nodeType": "function",
"props": Object {
"index": 5,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "6",
"nodeType": "function",
"props": Object {
"index": 6,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "7",
"nodeType": "function",
"props": Object {
"index": 7,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "8",
"nodeType": "function",
"props": Object {
"index": 8,
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": "9",
"nodeType": "function",
"props": Object {
"index": 9,
},
"ref": null,
"rendered": null,
"type": [Function],
},
],
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"activePage": 1,
"onPageChange": [Function],
"textKey": "pagination.patients",
"total": 36,
},
"ref": null,
"rendered": null,
"type": [Function],
},
],
"type": [Function],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"legacyContextMode": "parent",
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getChildContext": Object {
"calledByRenderer": false,
},
"getDerivedStateFromProps": Object {
"hasShouldComponentUpdateBug": false,
},
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;
Try use .find()
with another options (tag, class, comstructor), but every time return ShallowWrapper {}
Expected behavior
Return node list
Your environment
API
- shallow
- mount
- render
Version
library | version |
---|---|
enzyme | “^3.9.0” |
react | “^16.8.1” |
react-dom | “^16.8.1” |
react-test-renderer | - |
adapter (below) |
Adapter
- enzyme-adapter-react-16
- enzyme-adapter-react-16.3
- enzyme-adapter-react-16.2
- enzyme-adapter-react-16.1
- enzyme-adapter-react-15
- enzyme-adapter-react-15.4
- enzyme-adapter-react-14
- enzyme-adapter-react-13
- enzyme-adapter-react-helper
- others ( )
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Jest/Enzyme ShallowWrapper is empty when creating Snapshot
I faced the same issue after updating to jest@24.0.0 I have reverted to the previous version jest@23.6.0 for the time being till i...
Read more >Jest shallow return ShallowWrapper{}, how do I find elements ...
I declared a variable wrapper with the shallow() function, but using wrapper.find() I get nothing. I want to be able to find a...
Read more >SOLVED Empty ShallowWrapper Snapshot Object in Jest and ...
Here is the solution for when working with Jest v24 and above, developers are facing issue with Snapshot testing.
Read more >isEmpty() => Boolean - Enzyme - GitHub Pages
isEmpty() => Boolean. Deprecated: Use .exists() instead. Returns whether or not the wrapper is empty. Returns. Boolean : whether or not the wrapper...
Read more >Shallow Rendering API - Enzyme
Find every node in the render tree that return true for the provided predicate function. .filter(selector) => ShallowWrapper. Remove nodes in the current ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s not an empty shallow wrapper - that’s just how it’s logged. Try calling
.debug()
on it, or.length
?Thank you for detailed explanation! I got it, solved my problem