0
0
Cypresstesting~5 mins

Why custom commands reduce duplication in Cypress - Quick Recap

Choose your learning style9 modes available
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?
ATo write more code manually
BTo make tests run slower
CTo confuse other testers
DTo avoid repeating the same code in multiple tests
Where do you usually add custom commands in a Cypress project?
Acypress/integration/tests.js
Bcypress/support/commands.js
Cpackage.json
Dnode_modules folder
What happens if you change a custom command used in many tests?
ATests will fail immediately
BYou must update each test manually
CAll tests using it automatically use the updated command
DNothing changes in the tests
Which of these is NOT a benefit of using custom commands?
AIncreasing test maintenance effort
BReducing code duplication
CImproving test readability
DMaking tests easier to update
Custom commands in Cypress are best described as:
AReusable test functions
BTest data files
CBrowser plugins
DTest reports
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.