Recall & Review
beginner
What is a custom command in Cypress?
A custom command is a reusable function you create to perform common actions in tests, like logging in or filling forms, so you don't repeat the same code.
Click to reveal answer
beginner
How do custom commands help reduce code duplication?
They let you write a piece of code once and use it many times, so you avoid copying and pasting the same steps in multiple tests.Click to reveal answer
beginner
Give an example of a situation where a custom command is useful.
When you need to log in to your app in many tests, a custom command can handle the login steps so you just call it instead of writing the steps each time.
Click to reveal answer
intermediate
What is one benefit of reducing duplication with custom commands?
Tests become easier to maintain because if the login process changes, you only update the custom command once instead of every test.
Click to reveal answer
beginner
Where do you define custom commands in Cypress?
You define them in the 'cypress/support/commands.js' file so they are available in all your test files.
Click to reveal answer
Why should you use custom commands in Cypress tests?
✗ Incorrect
Custom commands help avoid code repetition, making tests cleaner and easier to maintain.
Where do you usually add custom commands in a Cypress project?
✗ Incorrect
The 'cypress/support/commands.js' file is the standard place to define custom commands.
What happens if you change a custom command used in many tests?
✗ Incorrect
Changing a custom command updates its behavior everywhere it is used, saving time and effort.
Which of these is NOT a benefit of using custom commands?
✗ Incorrect
Custom commands reduce maintenance effort, not increase it.
Custom commands in Cypress are best described as:
✗ Incorrect
Custom commands are reusable functions that simplify writing tests.
Explain how custom commands help reduce duplication in Cypress tests.
Think about how repeating login steps in many tests can be replaced by one command.
You got /4 concepts.
Describe where and why you would define a custom command in a Cypress project.
Consider the file that loads before tests run.
You got /4 concepts.