Radek
Radek

Reputation: 31

TestCafe docker - Run tests against app running on hosts localhost

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

Upvotes: 3

Views: 495

Answers (1)

Alexey Lindberg
Alexey Lindberg

Reputation: 766

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.

Upvotes: 1

Related Questions