lecture 3 of 160 completed

Custom command design patterns

Parent, child and dual commands, overwriting built-ins, and the judgement call about when a plain function is better.

What you'll learn

  • The difference between parent, child and dual commands
  • When overwriting a built-in is justified
  • When a plain function beats a custom command

Picture a suite with 63 custom commands, where nobody can say what most of them do. Several do the same thing under different names. Two overwrite built-in Cypress commands, which makes the ordinary Cypress documentation wrong for that project.

Custom commands are the easiest abstraction to add and the easiest to get wrong, because nothing stops you. Senior work is knowing the three shapes and choosing deliberately.

Parent commands start a chain.

members only

Keep reading with the full course

The Foundations track and the first 5 lectures of each framework are free. This lecture is part of the paid course, which unlocks every lecture, all three frameworks, and downloads.

See the options →