I am using react-dropzone library to handle uploading image files. Now I would like to test this upload behaviour. The tests are written using cypress and I am using cypress-file-upload. Here's my component
I tried to follow this example (https://gist.github.com/ZwaarContrast/00101934954980bcaa4ae70ac9930c60) as well, but didn't get it to work .
<ReactDropzone
onDrop={onDrop}
multiple={false}
noDrag
data-cy="uploadFile"
>
<button className={styles.avatarButton}>
Upload Profile Picture
</button>
</ReactDropzone>
function onDrop(event) {
const file = event[0];
//openModal;
}
In my test I'm trying to test if the modal opens up, but the modal doesn't open up in my case.
cy.fixture('avatar.png', 'base64').then(fileContent => {
cy.get('[data-cy="uploadFile"]').attachFile({
fileContent: fileContent,
fileName: 'avatar.png',
});
});
cy.get('[data-cy="uploadFile"]')
.find('input').trigger('change', {force:true})
});
I'm not sure what I'm doing wrong here. I don't see any modal on file upload. Any help would be appreciated.