Reputation: 2930
I have read docs here, and this is close to what I need, but not quite. I am looking to create a simple namespacing like:
cy.entity.create(name)
cy.entity.edit(id, data)
cy.entity.delete(id)
so that my UI tests had a direct API call fallback where needed. Is it possible to write commands in namespaced format like this?
Upvotes: 0
Views: 146
Reputation: 5293
cy
is a Javascript object, so if your goal is simply to store functions in cy.entity, this will work:
cy.entity = {};
cy.entity.edit = (id, data) => {
cy.log(`cy.entity.edit(${id}, ${data}) has been called`);
// ...
}
// Then you can call cy.entity.edit() like this:
cy.entity.edit("test", "test");
Upvotes: 1