Psdet
Psdet

Reputation: 689

Unable to debug TestCafe browser running in a docker container

I have been trying to figure out an issue which only occurs in my TestCafe docker environment but not in local environment. For that I would like to debug TestCafe docker either in inbuilt chromium or firefox. I followed the discussion here but it didn't work for me.

This is the command I use to run my docker container:

docker run --net=host -e NODE_OPTIONS="--inspect-brk=0.0.0.0:9229" -v `pwd`:/tests -v `pwd`/reporter:/reporters -w /reporters -e [email protected] -e userPass=password -e urlPort=9000 --env-file=.env testcafe 'firefox' '/tests/uitests/**/concurrentTests/logintest.js' --disable-page-caching -s takeOnFails=true --reporter 'html:result.html',spec,'xunit:res.xml' 

Running the above with -p 9229:9229 or without this is what I see:

Debugger listening on ws://0.0.0.0:9229/66cce714-31f4-45be-aed2-c50411d18319
For help, see: https://nodejs.org/en/docs/inspector

The when I go to the link ws://0.0.0.0:9229/66cce714-31f4-45be-aed2-c50411d18319 on the Chrome/Firefox browser then nothing happens. Also, chrome://inspect/#devices this is empty

My expectation:

I would like to see the webpage in the browser so that I know what's happening behind the scene. Also, I would like to see cookies and other API calls being done.

Please suggest how to deal with this situation.

Upvotes: 3

Views: 805

Answers (2)

Alexey Lindberg
Alexey Lindberg

Reputation: 766

It seems, node inspection doesn't work well with the host network for some reason. Try to remove the --net=host option and add the -p 127.0.0.1:9229:9229 one. A contained node process should then appear in DevTools (at chrome://inspect) under the 'Remote Target #LOCALHOST' section.

Also, you need to remove the -e NODE_OPTIONS="--inspect-brk=0.0.0.0:9229" option and add the --inspect-brk=0.0.0.0:9229 flag after testcafe/testcafe to avoid the 'Starting inspector on 0.0.0.0:9229 failed: address already in use' error.

Upvotes: 2

Alex Skorkin
Alex Skorkin

Reputation: 4274

When you see the Debugger listening on ws://0.0.0.0:9229/66cce714-31f4-45be-aed2-c50411d18319 message (or similar), navigate to the http://localhost:9229/json URL in your browser and find the devtoolsFrontendURL:

enter image description here

Copy and paste it to your browser to start your debugging session:

enter image description here

Upvotes: 1

Related Questions