Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug ember-cli tests running in phantomjs

Context: I have an acceptance test for my ember-cli application, and the test passes just fine in Chrome. However, in phantomjs, my test fails -- the UI doesn't get created the same way, and I'm trying to work out why. (I think the test is broken because of https://github.com/ember-cli/ember-cli/issues/1763, but the general question of how to debug remains)

In Chrome, I can use the standard debugging tools on my tests and all is well -- but in phantomjs, I can't get at it with a debugger. I also don't see console.log() messages show up in the output -- all I get is a list of test results in my terminal window.

I can sort-of get diagnostic info by writing things like

equal(true, false, "This is a log message");

and then I get the message as details for the assertion that failed, or I can try and work out what's in the DOM with

equal(true, false, document.getElementsByClassName("my-class".innerHTML);

but both of those a:stop the test going any further, and b:only let me log information from the test itself, not my application.

Is there a way to run my tests outside of "ember test", or some way to attach to the running test processes? Alternatively, is there a way to get console.log() messages to show up in the output?

like image 805
Dan Mitchell Avatar asked Jan 22 '15 17:01

Dan Mitchell


3 Answers

You can expose PhantomJS debug port and open it in browser then you can interact with context at your debugger breakpoints.

Debugging tests on PhantomJS using Testem test runner

like image 50
Pooyan Khosravi Avatar answered Oct 19 '22 05:10

Pooyan Khosravi


In testem.json add "phantomjs_debug_port": 9000.

While you run your tests visit http://localhost:9000 in your browser and click the long link that shows up.

Source: cssugared

like image 32
Nelu Avatar answered Oct 19 '22 05:10

Nelu


I had no luck with the other answers, so here's what I found out:

Add a return pauseTest(); at the point in your test where you want to be able to interact with the container in the browser. This is in the docs but I'm not sure it's in the guides.

like image 7
aceofspades Avatar answered Oct 19 '22 05:10

aceofspades