huddleeng / phantomflow Goto Github PK
View Code? Open in Web Editor NEWDescribe and visualise user flows through tests with PhantomJS
License: MIT License
Describe and visualise user flows through tests with PhantomJS
License: MIT License
Hi,
README.md mentions that you can run node test/test.js report
to load the Decision tree visualisation into your Web browser, but I get the following error:
D:\Learning\PhantomFlow\phantomflow.js:600
log( "A report hasn't been generated. Maybe you haven't set the
createRepor
^
ReferenceError: log is not defined
at showReport (D:\Learning\PhantomFlow\phantomflow.js:600:3)
at Object.report (D:\Learning\PhantomFlow\phantomflow.js:112:9)
at Object.<anonymous> (D:\Learning\PhantomFlow\test\test.js:40:7)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
Might this be a bug? If not, any idea how to resolve this?
Note that running node test/test.js
and node test/test.js dashboard
works for me.
Hi,
I'm new to node.js, so maybe this is my fault but I can't find it :(
I do following things to install PhantomFlow:
brew install node
git clone git clone https://github.com/Huddle/PhantomFlow.git
npm install
node test/test.js
Then it shows:
PhantomJS is not installed? Try `npm install`
Parallelising 2 test files on 2 threads.
It broke, sorry. Threads aborted. Non-zero code (1) returned.
A thread has completed.
It broke, sorry. Threads aborted. Non-zero code (1) returned.
All the threads have completed.
Completed 0 tests in 0 seconds. 0 failed, 0 passed.
/Users/weiwang/opensource/PhantomFlow/node_modules/wrench/lib/wrench.js:249
if (e.code !== 'EEXIST') throw e;
^
Error: ENOENT, no such file or directory '/Users/weiwang/opensource/PhantomFlow/test-results/report'
at Error (native)
at Object.fs.mkdirSync (fs.js:751:18)
at Object.exports.copyDirSyncRecursive (/Users/weiwang/opensource/PhantomFlow/node_modules/wrench/lib/wrench.js:246:12)
at copyReportTemplate (/Users/weiwang/opensource/PhantomFlow/phantomflow.js:415:10)
at ChildProcess.<anonymous> (/Users/weiwang/opensource/PhantomFlow/phantomflow.js:271:8)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1008:16)
at Socket.<anonymous> (child_process.js:1176:11)
at Socket.emit (events.js:107:17)
at Pipe.close (net.js:476:12)
Then I run npm install again:
> phantomjs@1.9.18 install /Users/weiwang/opensource/PhantomFlow/node_modules/phantomjs
> node install.js
Download already available at /var/folders/t7/qb22hwj15j7c9yph0xbt7s1c0000gn/T/phantomjs/phantomjs-1.9.8-macosx.zip
Extracting zip contents
Removing /Users/weiwang/opensource/PhantomFlow/node_modules/phantomjs/lib/phantom
Copying extracted folder /var/folders/t7/qb22hwj15j7c9yph0xbt7s1c0000gn/T/phantomjs/phantomjs-1.9.8-macosx.zip-extract-1439752203893/phantomjs-1.9.8-macosx -> /Users/weiwang/opensource/PhantomFlow/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /Users/weiwang/opensource/PhantomFlow/node_modules/phantomjs/lib/phantom/bin/phantomjs
But it still not work :( just output as I paste first
This is awesome by the way...
I'm successfully running this inside an Express app. My aim is to integrate this into a small local service for testing and retesting various sites. Some of those sites require u:p credentials to log in. Although I can hardcode them into the tests (with casper.setHttpAuth()), I'd rather be able to pass these in from the outside. Possible to do something like '--flowargs=...' or similar? Essentially, I need to get something user-supplied from the node/Express app req.params into the individual tests... is this possible in the current setup, or a possible enhancement?
Many thanks,
Rob
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"
}
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.
What I ran:
git clone https://github.com/Huddle/PhantomFlow.git
cd PhantomFlow
npm install
node test/test.js
What I get:
Parallelising 2 test files on 2 processes.
Picking up job: flows/responsive.test.js
[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 '/home/haoyang.feng/mos/work/PhantomFlow/test-results/log/error_2.log'
Picking up job: flows/coffeemachine.test.js
[flows/coffeemachine.test.js] It broke, sorry. Process aborted. Non-zero code (1) returned.
[flows/coffeemachine.test.js] It broke, sorry. Process aborted. Non-zero code (1) returned.
Please take a look at the error log for more info '/home/haoyang.feng/mos/work/PhantomFlow/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 0.07s
[flows/coffeemachine.test.js] 1 0 passes 0 fails 0.067s
Completed 0 assertions in 0 seconds. 0 assertions failed, 0 assertions passed.
/home/haoyang.feng/mos/work/PhantomFlow/node_modules/wrench/lib/wrench.js:249
if (e.code !== 'EEXIST') throw e;
^
Error: ENOENT: no such file or directory, mkdir '/home/haoyang.feng/mos/work/PhantomFlow/test-results/report'
at Object.fs.mkdirSync (fs.js:855:18)
at Object.exports.copyDirSyncRecursive (/home/haoyang.feng/mos/work/PhantomFlow/node_modules/wrench/lib/wrench.js:246:12)
at copyReportTemplate (/home/haoyang.feng/mos/work/PhantomFlow/phantomflow.js:569:10)
at /home/haoyang.feng/mos/work/PhantomFlow/phantomflow.js:515:7
at Timeout.<anonymous> (/home/haoyang.feng/mos/work/PhantomFlow/node_modules/async/lib/async.js:789:30)
at Timeout._onTimeout (/home/haoyang.feng/mos/work/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)
In your original idea of fluent communication, implementing the Gherkin language would allow the non-technical team member to write testing scenarios on their own.
When I run the sample test.js for the first time, it throws me the above error at line 358 in phantomflow.js. Wasn't sure if this is to be expected on the first pass or a bigger issue? It completed 17 tests with no failures, and then the second time I ran it, it didn't throw this error and 33 tests passed.
Also, maybe I missed it, but why do we need to run it from the main directory? Is there some relative path that it needs?
git clone https://github.com/Huddle/PhantomFlow.git cd phantomflow npm install
Is not working.
-$ node tests/visual/runner.js test=foo
Parallelising 1 test files on 1 threads.
TESTFILE foo.test.js
~ Phantom Flow. Running all paths for: default
~ default
~ initial
return diffile
[PhantomCSS] Screenshot capture failed: No element matching selector found: #foo
TESTFILE PhantomCSS
There are 0 visual tests to check
<testsuite name="[foo.test.js] default" tests="0" failures="0">
</testsuite>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
JUnit output: No test cases for foo.test.js
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Fini.
All the threads have completed.
Completed 0 tests in 3 seconds. 0 failed, 0 passed.
-$ echo $?
0
As a developer
Given that I run a PhantomFlow test
And the element I'm trying to take a screenshot of doesn't exist
Then the test should fail
And an error should be thrown informing me about the guilty selector
So that I'm aware that my code doesn't work as expected.
As a developer
Given that I run a PhantomFlow test
And the element I'm trying to take a screenshot of doesn't exist
Then the test should fail
So that I'm aware that something is wrong with my code.
As a developer
Given that I run a PhantomFlow test
And the element I'm trying to take a screenshot of doesn't exist
Then an error should be thrown informing me about the guilty selector
So that I'm aware of what went wrong.
As a developer
Given that I run a PhantomFlow test
And the element I'm trying to take a screenshot of doesn't exist
Then a non-zero exit code should be returned
So my tasks can fail.
I have a problem. I cannot set a breakpoint in a *.test.js
file to debug my test.
My test.js
file:
(function(){
"use strict";
var path = require('path');
var connect = require('connect');
var showReport;
var filterTest;
var debugMode;
process.argv.forEach(function(arg, i){
if (arg === 'report') {
showReport = true;
}
if (/^debug/.test(arg)){
debugMode = true;
}
if (/^test=/.test(arg)){
filterTest = arg.split('=')[1];
}
});
var flow = require('phantomflow').init({
earlyexit: false, // abort as soon as a test fails (also prevents report creation)
debug: 2,
createReport: true,
test: filterTest,
tests: "css-tests",
threads: 1,
});
if(showReport) {
flow.report();
} else {
connect(connect.static(path.join(__dirname, '..'))).listen(9001);
debugger;
// casper.options.verbose = true;
// casper.options.logLevel ="debug";
flow.run(function() {
process.exit(0);
});
}
}());
And my only test:
debugger;
(function(){
"use strict";
debugger;
/* Flows */
flow("Open Hello World!", function(){
debugger;
step("Go to Hello World!", goToHelloWorld);
});
/* Steps */
function goToHelloWorld(){
casper.thenOpen("http://localhost:9001/", function(){
debugger;
casper.test.pass('Index page has loaded');
phantomCSS.screenshot('body');
});
}
}());
The breakpoint in test.js
gets hit, but the other ones do not. Is there a way to achieve what I need to debug simply the tests?
I used the command node-debug css-tests/test.js
.
Hello!
I've previously gotten PhantomCSS integrated into my app, and it works great!
I want to explore using PhantomFlow, but I'm having problems getting it integrated. I'm more designer than developer, so my Node and CLI troubleshooting skills are a little pedestrian, and I apologize ahead of time if the solution should be obvious π
Anyway, cloning the repo works fine; however when I try to install PhantomFlow as a module in my project, it doesn't run.
$ cd my-project
$ npm install phantomflow --save-dev
I set up my directories to mirror the demo.
my-project/
|
βββ test/
βββ my-test.js
|
βββ flows/
βββ hello.test.js
For my-test.js
, I used the NodeJS setup example from the documentation.
// my-test.js
var flow = require('../node_modules/phantomflow').init({
debug: 1,
// createReport: true,
// test: 'coffee'
});
// flow.report(); // Show report
flow.run(function(code){
process.exit(code); // callback is executed when PhantomFlow is complete
});
The example seems considerably less complicated than the test.js file from the demo.
That file didn't run either, though, so I figured I'd go with the less complicated version?
The flow is a simple file...
// hello.test.js
(function(){
/*
User flows described in one decision tree
*/
flow("Say hello", function(){
step("Open mouth", openMouth);
});
/*
Steps
*/
function openMouth(){
casper.log('Opening mouth...', 'debug');
}
}());
But, when I attempt to run the test, I get the following error. Although, it's not really an error, I guess, but the Terminal prompt just sits there and blinks at me π
$ cd my-project/
$ node test/my-test.js
Parallelising 0 test files on 1 threads.
I am trying to move some existing PhantomCSS and Casper tests to use PhantomFlow. Is there a way to require
other modules/deps inside flows. From what I understand they are run in the Phantom domain, so it may need either a build step or additional config.
Alternatively, is there an example setup of PhantomFlow being included in a project as a dependency - I've been finding the included examples useful as a starting point but missing a few things.
Other info:
Current directory structure (with Casper/PhantomCSS) looks like this:
test
|-- pages
| |-- homepage.js
|
|-- homepage.test.js
|-- test-utils.js
Then homepage.test.js
looks like this:
var homepage = require('./pages/homepage.test');
var testUtils = require('./test-utils');
casper.start();
homepage.load();
testUtils.capture();
Thanks!
I was able to work around this by changing the line in tests.js to:
var connect = require( path.resolve( 'node_modules' ) + '/phantomflow/node_modules/connect');
DISCLAIMER: I am not sure if this is related to PhantomFlow or CasperJS.
In a flow
I use multiple times the same method addRandomProductToCart()
, it passes only once, then the next asserts are ignored. Any idea from where this comes?
Hey,
Not a bug, but wanted to see if you had some more detailed instructions on getting the d3 flow chart up and working.
I installed http-server but sort of a noob here.
Let me know if you have some more details on this, thanks!
Because npm@3 dependencies are flat.
module.js:338
throw err;
^
Error: Cannot find module 'E:\hwong\codes\p4\main\src\mgmt\ui\phantomcss\node_modules\phantomflow\node_modules\phantomcss\node_modules\phantomjs'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at getCasperPath (E:\hwong\codes\p4\main\src\mgmt\ui\phantomcss\node_modules\phantomflow\phantomflow.js:596:18)
at Object.module.exports.init (E:\hwong\codes\p4\main\src\mgmt\ui\phantomcss\node_modules\phantomflow\phantomflow.js
:35:19)
at Object.<anonymous> (E:\hwong\codes\p4\main\src\mgmt\ui\phantomcss\test\test.js:25:35)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
/* file1.test.js */
flow('flow1', function() {
step('step1', function() {
casper.on('stuff', function() {
console.log('stuff is happening');
});
});
});
/* file2.test.js */
flow('flow2', function() {
step('step1', function() {
casper.emit('stuff');
});
});
$ node tests/visual/runner.js test=stuff
Parallelising 2 test files on 1 threads.
TESTFILE stuff/file1.test.js
~ Phantom Flow. Running all paths for: flow1
~ flow1
~ step1
TESTFILE stuff/file2.test.js
~ Phantom Flow. Running all paths for: flow2
~ flow2
~ step1
stuff is happening <- offending
Fini.
As a developer
I want my tests to be independent
So that they don't influence each other
So that I may have predictable and deterministic test results
So that I can have visual coverage.
Hi,
I'm just learning PhantomFlow and trying the sample. I added more flows but when I run the test again using the following command the new flow is not picked.
node test/test.js report
I also deleted one of the flow file from test/flows but when I run the command again, I'm seeing the old two flows like below.
is there any way to force refreshing?
Thanks,
Bruk
The last release was back in January and we had some notable functionality changes in regards to running/regenerating reports for single/specific matched sets of flows [rather than all at once], so a version bump would be very helpful for keeping things up to date with npm.
As a developer
I want PhantomFlow to exit with a non-zero return code when tests fail
So that my scripts know when tests have failed.
The exit code of PhantomFlow is 0 no matter if the tests fail or pass.
Completed 4 tests in 5 seconds. 1 failed, 3 passed.
$ echo $?
0
Taken from the README:
flow.run(function() {
process.exit(0);
});
Can you get the exit code of PhantomCSS somehow and pass it to process.exit?
I traced it to this function.
First of all, why are you blocking image requests? It doesn't make much sense to block images in visual tests, but maybe I'm missing something here.
If that function is indeed useful, than you should note that the Regex you are using in the first conditional is incorrect:
!data
doesn't mean 'if it doesn't match data', it means literal !data
.The second conditional does the right thing.
Check here for more info http://regex101.com/r/cA4hV4/3
I would remove the !data
part out of the first conditional and remove the second conditional completely.
Also, the shouldAbort
variable you're using here is set to true
at the beginning of the file. It is then set to false
here but in my debugging sessions I never entered that function.
Hi,
I grabbed your PhantomFlow example and tried running the tests via:
'phantomjs demo/runTests.js' but keep getting "CasperError: Cannot dispatch click event on nonexistent selector: #coffeemachinebutton".
I first wasn't sure if the HTML page needed to be open in the browser first (I tried it this way and still no luck) or there was some other prep work I need to do to run it.
Let me know as I would love to implement this in my project.
Thanks
Ted
To try out the demo for yourself run from the command line. node test/test.js
After the first test-run, run this to see the visualisation node test/test.js report
When following these instructions, when calling node test/test.js report
I get the following error:
A report hasn't been generated. Maybe you haven't set the createReport option?
Any idea what I'm doing wrong?
The ui-view elements are not appear when I use as below:
casper.start('https://carepilot-web-staging.herokuapp.com/login');
casper.then( function () {
require('utils').dump(this.getElementInfo('.main-page'));
phantomcss.screenshot( '.loginWrapper', 'Get login page' );
this.echo('get login page...');
} );
the require print out the div null
<div ui-view=\"\" class=\"main-page ng-scope\"></div>
it should be:
<div ui-view="" class="main-page ng-scope" style="">
<div class="loginWrapper ng-scope" ng-controller="loginController as vm">
<div class="login-panel">
<div login-form="" ng-hide="vm.showForgotPassword || vm.showTOU"><form name="vm.loginForm" ng-submit="vm.login()" class="ng-pristine ng-valid-email ng-invalid ng-invalid-required" style="">
<div class="panel-fields">
<div class="logo icon-logo"></div>
<div>
<input type="email" name="username" id="username" class="form-control ng-pristine ng-untouched ng-empty ng-valid-email ng-invalid ng-invalid-required" ng-model="vm.username" placeholder="Email" required="" ng-class="{'error': vm.loginError && username.$pristine}" style="">
<!-- ngIf: vm.loginError -->
</div>
<div>
<input type="password" name="password" id="password" class="form-control ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required" ng-model="vm.password" placeholder="Password" required="" ng-class="{'error': vm.loginError && password.$pristine}" style="">
<!-- ngIf: vm.loginError -->
</div>
<div ng-show="vm.resetEmail" class="ng-binding ng-hide" style="">Reset Password email has been sent to </div>
</div>
<div class="panel-buttons">
<button id="loginButton" type="submit" class="btn-login ng-binding ng-hide-remove" ng-show="!vm.loginError || vm.loginForm.$dirty" ng-class="{ 'btn-login-green' : vm.loginForm.$valid }">Login</button>
<button id="errorButton" class="btn-login btn-login-red ng-hide" ng-show="vm.loginError && !vm.loginForm.$dirty" disabled="disabled" style="">
<div class="ng-binding">SORRY</div>
<div class="ng-binding">We didn't recognize that email and password</div>
</button>
<button id="forgotPwdButton" type="button" class="btn-login btn-clear ng-binding" ng-click="vm.showForgotPassword=true">I forgot my password</button>
</div>
</form>
</div>
</div>
</div>
I tried a hole day with no success, can anyone give me some suggestion? Thanks!
doing one of http://huddle.github.io/PhantomFlow/demo/phantomFlowReport
would be awesomeee
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?
Basically I want to do some stuff on top of phantomflow, and to have logic branching based on command line arguments as to whether one runs production or integration tests against a remote url or on the local server.
The easiest for me would be if I can pass my arguments all the way down to the tests that are started by casperjs.
Is that possible or should I use environmental variables instead to do the branching?
Hello,
How can I change the value of mismatchTolerance option belonging to phantomcss? I use grunt-phantomflow to be exact.
Is phantomflow support python LanguageοΌ Beause I am no good at JS.
I cannot find it.
Hi, this project is awesome, thanks for creating it!
I was able to get it working straight from cloning the repo, and then integrated it into my app.
To integrate it into my app, I had to change some code around in phantomflow.js to get dependencies to load.
But, if I try to use it as an npm dependency, I get this error:
Error: Cannot find module '<project_directory>/node_modules/phantomflow/node_modules/phantomcss/node_modules/phantomjs'
It looks like it's looking for phantomCSS as a dependency to phantomFlow. In phantomFlow's package.json, I see phantomCSS. But when I run npm install phantomFlow --save-dev, npm puts phantomCSS as a sibling to phantomFlow in the tree, and the require at line 579 of phantomFlow fails.
I changed test.js to load phantomFlow like this:
var flow = require( path.resolve( 'node_modules' ) + '/phantomflow/phantomflow' ).init({
Trying to run on my project structure:
front/modules/name1/test/name1.test.js
front/modules/name2/test/name2.test.js
Script options: tests: 'front/modules/**/test'
works ok, all files processed, but result doesn't works (((
Looks like tests
var used alot, maybe it's better to split? For ex.:
`base`: 'whatever'
`tests: 'front/modules/**/test'`
When I pass casperArgs: ['--engine=slimerjs'], it fails to result in a casper object.
Has anyone else been able to use PhantomFlow with Slimer?
Just a quick question, would it be possible to use Selenium to drive the tests (ie, the click this, enter this, as part of the functional testing) and have PhantomFlow hook into that to take the screenshots at certain points during those tests?
The reason I ask is because we have thousands of existing tests written for Selenium already and would like to hook PhantomFlow into them without having to re-write all of the feature files and maintain two sets of tests for essentially the same thing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.