I did write the following e2e test visiting this page for cypress yesterday:
it('Download test: Verify download file', () => {
// check that button is correct
cy.get("#whitepaper-download-button")
.should("be.visible")
.should('have.attr', 'href', 'https://troodi.de/download/358489/');
// check that button has correct file download
cy.request({
url: 'https://troodi.de/download/358489/',
encoding: 'binary',
}).then((response) => {
cy.readFile("cypress/fixtures/whitepaper.pdf", "binary").should("eq", response.body);
})
})
I first check that the button has the correct download and afterwards that the file is the same as the one in the fixtures folder.
Some of the hourly runs overnight on GitHub actions just did not terminate in that test and used the 6hs available for a single step. The output of the cypress run
command always looks like that:
Running: test.cy.js (2 of 3)
Whitepaper
√ Section has proper title (7191ms)
The testing does not continue after that. The tests works on my machine when I run it in chrome with cypress open
but not always with cypress run
.