https://cypress.io logo
Hi! I've been using cypress for a few months after...
# best-practices
l
Hi! I've been using cypress for a few months after I inherited the project from a teammate who left the company. So I've been maintaining the existing tests, writing new ones and at the same time reading everything I could find about cypress to learn best practices and so on. What I found is that most people (including my former colleague) is writing every test from scratch, meaning very few reusable bits of code. Since our web app is quite large and there are many similar but not quite same test cases, I've started putting cypress commands in functions and then calling them in different tests. For example, I have a button in the header of the page that's used in more than 15 tests. It's a lot easier for me to call a descriptively named function those 15 times, and it's a lot easier to maintain. But from what I've read on multiple sites, including cypress official docs, that isn't how it's supposed to be done 🙂 My actual question is am I doing it dead wrong and is anybody else doing it this way? 🙂