Reputation: 276181
I need to test the same logic hosted on different domains e.g.
cy.visit('DomainA');
cy.sameTestLogic();
cy.visit('DomainB');
cy.sameTestLogic();
There are entire suites of tests that need to run on both domains, A and B. Does anyone have any suggestions based on experience on how to approach this?
Upvotes: 1
Views: 620
Reputation: 31862
Iterate the domains like this (applied per spec)
const domains = ['a', 'b']
domains.forEach(domain => {
describe(`Testing domain ${domain}`, () => {
beforeEach(() => {
cy.visit(domain)
})
it('...', () =>
To do something more flexible, take a look at the Module API
Node script
const cypress = require('cypress')
const domains = ['a', 'b']
domains.forEach(domain => {
// run all specs or as specified
cypress.run({
...
env: {
domain
},
})
})
Test
const domain = Cypress.env('domain')
cy.visit(domain)
Upvotes: 1