Bird
0
0

You want to verify a downloaded CSV file contains the header row exactly as "Name,Age,Email". Which Cypress code correctly reads the file and asserts this?

hard📝 Application Q15 of 15
Cypress - File Operations
You want to verify a downloaded CSV file contains the header row exactly as "Name,Age,Email". Which Cypress code correctly reads the file and asserts this?
Acy.readFile('downloads/data.csv').should('contain', 'Name,Age,Email')
Bcy.readFile('downloads/data.csv').should('equal', 'Name,Age,Email')
Ccy.readFile('downloads/data.csv').should('deep.equal', 'Name,Age,Email')
Dcy.readFile('downloads/data.csv').should('include', 'Name,Age,Email')
Step-by-Step Solution
Solution:
  1. Step 1: Understand the file content and assertion needed

    The CSV file is text, and we want to check if it contains the exact header row as a substring.
  2. Step 2: Choose the correct assertion for substring in text files

    contain is the correct assertion to check if the file text includes the header row.
  3. Final Answer:

    cy.readFile('downloads/data.csv').should('contain', 'Name,Age,Email') -> Option A
  4. Quick Check:

    Use 'contain' to check text includes header row [OK]
Quick Trick: Use 'contain' to check CSV header text inside file [OK]
Common Mistakes:
  • Using 'equal' which requires exact full file match
  • Using 'deep.equal' which is for objects, not strings
  • Using 'include' which is not a valid assertion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes