Uploading a csv file in Cypress

Viewed 990

I am having issues with uploading a csv file to test in cypress so I am successful in uploading the file and clicking the submit button but the fields do not upload with new information which is in the csv.

cy.fixture('contentData.csv').then((fileContent) => {
  cy.get('input[type="file"]').attachFile({
    fileContent: fileContent.toString(),
    fileName: 'contentData.csv',
    mimeType: 'text/csv',
  });
});

I was hoping someone can tell me where i am going wrong?

1 Answers

Well, I don't see a reason why you need to use toString() function. Try this:

cy
  .fixture('contentData.csv')
  .then(fileContent => {
  cy
    .get('input[type="file"]')
    .attachFile({
      fileContent,
      fileName: 'contentData.csv',
      mimeType: 'text/csv',
  });
Related