HuddleEng / PhantomFlow

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

It broke, sorry after URL Changed: "about:blank" #51

Closed bryanrasmussen closed 7 years ago

bryanrasmussen commented 7 years ago

hey, I am on windows 10. I am getting a response like the following when I try to run my phantom flow process.


[flows\responsive.test.js] (1504ms) D:/projects/repositories/TDC/se-gui-comparisontool/node_modules/phantomflow/lib/phantomFlow.js

[flows\responsive.test.js] (67ms) URL Changed:"about:blank"
[flows\responsive.test.js] It broke, sorry. Process aborted. Non-zero code (1) returned.
[flows\responsive.test.js] It broke, sorry. Process aborted. Non-zero code (1) returned.

 Please take a look at the error log for more info 'D:\projects\repositories\TDC\se-gui-comparisontool\test-results/log/error_1.log'

Some processes exited with errors:

Test name                    Exit code  Passed assertions  Failed assertions  Process time /s
---------------------------  ---------  -----------------  -----------------  ---------------
[flows\responsive.test.js]   1          0 passes           0 fails            1.606s

Completed 0 assertions in 2 seconds. 0 assertions failed, 0 assertions passed.
D:\projects\repositories\TDC\se-gui-comparisontool\node_modules\wrench\lib\wrench.js:249
        if (e.code !== 'EEXIST') throw e;
                                 ^

Error: ENOENT: no such file or directory, mkdir 'D:\projects\repositories\TDC\se-gui-comparisontool\test-results\report'
    at Error (native)
    at Object.fs.mkdirSync (fs.js:922:18)
    at Object.exports.copyDirSyncRecursive (D:\projects\repositories\TDC\se-gui-comparisontool\node_modules\wrench\lib\wrench.js:246:12)
    at copyReportTemplate (D:\projects\repositories\TDC\se-gui-comparisontool\node_modules\phantomflow\phantomflow.js:573:10)
    at D:\projects\repositories\TDC\se-gui-comparisontool\node_modules\phantomflow\phantomflow.js:519:7
    at Timeout.<anonymous> (D:\projects\repositories\TDC\se-gui-comparisontool\node_modules\phantomflow\node_modules\async\lib\async.js:789:30)
    at Timeout._onTimeout (D:\projects\repositories\TDC\se-gui-comparisontool\node_modules\phantomflow\node_modules\async\lib\async.js:167:37)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

I figured it was my casperjs process, and it seemed at first when I tried to run the casperjs process it couldn't find my phantomjs, but after a lot of trouble with that I got phantomjs installed and added to my path. After which when I did the following

D:\projects\repositories\TDC\se-gui-comparisontool\node_modules\phantomflow\node_modules\casperjs\bin\casperjs.exe D:/projects/repositories/TDC/se-gui-comparisontool/node_modules/phantomflow/lib/start.js --flowincludes=D:/projects/repositories/TDC/se-gui-comparisontool/include --flowtestsroot=D:/projects/repositories/TDC/se-gui-comparisontool/phantomflow_tests/ --flowphantomcssroot=D:/projects/repositories/TDC/se-gui-comparisontool/node_modules/phantomflow/node_modules/phantomcss --flowlibraryroot=D:/projects/repositories/TDC/se-gui-comparisontool/node_modules/phantomflow/lib --flowoutputroot=D:/projects/repositories/TDC/se-gui-comparisontool/test-results/data/ --flowcoverageroot=D:/projects/repositories/TDC/se-gui-comparisontool/test-results/coverage/ --flowxunitoutputroot=D:/projects/repositories/TDC/se-gui-comparisontool/test-results/xunit/ --flowvisualdebugroot=D:/projects/repositories/TDC/se-gui-comparisontool/test-results/debug/ --flowvisualstestroot=D:/projects/repositories/TDC/se-gui-comparisontool/phantomflow_tests/visuals/ --flowvisualsoutputroot=D:/projects/repositories/TDC/se-gui-comparisontool/test-results/visuals/ --flowdebug=1 --hideelements= --flowtests=flows/responsive.test.js

casperjs returned URL Changed:"about:blank" without other info.

I would think that it had something to do with the test-results folder, because it says it can't find. But I created it, and the report folder inside that, and then when I ran it again those were deleted - which makes sense, the report is overwritten every time it is generated?

My code to run things is the following js

const path = require('path');
const connect = require('connect');
const static = require('serve-static');
const commandLineArgs = require('command-line-args');
const phantomflow = require('phantomflow');

const optionDefinitions = [
  { name: 'site', type: String, defaultValue: 'local', description: 'The site we want to test, by default it will be testing on your local host. Values are business, help, or local.'},
  { name: 'testTarget', type: String, defaultValue: 'pages', description: 'Values are either business or integration. In localhost it is assumed that pages are production, and components are integration' },
  { name: 'debug',  type: Number, defaultValue: 1, description: 'Passes value to phantomflow to control debugging - A value of 1 will output more logging, 2 will generate full page screenshots per test which can be found in the test-results folder. Forces tests onto one thread for readability. ' },
  { name: 'earlyexit',  type:  Boolean, defaultValue: false, description: 'Exit as soon as a test fails' },
  { name: 'createReport', type: Boolean, defaultValue: true, description: 'Passes value to phantomflow as to whether there should be any report created' },
  { name: 'remoteDebug', type: Boolean, defaultValue: false, description: 'Enable PhantomJS remote debugging' },
  { name: 'help', alias: 'h', type: Boolean, defaultValue: false, description: 'Show this help message' },
  { name: 'dashboard', type: Boolean, defaultValue: false, description: 'Allow phantomflow dashboard creation and display in command line' }

]
const options = commandLineArgs(optionDefinitions);
const phantomFlowConfig = {
  tests: "phantomflow_tests/",
  earlyexit: options.earlyexit,
  debug: options.debug,
  remoteDebug: options.remoteDebug,
  createReport: options.createReport,
  dashboard: options.dashboard
};
//TODO switch to command-line-usage tool if want better printing of arguments.

if(options.help){
  console.log("Options:\n");
  let item = "";
  for(var x = 0; x < optionDefinitions.length;x++){
    item = optionDefinitions[x];
    console.log("---------------------------------------\n");
    console.log("Property name = "+ item.name + "\n");
    console.log(item.description);
    console.log("---------------------------------------\n");

  }
}

var flow = phantomflow.init(phantomFlowConfig);

if(options.showReport){

    flow.report();

} else {
    const app = connect();
    app.use(static( path.join(__dirname, '..', 'ui_for_tests')));
    app.listen(9001);

    flow.run(function(code){
        process.exit(code);
    });
}

and inside of my phantomflow_tests/flows folder is a single test that just reuses a version of the responsive.test.js from the examples:

(function(){

    flow("My first responsive webpage", function(){
        decision({
            "View in 1500px": function(){
                step('Look at the page', function(){
                  lookAtIt(1500);
                });
            },
            "View in 990px": function(){
                step('Look at the page', function(){
                  lookAtIt(990);
                });
            },
            "View in 440px": function(){
                step('Look at the page', function(){
                  lookAtIt(440);
                });
            }
        });
    });

    function lookAtIt(w){
        casper.viewport(w, 768).thenOpen("https://tdc.dk", function(){
            casper.test.pass('Responsive page has loaded');
            phantomCSS.screenshot('body');
            console.log("look at it test now");

        });
    }

}());

Any ideas why it is not working on my system - anything you want me to try to see if I can get it to work?

bryanrasmussen commented 7 years ago

looking at it some more. If I create by hand a folder test-results, that folder gets deleted when I run the tests above. Then when it gets to writeLogFile in phantomflow.js and it gives the message

Please take a look at the error log for more info 'D:\projects\repositories\TDC\se-gui-comparisontool\test-results/log/error_1.log'

writeLogFile is actually getting the error

{ Error: ENOENT: no such file or directory, open 'D:\projects\repositories\TDC\se-gui-comparisontool\test-results\log\error_1.log' at Error (native) errno: -4058, code: 'ENOENT', syscall: 'open', path: 'D:\projects\repositories\TDC\se-gui-comparisontool\test-results\log\error_1.log' }

If the folder is not present it looks like it never gets created.

jamescryer commented 7 years ago

I got your example running after stripping out the excess code in test.js. For that test suite you don't need a connect server (because you've already got a hosted site). To simplify things I also removed all the command-line args stuff as well.

My suggestion is to strip it back to the basics then add more until it breaks, which will hopefully diagnose your problem.

fwiw, I'm on node v4.4.5, perhaps there is a dependency problem with v6 / v7 ?

bryanrasmussen commented 7 years ago

Ok. thanks. maybe the connect or the versions are the problems - don't think its command line because that stuff was working before, but anyway as I am going to have to branch with environment variables in the most important cases I guess I can get rid of that as well.

On Fri, Dec 23, 2016 at 11:50 AM, James Cryer notifications@github.com wrote:

I got your example running after stripping out the excess code in test.js. For that test suite you don't need a connect server (because you've already got a hosted site). To simplify things I also removed all the command-line args stuff as well.

My suggestion is to strip it back to the basics then add more until it breaks, which will hopefully diagnose your problem.

fwiw, I'm on node v4.4.5, perhaps there is a dependency problem with v6 / v7 ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Huddle/PhantomFlow/issues/51#issuecomment-268972391, or mute the thread https://github.com/notifications/unsubscribe-auth/AATEQCF7Hvxesm8E644J9v2di2jCmEqAks5rK6degaJpZM4LQ5Pu .