Cypress: Allow force different superdomains with cy.visit()

Created on 6 Mar 2018  路  2Comments  路  Source: cypress-io/cypress

Hi,
I own an application with several different tlds (.com, .es, .us...). I need to run a test to check that I am showing the same dynamic content in all of them so I need to visit the different tlds in the same test.

Could be posible something like
cy.visit('https://whatever.com', {force: true})

wontfix

Most helpful comment

We will not support visiting different tlds in the same test as outlined in our tradeoffs: https://docs.cypress.io/guides/references/trade-offs.html#Same-origin

You will need to split the visiting of these domains into separate tests. This should be achievable by creating dynamic tests. Something like:

const websites = [{
  domain: 'https://www.cypress.io',
  header: 'The web has evolved',
}, {
  domain: 'https://example.cypress.io',
  header: 'Kitchen Sink',
}]

describe('my tests', () => {
  websites.forEach((website) => {
    it(`is running ${website.domain}`, () => {
      cy.visit(website.domain)
      cy.get('h1').should('contain', website.header)
    })
  })
})

All 2 comments

We will not support visiting different tlds in the same test as outlined in our tradeoffs: https://docs.cypress.io/guides/references/trade-offs.html#Same-origin

You will need to split the visiting of these domains into separate tests. This should be achievable by creating dynamic tests. Something like:

const websites = [{
  domain: 'https://www.cypress.io',
  header: 'The web has evolved',
}, {
  domain: 'https://example.cypress.io',
  header: 'Kitchen Sink',
}]

describe('my tests', () => {
  websites.forEach((website) => {
    it(`is running ${website.domain}`, () => {
      cy.visit(website.domain)
      cy.get('h1').should('contain', website.header)
    })
  })
})

Thanks for your advice. I've managed to solve it following your instructions.

Was this page helpful?
0 / 5 - 0 ratings