Open ShBodden opened 4 years ago
Typically, when writing tests we also write functionality to set up data for those tests, and clean up that data in between tests. This ensures that the tests are not prone to failure as data is changed.
We didn't get into that, though, so it's not something I'm expecting when grading. However, there are ways to make our tests flexible with the seed data we did set up.
For example, instead of looking for an exact length of foos, check that there are at least 3 foos.
Example from one of the ZipFoods tests:
cy.get('[data-test="product-name"]').its('length').should('be.gte', 10);
Is it okay to hard code data for a particular test? I'm thinking of a scenario in which our project is cloned for grading and may fail a test. For example:
cy.get('[data-test="foo-name"]').should('have.length', 3)
would test for 3 foos. If during grading an additional foo is created to test the create foo method, the additional foo would result in a failed test. Would points get deducted for such a failure or will the testing be done with the expectation that the data itself is complete and accurate. Ideally the test won't be hard coded but instead would be dynamic however, examples in class included hard coded products and have.lenght.