How to debug ember-cli tests running in phantomjs

眉间皱痕 提交于 2019-12-20 09:46:08

问题


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?


回答1:


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




回答2:


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




回答3:


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.




回答4:


To answer the part of my original question about "how do I get log messages to show up", if I use the TAP reporter, then console.log (in my app and in my tests) messages show up in the output; the xunit reporter doesn't pass console.log on, which was confusing me.

(I've also hit issues where running the tests on teamcity behaves differently than running locally; in that situation, combining the TAP reporter with https://github.com/aghassemi/tap-xunit (or the TAP teamcity plugin) lets me get log messages and also test counts)



来源:https://stackoverflow.com/questions/28095371/how-to-debug-ember-cli-tests-running-in-phantomjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!