I have these dev dependencies installed:
"devDependencies": {
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.6",
"jest-enzyme": "7.1.2"
},
This is my test code:
const onClickSpy = jest.fn();
const wrapper = shallow(
<MessageItem
message=
deleteMessageFromTable={onClickSpy}
/>
);
I have a wrapper wich contains the following:
<div class="MuiPaper-root-7 MuiPaper-elevation8-17 MuiPaper-rounded-8 MuiCard-root-6">
<div class="MuiCardContent-root-34">
<p class="MuiTypography-root-35 MuiTypography-body1-44 MuiTypography-colorTextSecondary-68 MuiTypography-gutterBottom-62 MessageItem-title-5">
testmessage
</p>
</div>
<div class="MuiCardActions-root-71">
<button
class="MuiButtonBase-root-100 MuiButton-root-74 MuiButton-text-76 MuiButton-flat-79 MuiButton-sizeSmall-97 MessageItem-cardclearbutton-1 MuiCardActions-action-73"
tabindex="0"
type="button"
id="button-messageitem-1"
>
<span class="MuiButton-label-75">Clear</span>
</button>
</div>
</div>
Why does wrapper.find("#button-messageitem-1");
don't find the button?
I also tried wrapper.find("button");
and nothing, no matter what I always get the error message: Method “html” is meant to be run on 1 node. 0 found instead.
.
Thank you for your support.
Aucun commentaire:
Enregistrer un commentaire