# How to run Cypress test in localhost

**URL:** <https://community.cumulocity.com/t/how-to-run-cypress-test-in-localhost/7086>\
**Category:** Forum\
**Tags:** cumulocity\
**Created:** [February 14, 2024, 8:18pm UTC](https://community.cumulocity.com/t/how-to-run-cypress-test-in-localhost/7086 "2024-02-14T20:18:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luclib](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@luclib](https://community.cumulocity.com/u/luclib)\
**Post date:** [February 14, 2024, 8:18pm UTC](https://community.cumulocity.com/t/how-to-run-cypress-test-in-localhost/7086/1 "2024-02-14T20:18:51Z")

</div>

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.

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/6/7/67564a5e9c996d850159a3fe8849ac3d90801385.png)

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.

---

<div class="post-metadata">

**Author:** ![Tristan\_Bastian](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/tristan_bastian/32/18259_2.png) [@Tristan\_Bastian](https://community.cumulocity.com/u/Tristan_Bastian)\
**Post date:** [February 15, 2024, 9:07am UTC](https://community.cumulocity.com/t/how-to-run-cypress-test-in-localhost/7086/2 "2024-02-15T09:07:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![luclib](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@luclib](https://community.cumulocity.com/u/luclib)\
**Post date:** [February 15, 2024, 2:26pm UTC](https://community.cumulocity.com/t/how-to-run-cypress-test-in-localhost/7086/3 "2024-02-15T14:26:44Z")

</div>

Hi Tristan,

I added [http://localhost:9000](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](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/9/a/9a5ef8ac693e0d9154d1f693ef1eaf12e5093c0a.png)

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [August 13, 2024, 2:26pm UTC](https://community.cumulocity.com/t/how-to-run-cypress-test-in-localhost/7086/4 "2024-08-13T14:26:48Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
