Bird
0
0

Given this App Action:

medium📝 Predict Output Q5 of 15
Cypress - Test Organization and Patterns
Given this App Action:
const addTask = (task) => { cy.get('#task-input').type(task); cy.get('#submit-btn').click(); }

What will happen if you call addTask('Email') twice consecutively in a test?
AThe second call will fail due to duplicate task names
BOnly one task will be added because the input clears automatically
CTwo tasks named 'Email' will be added to the task list
DThe test will throw an error because the function lacks a return statement
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the addTask function

    The function types the task name and clicks submit each time it is called.
  2. Step 2: Effect of consecutive calls

    Calling it twice will add two tasks with the same name unless the app prevents duplicates.
  3. Final Answer:

    Two tasks named 'Email' will be added to the task list -> Option C
  4. Quick Check:

    Each call triggers a new add action [OK]
Quick Trick: Each call adds a new item unless app blocks duplicates [OK]
Common Mistakes:
  • Assuming input clears automatically without verification
  • Believing duplicates cause test failure by default
  • Thinking missing return causes runtime error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes