UMM-CSci-3601 / 3601-iteration-template

This template repository is used as a starting point for course projects in CSci 3601: Software Design and Development at the University of Minnesota Morris. It includes an Angular client along with a Javalin server and Mongo database.
MIT License
0 stars 9 forks source link

Make Cypress tests less fragile #888

Open NicMcPhee opened 2 years ago

NicMcPhee commented 2 years ago

The way the tests broke in #874 when I changed the case of what's arguably an inconsequential word suggests that at least some of our Cypress tests are overly fragile and we should probably fix that.

kklamberty commented 1 year ago

I think this is a duplicate issue: #649

NicMcPhee commented 10 months ago

Actually, I think these are quite different. What I was concerned about is tests that expect specific words/text to be returned. In #874, for example, we had a test that checked explicitly for the text Added User ${user.name}. That then breaks if you do something like change the case of User to user, which isn't awesome. I think there are quite a few instances of this in our tests and we could probably make that better.

I'm pretty sure the #649 is a timing issue, and thus unrelated to this.

NicMcPhee commented 2 months ago

1580 will close #649, but I wanted to copy this comment from @kklamberty over here since I think it includes things that we may want to return to:

As Nic pointed out, the linked blog post specifically about the "detached elements in the DOM" problem explains some things to try. One thing I noticed we do have is some fragile chaining where we try to continue after clicking on something, but click is not safe to chain off of. Also, some of the fixes that I noticed do things like wait until there are more than 0 elements... if you know there will be 2, you should probably just say 2. cy.get waits until the state you are waiting for exists (or until it times out), so putting exactly what you're waiting for in there makes sense.