Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-horseman

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-horseman - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

7

CHANGELOG.md
# Change Log
All notable changes to this project will be documented in this file.
##2.5.0 - 2015-10-08
### Added
- .log(). Closes #54.
### Fixed
- .viewport() wasn't returning the actual viewport size.
##2.4.0 - 2015-10-08

@@ -5,0 +12,0 @@ ### Added

24

lib/actions.js

@@ -127,9 +127,12 @@ var fs = require("fs");

exports.viewport = function(width, height) {
var self = this;
if (!width) {
debug('getting viewport()');
return this.evaluate(function() {
return {
width: window.innerWidth,
height: window.innerHeight
};
return this.ready.then(function() {
return self.evaluate(function() {
return {
width: window.innerWidth,
height: window.innerHeight
};
});
});

@@ -841,2 +844,13 @@ } else {

/*
* Log the output from either a previous chain method, or a string the user passed in.
* @param output
*/
exports.log = function(output){
return this.ready.then(function(){
console.log(output);
return;
});
}
//**************************************************//

@@ -843,0 +857,0 @@ // Tabs

@@ -166,3 +166,2 @@ var clone = require('clone');

/**

@@ -178,2 +177,3 @@ * Attach all the actions.

});
// Allow chaining off Promises

@@ -187,3 +187,7 @@ function addActions(p) {

var args = arguments;
var pt = p.then(function() {
var pt = p.then(function(output) {
if (output && name == 'log'){
args = [].slice.call(args);
args.push(output);
}
return action.apply(self, args);

@@ -190,0 +194,0 @@ });

{
"name": "node-horseman",
"version": "2.4.0",
"version": "2.5.0",
"description": "Run PhantomJS from Node",

@@ -18,3 +18,3 @@ "repository": {

"defaults": "~1.0.0",
"node-phantom-simple": "^2.0.4"
"node-phantom-simple": "^2.0.5"
},

@@ -21,0 +21,0 @@ "devDependencies": {

@@ -280,2 +280,17 @@ Horseman

####.log()
Outputs the results of the last call in the chain, or a string you provide, without breaking the chain.
```js
horseman
.open('http://www.google.com')
.count('a')
.log() // outputs the number of anchor tags
.click('a')
.log('clicked the button') //outputs the string
.finally(function(){
horseman.close();
});
```
####.do(fn)

@@ -285,3 +300,3 @@ Run an function without breaking the chain. Works with asynchronous functions. Must call the callback when complete.

```js
horseman.
horseman
.open('http://www.google.com')

@@ -291,3 +306,5 @@ .do(function(done){

})
.finally(horseman.close);
.finally(function(){
horseman.close();
});
```

@@ -294,0 +311,0 @@

@@ -15,3 +15,3 @@ var Horseman = require('../lib');

parallel(title, function() {
parallel(title, function() {

@@ -29,5 +29,6 @@ it('should set the user agent', function(done) {

.then(function(result) {
horseman.close();
result.should.equal("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36");
horseman.close();
})
.catch(done)
.finally(done);

@@ -50,2 +51,3 @@ });

.then(function(data) {
horseman.close();
var response = JSON.parse(data);

@@ -55,4 +57,4 @@ response.should.have.property('headers');

response.headers['X-Horseman-Header'].should.equal('test header');
horseman.close();
})
.catch(done)
.finally(done);

@@ -69,5 +71,6 @@ });

.then(function(data) {
horseman.close();
data.should.equal(serverUrl);
horseman.close();
})
.catch(done)
.finally(done);

@@ -84,5 +87,6 @@ });

.then(function(data) {
horseman.close();
data.should.equal(200);
horseman.close()
})
.catch(done)
.finally(done);

@@ -101,5 +105,6 @@ });

.then(function(data) {
horseman.close();
data.should.equal(serverUrl + "next.html");
horseman.close();
})
.catch(done)
.finally(done);

@@ -128,6 +133,7 @@ });

.then(function(data) {
horseman.close();
data.should.equal(serverUrl + "next.html");
horseman.close();
});
})
.catch(done)
.finally(done);

@@ -147,5 +153,6 @@ });

.then(function(result) {
horseman.close();
result.should.be.above(0);
horseman.close();
})
.catch(done)
.finally(done);

@@ -167,6 +174,7 @@ });

.then(function(vp) {
horseman.close();
vp.height.should.equal(size.height);
vp.width.should.equal(size.width);
horseman.close();
})
.catch(done)
.finally(done);

@@ -189,6 +197,7 @@ });

.then(function(coordinates) {
horseman.close();
coordinates.top.should.equal(50);
coordinates.left.should.equal(40);
horseman.close();
})
.catch(done)
.finally(done);

@@ -213,6 +222,7 @@

.then(function(body) {
horseman.close();
var result = JSON.parse(body);
result.cookies[cookie.name].should.equal(cookie.value);
horseman.close();
})
.catch(done)
.finally(done);

@@ -231,6 +241,7 @@

.then(function(body) {
horseman.close();
var result = JSON.parse(body);
Object.keys(result.cookies).length.should.equal(0);
horseman.close();
})
.catch(done)
.finally(done);

@@ -258,7 +269,8 @@ });

.then(function(body) {
horseman.close();
var result = JSON.parse(body);
result.cookies[cookies[0].name].should.equal(cookies[0].value);
result.cookies[cookies[1].name].should.equal(cookies[1].value);
horseman.close();
})
.catch(done)
.finally(done);

@@ -277,2 +289,3 @@ });

.then(function(response) {
horseman.close();
response = JSON.parse(response);

@@ -282,4 +295,4 @@ response.should.have.property('form');

response.form['universe'].should.equal('expanding');
horseman.close();
})
.catch(done)
.finally(done);

@@ -295,8 +308,9 @@

.open(serverUrl)
.then(function( status ){
.then(function(status) {
horseman.close();
status.should.equal('success');
horseman.close();
})
.catch(done)
.finally(done);
});

@@ -311,3 +325,3 @@

parallel(title, function() {
it('should get the title', function(done) {

@@ -321,5 +335,6 @@ var horseman = new Horseman({

.then(function(title) {
horseman.close();
title.should.equal('Testing Page');
horseman.close();
})
.catch(done)
.finally(done);

@@ -337,5 +352,6 @@

.then(function(exists) {
horseman.close();
exists.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -353,5 +369,6 @@

.then(function(exists) {
horseman.close();
exists.should.be.false;
horseman.close();
})
.catch(done)
.finally(done);

@@ -368,5 +385,6 @@ });

.then(function(count) {
horseman.close();
count.should.be.above(0);
horseman.close();
})
.catch(done)
.finally(done);

@@ -384,5 +402,6 @@

.then(function(html) {
horseman.close();
html.indexOf("code").should.be.above(0);
horseman.close();
})
.catch(done)
.finally(done);

@@ -399,5 +418,6 @@ });

.then(function(text) {
horseman.close();
text.trim().should.equal("This is my code.");
horseman.close();
})
.catch(done)
.finally(done);

@@ -415,5 +435,6 @@

.then(function(value) {
horseman.close();
value.should.equal("");
horseman.close();
})
.catch(done)
.finally(done);

@@ -430,5 +451,6 @@ });

.then(function(value) {
horseman.close();
value.should.equal("next.html");
horseman.close();
})
.catch(done)
.finally(done);

@@ -446,5 +468,6 @@

.then(function(value) {
horseman.close();
value.should.equal("3px");
horseman.close();
})
.catch(done)
.finally(done);

@@ -461,5 +484,6 @@ });

.then(function(value) {
horseman.close();
value.should.be.above(0);
horseman.close();
})
.catch(done)
.finally(done);

@@ -476,5 +500,6 @@ });

.then(function(value) {
horseman.close();
value.should.be.above(0);
horseman.close();
})
.catch(done)
.finally(done);

@@ -491,5 +516,6 @@ });

.then(function(visible) {
horseman.close();
visible.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -506,5 +532,6 @@ });

.then(function(visible) {
horseman.close();
visible.should.be.false;
horseman.close();
})
.catch(done)
.finally(done);

@@ -523,5 +550,6 @@ });

.then(function(result) {
horseman.close();
result.should.equal("Testing Page");
horseman.close();
})
.catch(done)
.finally(done);

@@ -541,27 +569,10 @@ });

.then(function(result) {
horseman.close();
result.should.equal(str);
horseman.close();
})
.catch(done)
.finally(done);
});
it('should do a function without breaking the chain', function(done){
var doComplete = false;
var horseman = new Horseman({
injectJquery: bool
});
horseman
.do(function(complete){
setTimeout(function(){
doComplete = true;
complete();
},500)
})
.then(function(){
doComplete.should.be.true;
horseman.close();
})
.finally(done);
});
});

@@ -574,3 +585,3 @@ }

parallel(title, function() {
after(function() {

@@ -605,5 +616,6 @@ if (fs.existsSync("out.png")) {

.then(function(result) {
horseman.close();
result.should.equal("isbob");
horseman.close();
})
.catch(done)
.finally(done);

@@ -622,5 +634,6 @@

.then(function(value) {
horseman.close();
value.should.equal('github');
horseman.close();
})
.catch(done)
.finally(done);

@@ -640,5 +653,6 @@

.then(function(value) {
horseman.close();
value.should.equal('');
horseman.close();
})
.catch(done)
.finally(done);

@@ -656,5 +670,6 @@ });

.then(function(value) {
horseman.close();
value.should.equal('1');
horseman.close();
})
.catch(done)
.finally(done);

@@ -671,5 +686,6 @@ });

.then(function() {
horseman.close();
fs.existsSync("out.png").should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -686,6 +702,7 @@ });

.then(function(asPng) {
horseman.close();
var type = typeof asPng;
type.should.equal('string');
horseman.close();
})
.catch(done)
.finally(done);

@@ -709,2 +726,4 @@

.then(function() {
horseman.close();
var smallSize = fs.statSync('small.png').size,

@@ -714,4 +733,4 @@ bigSize = fs.statSync('big.png').size;

bigSize.should.be.greaterThan(smallSize);
horseman.close();
})
.catch(done)
.finally(done);

@@ -734,2 +753,3 @@

.then(function() {
horseman.close();
// A4 size is slightly larger than US Letter size,

@@ -742,4 +762,4 @@ // which is the default pdf paper size.

euroSize.should.be.greaterThan(0);
horseman.close();
})
.catch(done)
.finally(done);

@@ -765,5 +785,6 @@ });

.then(function(err) {
horseman.close();
err.toString().indexOf("Error").should.be.above(-1);
horseman.close();
})
.catch(done)
.finally(done);

@@ -791,5 +812,6 @@

.then(function(keypresses) {
horseman.close();
keypresses.should.equal(6);
horseman.close();
})
.catch(done)
.finally(done);

@@ -832,3 +854,3 @@ });

.then(function(events) {
//console.log( events );
horseman.close();
events['mousedown'].should.be.greaterThan(0);

@@ -839,4 +861,4 @@ events['mouseup'].should.be.greaterThan(0);

events['mousemove'].should.be.greaterThan(0);
horseman.close();
})
.catch(done)
.finally(done);

@@ -856,5 +878,6 @@ });

.then(function(data) {
horseman.close();
data.indexOf("keyCode=13").should.be.greaterThan(-1);
horseman.close();
})
.catch(done)
.finally(done);

@@ -908,2 +931,45 @@ });

describe("Usability", function(){
it('should do a function without breaking the chain', function(done) {
var doComplete = false;
var horseman = new Horseman();
horseman
.do(function(complete) {
setTimeout(function() {
doComplete = true;
complete();
}, 500)
})
.then(function() {
horseman.close();
doComplete.should.be.true;
})
.catch(done)
.finally(done);
});
it('should log output', function(done) {
var horseman = new Horseman();
var oldLog = console.log;
var output = '';
console.log = function(message) {
output += message;
};
horseman
.open(serverUrl)
.count('a')
.log()
.then(function() {
console.log = oldLog;
horseman.close();
output.should.equal('1');
})
.catch(done)
.finally(done);
});
})
parallel("Inject jQuery", function() {

@@ -919,7 +985,6 @@ it('should inject jQuery', function(done) {

.then(function(result) {
horseman.close();
result.should.equal("function");
})
.then(function() {
horseman.close();
})
.catch(done)
.finally(done);

@@ -940,7 +1005,6 @@

.then(function(result) {
horseman.close();
result.should.equal("undefined");
})
.then(function() {
horseman.close();
})
.catch(done)
.finally(done);

@@ -960,4 +1024,6 @@ });

.then(function(result) {
horseman.close();
result.should.not.equal("2.1.1");
})
.catch(done)
.finally(done);

@@ -969,3 +1035,3 @@ });

parallel("Waiting", function() {
parallel("Waiting", function() {
it('should wait for the page to change', function(done) {

@@ -979,5 +1045,6 @@ var horseman = new Horseman();

.then(function(url) {
horseman.close();
url.should.equal(serverUrl + "next.html");
horseman.close();
})
.catch(done)
.finally(done);

@@ -996,5 +1063,6 @@ });

.then(function(url) {
horseman.close();
url.should.equal('http://www.google.com/');
horseman.close();
})
.catch(done)
.finally(done);

@@ -1010,7 +1078,8 @@ });

.then(function() {
horseman.close();
var end = new Date();
var diff = end - start;
diff.should.be.greaterThan(999); //may be a ms or so off.
horseman.close();
})
.catch(done)
.finally(done);

@@ -1026,5 +1095,6 @@ });

.then(function(count) {
horseman.close();
count.should.be.above(0);
horseman.close();
})
.catch(done)
.finally(done);

@@ -1048,8 +1118,7 @@ });

.then(function() {
timeoutHorseman.close();
timeoutFired.should.be.true;
})
.finally(function() {
timeoutHorseman.close();
done();
});
.catch(done)
.finally(done);

@@ -1072,8 +1141,7 @@ });

.then(function() {
timeoutHorseman.close();
timeoutFired.should.be.true;
})
.finally(function() {
timeoutHorseman.close();
done();
});
.catch(done)
.finally(done);

@@ -1100,8 +1168,7 @@ });

.then(function() {
timeoutHorseman.close();
timeoutFired.should.be.true;
})
.finally(function() {
timeoutHorseman.close();
done();
});
.catch(done)
.finally(done);
});

@@ -1114,3 +1181,3 @@ });

*/
describe("Frames", function() {
describe("Frames", function() {

@@ -1125,5 +1192,6 @@ it('should let you switch to a child frame', function(done) {

.then(function(html) {
horseman.close();
html.should.equal("This is frame 1.");
horseman.close();
})
.catch(done)
.finally(done);

@@ -1149,5 +1217,6 @@

.then(function() {
horseman.close();
fired.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -1166,5 +1235,6 @@ });

.then(function() {
horseman.close();
fired.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -1184,5 +1254,6 @@ });

.then(function() {
horseman.close();
fired.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -1201,5 +1272,6 @@ });

.then(function() {
horseman.close();
fired.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -1218,5 +1290,6 @@ });

.then(function() {
horseman.close();
fired.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -1235,5 +1308,6 @@ });

.then(function() {
horseman.close();
fired.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -1252,5 +1326,6 @@ });

.then(function() {
horseman.close();
fired.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -1272,5 +1347,6 @@ });

.then(function() {
horseman.close();
fired.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -1292,5 +1368,6 @@ });

.then(function() {
horseman.close();
fired.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -1312,5 +1389,6 @@ });

.then(function() {
horseman.close();
fired.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -1325,3 +1403,3 @@ });

parallel('Tabs', function() {
parallel('Tabs', function() {

@@ -1335,5 +1413,6 @@ it('should let you open a new tab', function(done) {

.then(function(count) {
horseman.close();
count.should.equal(2);
horseman.close();
})
.catch(done)
.finally(done);

@@ -1353,5 +1432,6 @@ });

.then(function() {
horseman.close();
fired.should.be.true;
horseman.close();
})
.catch(done)
.finally(done);

@@ -1368,8 +1448,8 @@

.url()
.then(function(url){
.then(function(url) {
horseman.close();
url.should.equal(serverUrl);
horseman.close();
})
.catch(done)
.finally(done);
});

@@ -1376,0 +1456,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc