Bird
0
0

Which of the following is the correct way to call a task named readFile in a Cypress test?

easy📝 Syntax Q12 of 15
Cypress - Plugins and Ecosystem
Which of the following is the correct way to call a task named readFile in a Cypress test?
Acy.command('readFile')
Bcy.readFile('readFile')
Ccy.task('readFile')
Dcy.nodeTask('readFile')
Step-by-Step Solution
Solution:
  1. Step 1: Recall the syntax for calling tasks

    In Cypress, tasks defined in the config are called using cy.task('taskName').
  2. Step 2: Verify other options

    cy.readFile is a different command for reading files in the browser context, not tasks. The others are invalid commands.
  3. Final Answer:

    cy.task('readFile') -> Option C
  4. Quick Check:

    Use cy.task() to call tasks [OK]
Quick Trick: Use cy.task('name') to run tasks [OK]
Common Mistakes:
  • Using cy.readFile instead of cy.task
  • Trying non-existent commands like cy.nodeTask
  • Passing task name without quotes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes