I have a JSON file in while I store the test data needed for my Cypress tests but I would like to generate specific it
blocks dynamically based on the contents of object keys/values (not every object has the same values or needs to perform the same steps).
So for example, if I have the following testData objects:
[
{
"name": "Do Something",
"type": "A",
},
{
"name": "Do Something",
"type": "B",
},
{
"name": "Do Something",
"type": "C",
},
]
Not all have the same type
so will need to call upon different tests for their runs.
What is the best way to achieve this in Cypress? Is there a way that doesn't involve if/else blocks?
There is an example in the Cypress Real World App, a payment application to demonstrate real-world usage of Cypress testing methods, patterns, and workflows
There are 3 transaction feeds and each are tested thoroughly in this spec: https://github.com/cypress-io/cypress-realworld-app/blob/develop/cypress/tests/ui/transaction-feeds.spec.ts