How Do I Upload a File in

Timothy Joseph | October 12, 2020

How Do I Upload a File in

The JavaScript End to End Testing Framework is a highly popular framework nowadays. However, there are a few browser events that are not supported by cypress. File uploading is one such event.

To upload a file in cypress, you need to install a dependency to upload the file. Follow these steps:

  1. Install the dependency

    npm install cypress-file-upload

  2. Add import

    ‘cypress-file-upload’; to cypress/support/commands.js file

  3. Go to spec file where you are creating your test code:
    declare a constant having path of your file and use attachFile command.


const urFilePath = 'abc.png';



This publication is for informational purposes only, and nothing contained in it should be considered legal advice. We expressly disclaim any warranty or responsibility for damages arising out of this information and encourage you to consult with legal counsel regarding your specific needs. We do not undertake any duty to update previously posted materials.

Post a Comment