🧪 E2E Testing

Create a new file inside integration folder with the name ExcelDownload.spec.js . Inside this file our test would first start with checking for existence of our button and then we will click on it.

3) After clicking on it, the file should ideally have been downloaded and now we need to somehow read that file and check if it exists and also check if it consists of the right data in it.

4) To do that, we will first need to install another npm package which can parse the excel and convert it to a json.

5) After this, inside your plugins/index.js file we will create a new task to parse excel.

This function will parse our excel file and convert it to json.

6) Finally let’s complete our test for excel file download

7) With this we can be sure that our excel download functionality is working as expected.

Test Execution

demo of running e2e test in cypress

8) The only caveat here is how do you know the download path for your CI/CD Pipeline or how can you change that path to something else.

The solution to that is built into cypress. Again inside plugins/index.js file we will create another task.

Here we are changing the default directory of download to a directory named excelDownloads inside of cypress folder.

https://docs.cypress.io/api/plugins/browser-launch-api.html#Change-download-directory