0
0
Cypresstesting~5 mins

Custom plugin development in Cypress - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a custom plugin in Cypress?
A custom plugin in Cypress is a piece of code that extends Cypress's functionality by adding new tasks or modifying existing behavior, allowing you to customize test runs.
Click to reveal answer
beginner
Where do you define custom plugins in a Cypress project?
Custom plugins are defined in the cypress/plugins/index.js file, where you can register new tasks or modify Cypress events.
Click to reveal answer
intermediate
How do you register a new task in a Cypress plugin?
You use the on('task', { ... }) event handler inside the plugin file to register new tasks that can be called from test code.
Click to reveal answer
intermediate
Why use custom plugins instead of writing all code in test files?
Custom plugins allow you to run Node.js code outside the browser context, access system resources, or perform complex operations that are not possible directly in test files.
Click to reveal answer
advanced
What is the role of the on and config parameters in the plugin function?
The on parameter lets you listen to Cypress events like task, while config provides the current Cypress configuration that you can modify or use.
Click to reveal answer
Where do you add custom plugin code in a Cypress project?
Acypress/integration/tests.js
Bcypress/support/commands.js
Ccypress/plugins/index.js
Dpackage.json
Which Cypress event is used to register custom tasks in a plugin?
Aon('window:load', ...)
Bon('beforeEach', ...)
Con('test:after:run', ...)
Don('task', ...)
Why might you create a custom plugin instead of writing code directly in tests?
ATo make tests run faster
BTo run Node.js code outside the browser
CTo avoid writing assertions
DTo skip tests automatically
What does the config parameter in the plugin function provide?
ACurrent Cypress configuration settings
BTest case data
CBrowser console logs
DTest execution results
Which file would you NOT modify to create a custom Cypress plugin?
Acypress/integration/sample_spec.js
Bcypress/support/index.js
Ccypress/plugins/index.js
Dcypress/plugins/customPlugin.js
Explain how to create and register a custom task in a Cypress plugin.
Think about the plugin file and how Cypress listens for tasks.
You got /4 concepts.
    Describe why and when you would use a custom plugin in Cypress testing.
    Consider what test code cannot do alone.
    You got /4 concepts.