I would like to programmatically write a series of it()
tests given the data from a fixture (which seems like the correct way of using data in Cypress) or elsewhere.
This data is an array of objects, each object provides the necessary information needed for each it()
test I'd like to write.
[
{
slug: "/some-page-with-form/",
slugRedir: "/expected-redir-page-after-form-submit/",
formData: [
{
htmlName: "firstName",
type: "inputText",
},
...
]
},
...
]
Below is an idea of what I'm trying to achieve
describe("CMS-generated pages with forms", function() {
before(function() {
cy.fixture("forms").as("forms")
});
this.forms.forEach(({ slug, slugRedir, formData }) => {
it(`fills and submits form on ${slug}`, function() {
...
});
})
})
Obviously the above doesn't work because this.forms
does not exist outside of the it()
scope.
To summarize - how would I achieve programmatically writing a series of it()
tests given the data from either a fixture or possibly imported elsewhere?
Aucun commentaire:
Enregistrer un commentaire