I know that there is a plugin for doing this in cypress already. However using it with jar files just corrupts the file and therefore it is useless in my usecase. This is really weird because i tried it with every combination of encoding and it still does not work. Works perfectly fine with other filetypes however.
This is the code i am using (works except with jar files).
cy.fixture('test.jar', 'binary')
.then(Cypress.Blob.binaryStringToBlob)
.then(fileContent => {
cy.get('[data-cy="dropzone"]')
.contains('Jar file')
.parent()
.find('div')
.attachFile({
fileContent,
filePath: 'test.jar',
mimeType: 'application/java-archive',
encoding: 'binary',
lastModified: new Date().getTime(),
subjectType: 'drag-n-drop',
force: true
});
});
I know that you can perform post requests in cypress. Is it possible to perfom the file upload with it after clicking the dropzone element?