In Cypress, how do I force a PDF file to download instead of opening in a new tab?

Viewed 326

In a web application that I don't control, I need to test that the PDFs that are generated by pressing a button actually have the information that is required.

I managed to do this using pdf-parse and cy.task, but I can only apply it if I download the PDF file.

Using npx cypress open I have Chrome set to download the PDF instead of opening it in a new tab, and it works perfectly, but when I try running npx cypress run then it stops working, even if I choose Chrome as the browser.

In Protractor there is a setting that forces Chrome to download instead of opening PDFs, but I can't find a similar option in Cypress.

Could someone recommend me what to do?

0 Answers
Related