abramenal / cypress-file-upload

File upload testing made easy
https://npm.im/cypress-file-upload
MIT License
498 stars 89 forks source link

[Bug] Example not correct #224

Closed mroeling closed 3 years ago

mroeling commented 4 years ago

Current behavior:

According to last example in Readme

/* when providing fileContent is possible to ignore filePath but fileName and mime type must be provided */

const special = 'file.spss';
cy.fixture(special, 'binary')
  .then(Cypress.Blob.binaryStringToBlob)
  .then((fileContent) => {
    cy.get('[data-cy="file-input"]').attachFile({ fileContent, fileName: 'special', mimeType: 'application/octet-stream', encoding: 'utf-8' });
})

The example provided states filePath can be ignored, but it is a mandatory parameter according to the index.d.ts.

interface FixtureData {
    filePath: String;
    fileContent?: Blob;
    fileName?: string;
    encoding?: String;
    mimeType?: String;
 }

Desired behavior:

Update interface to make filePath optional, or add filePath as well, like in the pre-ultimate example

Versions

Cypress 5.0.0, cypress-file-upload 4.1.0

abramenal commented 3 years ago

Hi @mroeling, Thanks for submitting the issue, Will release the fix soon!