TestCafe docker - Run tests against app running on hosts localhost

自古美人都是妖i 提交于 2021-01-28 07:38:55

问题


I have a local dev server running on Mac OS on localhost:3000
I want to be able to run testcafe tests in the docker container, pointing to the app running on the Mac host.

Test code:

fixture('<Page>')
  .page(`localhost:3000/page-test`)

I've tried docker run --network="host" which should make Mac's localhost accessible, but no success. Have also read, host.docker.internal or docker.for.mac.localhost can be used inside the container, but there is no way for me to access, modify the image settings.

Anyone has a similar use case for testcafe docker or knows how to solve this? Thanks, Radek


回答1:


You can just use host.docker.internal instead of localhost right in your test code. It does not require image settings modification. Please, keep in mind that this feature was introduced in version 18.03.0-ce and is not available in Docker Toolbox.



来源:https://stackoverflow.com/questions/58006459/testcafe-docker-run-tests-against-app-running-on-hosts-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!