enough-truck-68085
04/10/2023, 3:04 PMappend
and cy.fixture
if you place your test file in the fixtures folder.
``` const createUpload = () => {
cy.fixture('attachments/myFile.pdf', 'binary')
.then((file) => Cypress.Blob.binaryStringToBlob(file))
.then((blob) => {
const fileData = new FormData()
fileData.append('file', blob, 'File Name ')
fileData.append('user_insert_id', 'cypress.test')
// whatever other values are needed
return cy.request({
method: 'POST',
url: 'Your URL',
body: fileData,
headers: {
'Content-Type': 'multipart/form-data',
},
})
})
}