From ea5c4409191fd46084b35212767a9ca5ddcac5a9 Mon Sep 17 00:00:00 2001 From: Walmyr Date: Fri, 31 May 2024 20:01:42 +0200 Subject: [PATCH] Add new feature (download/readFile) --- src/index.html | 21 +++++++++++++++++++++ src/style.css | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index ed6d42a..4c51783 100644 --- a/src/index.html +++ b/src/index.html @@ -375,6 +375,27 @@

+
+

+
cy.readFile
+

+

Sometimes, you need to test downloading a file.

+

For that, Cypress offers the cy.readFile() command.

+

The cy.readFile() command enables you to read a file, as its name suggests.

+

A use case for that could be as follows.

+

You could click an element that downloads a file, and then, read the file to check if its content is correct.

+

Note: By default, Cypress downloads files inside the cypress/downloads/ directory.

+

Here's an example:

+ cy.contains('a', 'Download a text file').click() +
+
+ cy.readFile('cypress/downloads/example.txt') +
+   .should('be.equal', 'This is an example text file.') +
+
+ Download a text file +
diff --git a/src/style.css b/src/style.css index 7541d9c..8b03310 100644 --- a/src/style.css +++ b/src/style.css @@ -24,7 +24,8 @@ q { margin-left: 10px; } -#intro p strong { +#intro p strong, +#download p strong { margin-left: 0; }