Please add support for www.domain.com.localhost
uflidd opened this issue · comments
What would you like?
All browsers now support that you can open a domain locally by adding .localhost at end of the domain name,. Cypress however doesn't support this yet.
More specically:
www.yourdomain.com goes to production
www.yourdomain.com.localhost goes to your local (without you having to specify this in the host file)
Why is this needed?
We have a saas application that can be open in multiple domains. Manually having to update host file to add/remove hosts constantly is a painfully repeating operation.
Cypress testing would get an great enhancement for us that are working typically with apps that can be open by multiple domains.
Other
No response
Hey @uflidd ! I wanted to know that when first visiting www.yourdomain.com.localhost and then e.g. visiting www.yourdomain2.com.localhost, does Cypress' outer URL get stuck in www.yourdomain.com.localhost ?
I'm having a similar issue (rather not a missing enhancement) where Cypress' doesn't trigger a full page load after visiting another subdomain if it first did visit one.
E.g.
- Visit
a.b.com
=> Success,localStorage
andcookies
all are loaded. - Visit
b.b.com
=> Failed,localStorage
andcookies
are cleared and outerURL is stuck ata.b.com
whereas inner one is correct.
I want to know if you have same exp as I do 'so that we may update the content of your issue to include this, or I then have to create a separate one.
Thanks for consideration!
I found that this works (thanks to #1488 (comment))
export default defineConfig({
...
hosts: {
'*.localhost': '127.0.0.1'
},
});
While this does NOT work for some reason:
export default defineConfig({
...
hosts: {
'www.adamogeva.no': '127.0.0.1'
},
});
My test looks like this:
describe('hosts option in cypress config', () => {
var baseUrl = 'https://www.adamogeva.no.localhost';
it('Visit domain that is not added to localhost', () => {
cy.visit(baseUrl);
// I've added <div id="local">Local</div> on the website
cy.get('#local')
.should('exist')
.and('have.text', 'Local');
});
});
So the question is why domains doesn't work. The workaround would be to use .localhost baseUrls when running tests locally and just www.domain.com when running tests in production.