Bird
0
0

Identify the error in this plugin code snippet:

medium📝 Debug Q6 of 15
Cypress - Plugins and Ecosystem
Identify the error in this plugin code snippet:
module.exports = (on, config) => {
  on('task', {
    greet(name) {
      console.log('Hello ' + name)
    }
  })
}
AUsing console.log inside plugin is not allowed
BMissing return statement in greet task
CIncorrect event name 'task' should be 'tasks'
DPlugin function should not use arrow syntax
Step-by-Step Solution
Solution:
  1. Step 1: Review task function requirements

    Tasks must return a value or null; greet lacks a return statement.
  2. Step 2: Validate other parts

    'task' event name is correct, console.log is allowed, arrow function is valid syntax.
  3. Final Answer:

    Missing return statement in greet task -> Option B
  4. Quick Check:

    Tasks must return a value [OK]
Quick Trick: Always return a value from task functions [OK]
Common Mistakes:
  • Confusing event name 'task' with 'tasks'
  • Thinking console.log is disallowed
  • Believing arrow functions are invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes