How to run Cypress test in localhost

I am using Cypress v.13 to perform end-to-end tests. I have set up my beforeEach hook so that the my test runner visits my localhost:9000 address when performing tests. This is especially important since the HTML template in my local dev environment differs from that on my Cumulocity tenant.

However, when I run my unit tests in the Cypress Test Runner application I see that the individual tests are using my tenant URL rather than localhost resulting in failed tests.

Is there a workaround for this aside from deploying the latest code to Cumulocity? I tried setting the baseUrl property in my cypress.config.ts file but that did not change anything.

Hi Lucas,

you should be able to just specify the baseUrl to point to your locally running dev server.
All the cy.visit and other cypress calls that you perform should only contain the path without specifying the host. So e.g. when trying to visit a page in the administration app, you would want to call cy.visit('/apps/administration/index.html#/roles/inventory_roles') and not cy.visit('xyz.us.cumulocity.com/apps/administration/index.html#/roles/inventory_roles').

Are you using the actual domain of your tenant somewhere in your applications code or within your cypress tests?
It might help if you could provide a cypress tests where you are seeing this issue and ideally also the sourcecode of the view you are trying to test.

Regards,
Tristan

1 Like

Hi Tristan,

I added http://localhost:9000 as the baseUrl property of the Cypress config file and then added the path without the host in the cy.visit calls and it worked.
image

Thanks!

1 Like