Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 243
Psdet Avatar asked Dec 11 '25 19:12

Psdet


1 Answers

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.

like image 160
Alexey Lindberg Avatar answered Dec 14 '25 21:12

Alexey Lindberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!