Problem/Motivation
Currently if you try to run a test that extends JavascriptTestBase but do not have phantomjs running it will cause an error but not tell you need to have phantomjs running.
The error received is
PHPUnit_Framework_Exception: PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ConnectException' with message 'cURL error 7: Failed to connect to 127.0.0.1 port 8510: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in /var/www/d8_2_ux/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:186
Stack trace:
#0 /var/www/d8_2_ux/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 /var/www/d8_2_ux/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlMultiHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#2 /var/www/d8_2_ux/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(180): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlMultiHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#3 /var/www/d8_2_ux/vendor/guzzlehttp/guzzle/src/Handler/CurlM in /var/www/d8_2_ux/vendor/jcalderonzumba/gastonjs/src/Browser/BrowserBase.php on line 93
This doesn't help the user to know that they need phantomjs running
Proposed resolution
Detect if phantomjs is running and if not print out a helpful message such as "Phantomjs is currently not running. It must be running to execute Javascript based tests."
Remaining tasks
Determine if it is possible.
Do it
Comment | File | Size | Author |
---|---|---|---|
#21 | provide_helpful_message-2737781-21.patch | 1.09 KB | juampynr |
#19 | provide_helpful_message-2737781-19.patch | 1.24 KB | juampynr |
#19 | Selection_010.png | 71.41 KB | juampynr |
#3 | provide_helpful_message-2737781-3.patch | 672 bytes | cilefen |
Comments
Comment #2
dawehnerLet's improve that a bit.
Comment #3
cilefen CreditAttribution: cilefen as a volunteer commentedWhat a silly patch, but this is a possible place to catch it.
Comment #4
dawehnerSo here is a question, why was the existing exception message not shown? Can we maybe convert the exception message to be more helpful?
Comment #5
cilefen CreditAttribution: cilefen as a volunteer commentedThe actual exception that arrives at this place is Zumba\GastonJS\Exception\DeadClient.
Comment #6
cilefen CreditAttribution: cilefen as a volunteer commentedSomething like this would seem to make sense:
Although it does catch the exception, it doesn't actually work.
Comment #7
dawehnerWhat about using the following message:
Comment #8
cilefen CreditAttribution: cilefen as a volunteer commentedThe message can be whatever we like but #6 doesn't work, for maybe several reasons. One is that marking a test as skipped does not halt its execution. The other is that there is probably an exception handler.
Comment #9
dawehnerWell, but the message is still shown when you use --verbose, doesn't it?
Comment #10
cilefen CreditAttribution: cilefen as a volunteer commentedIt does not.
Comment #11
jibranComment #12
albertski CreditAttribution: albertski at Xeno Media, Inc. commentedI'm running into this same error.
I installed phantomjs. When I run 'phantomjs -v' I get '1.9.0' but I still get the same error. I'm using nginx.
Comment #13
albertski CreditAttribution: albertski at Xeno Media, Inc. commentedActually I'm seeing the same error on Apache.
Comment #14
cilefen CreditAttribution: cilefen as a volunteer commented@albertski This issue is to fix the error message when phantomjs is not running properly. Did you start phantomjs this way?
/path/to/phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768
Comment #15
dawehner@albertski Yeah I think phantomjs should be 2.0.x at least, otherwise there are problems with the underlying JS engine.
Comment #16
albertski CreditAttribution: albertski at Xeno Media, Inc. commented@cilefen Thanks that ended up working. To get it to work I had to:
1. ssh into server
2. Run command: phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768
3. Leave this running
4. Open new terminal window
5. ssh into server
6. Run phpunit test
Is there a way to run the command without having to keep running? So I don't have to open two separate connections.
@dawehner Thanks I updated to 2.0.x.
Comment #17
cilefen CreditAttribution: cilefen as a volunteer commentedphantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768&
Comment #18
albertski CreditAttribution: albertski at Xeno Media, Inc. commented@cilefen: Thanks that worked great!
Comment #19
juampynr CreditAttribution: juampynr at Lullabot commentedHere I am marking the test to be skipped if phantomjs fails to start. Here is the output when I attempt to run a JavascriptTestBase test without PhantomJS running:
Comment #20
dawehnerCould we catch that explictly in JavascriptTestBase instead?
Comment #21
juampynr CreditAttribution: juampynr at Lullabot commentedSure, here it is.
Here is the output when I run a JavascriptTestBase test with PhantomJS not running and this patch applied:
Comment #22
dawehnerWell, do we want this catch in BrowserTestBase still?
Comment #23
juampynr CreditAttribution: juampynr at Lullabot commentedIf we have it in BrowserTestBase, we would have to re-throw it so it bubbles up to JavascriptTestBase. Why would you prefer to do that? Shall we remove the Exception catch?
Comment #24
dawehnerWell the message in the catch all seems to be helpful for mink potentially as well, but I agree this is super nitpicky.
Comment #27
alexpottHelpful. Nice work. Committed 25d27de and pushed to 8.1.x and 8.2.x. Thanks!