HuddleEng / PhantomFlow

Describe and visualise user flows through tests with PhantomJS
MIT License
682 stars 60 forks source link

Running in debug mode litters the output with resource errors #46

Closed eskitek closed 8 years ago

eskitek commented 8 years ago

When running tests in debug mode, a ton of resource errors are logged. These resource errors don't seem to adversely affect the test run, but they add a lot of noise to the debug output.

To reproduce, using PhantomFlow v1.0.0 run:

node test/test.js debug

In the output you'll see a ton of resource errors around 'empty.html' and 'resemblejscontainer.html':

Resource Error: {
    "errorCode": 301,
    "errorString": "Protocol \"c\" is unknown",
    "id": 1,
    "status": null,
    "statusText": null,
    "url": "c:/Code/PhantomFlow/lib/empty.html"
}
Resource Error: {
    "errorCode": 301,
    "errorString": "Protocol \"c\" is unknown",
    "id": 1,
    "status": null,
    "statusText": null,
    "url": "c:/Code/PhantomFlow/node_modules/phantomcss%5Cresemblejscontainer.html"
}

Screenshot: empty html resource error before

These resource errors are not present in PhantomFlow v0.5.14, but they are present in PhantomFlow v1.0.0. Further investigation shows that the errors are triggered by the switch to PhantomJS v2.

It seems that PhantomJS 2 requires that URLs have a protocol - see this SO answer.

So while this worked in PhantomJS v1:

casper.thenOpen( 'C:/test.htm' );

PhantomJS v2 requires us to prefix the file path with 'file:///':

casper.thenOpen( 'file:///C:/test.htm' );

I'll submit some pull requests shortly to fix the 2 spots that are causing the resource errors. One is in PhantomFlow and one is in PhantomCSS.