Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug PhantomJS when running through Karma

I test through Jasmine, Karma and a variety of browsers. I'm currently debugging a test that fails only in PhantomJS.

I'd like to debug this call, so I've setup a custom PhantomJS launcher in karma that runs it with the debug port open.

I'm able to access the remote debugger in Chrome through that port, however, it seems to know nothing about any of my test files. It reports an "about:blank" and a "localhost:9876" (the karma server that Phantom is hitting) but when I try to debug that location, it shows none of the source files or Jasmine spec files.

Has anyone else seen this behavior? I've read the PhantomJS docs on the remote debugging feature and they don't shed any light on this issue, AFAIK.

like image 406
stolli Avatar asked Apr 07 '14 21:04

stolli


People also ask

How do you debug a test in PhantomJS?

Open a new browser tab and return to the debugging portal at http://127.0.0.1:9000. There should now be a second entry in the bulleted list. Click on this entry to open a new debugger that operates in the context of your page inside PhantomJS.

What is karma PhantomJS launcher?

The karma-phantomjs-launcher enables the karma test runner to launch and interact with PhantomJS. Use NPM to install the karma-phantomjs-launcher package as a dev dependency by executing the following command in the root of the project: npm install karma-phantomjs-launcher --save-dev.


Video Answer


1 Answers

I struggled mightily with this, it was not straightforward.

I ended up proposing a change to karma-phantomjs-launcher. It was merged and is now in the latest versions.

like image 101
mpderbec Avatar answered Oct 10 '22 04:10

mpderbec