cypress-documentation icon indicating copy to clipboard operation
cypress-documentation copied to clipboard

Missing host documentation

Open bartoszWesolowski opened this issue 3 years ago • 1 comments

Hi,

I found YT video explaining how to configure hosts using cypress config file instrad of changing hosts on my local machine: https://www.youtube.com/watch?v=BrZbNCrrlx8

In summary config like this:

{
  "video": false,
  "screenshotsFolder": "build/cypress/screenshots",
  "viewportWidth": 1300,
  "viewportHeight": 800,
  "env": {
    "allure": true,
    "allureAttachRequests": true,
    "allureResultsPath": "build/allure-results"
  },
  "hosts": {
    "not.public.host.com": "191.1.191.111"
  }
}

will allow cypress to resolve not.public.host.com host in my tests.

I could not find this section in the documentation of cypress parameters https://docs.cypress.io/guides/references/configuration

Is this missing or maybe it should not be used as it might not work in next Cypress version? I am using Cypress 8.3.0

Cheers, Bartek

bartoszWesolowski avatar Mar 30 '22 09:03 bartoszWesolowski

+1 to this, that is the actual video that I also found and it helped me in setting up my environment

Additional note here (with the new cypress.config.js format), wildcard also seems to work:

module.exports = defineConfig({
	e2e: {
		experimentalSessionAndOrigin: true,
		// The installed baseUrl will change from test to test
		// (behavior of the tested code changes based on the domain)
		baseUrl: 'http://plugin-e2e.loc/',
		hosts: {
			'*.loc': '127.0.0.1',
		},
	},
});

denke8 avatar Aug 17 '22 14:08 denke8