Bird
0
0

What will this plugin code do?

medium📝 Predict Output Q13 of 15
Cypress - Plugins and Ecosystem
What will this plugin code do?
module.exports = (on, config) => {
  on('task', {
    log(message) {
      console.log(message)
      return null
    }
  })
}
ACreates a new browser event listener
BRuns a test inside the browser console
CDefines a task named 'log' that prints messages to the console
DOverrides Cypress default logging behavior
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the plugin code

    The code uses on('task', {...}) to define a custom task named 'log' that prints a message to the Node console.
  2. Step 2: Understand task purpose

    This task can be called from tests to log messages outside the browser.
  3. Final Answer:

    Defines a task named 'log' that prints messages to the console -> Option C
  4. Quick Check:

    Task 'log' prints messages = D [OK]
Quick Trick: Tasks run in Node, not browser console [OK]
Common Mistakes:
  • Thinking task runs inside browser
  • Confusing task with event listener
  • Assuming it overrides default logs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes