Permalink
Browse files

Function.prototype.bind fix for PhantomJS

  • Loading branch information...
1 parent b02ad13 commit f5d5192e122e9a7d668d93edd21fd4cf9581211f @malandrew malandrew committed Nov 20, 2014
Showing with 14 additions and 1 deletion.
  1. +7 −1 bin/cli.js
  2. +4 −0 index.js
  3. +2 −0 lib/phantom-function-bind-shim.js
  4. +1 −0 package.json
View
@@ -14,6 +14,7 @@ var port = Number(args.p || args.port) || 3000;
var help = args.help || args.h || args._.length === 0;
var phantom = args.b || args.phantom || args.phantomjs;
var report = args.p || args.report || args.istanbul;
+var debug = args.d || args.debug;
if (help) {
var helpText = [
@@ -25,6 +26,7 @@ if (help) {
' -p --port <number> The port number to run the server on (default: 3000)',
' -b --phantom Use the phantom headless browser to run tests and then exit with the correct status code (if tests output TAP)',
' -r --report Generate coverage Istanbul report. Repeat for each type of coverage report desired. (default: text only)',
+ ' -d --debug Debug PhantomJS by printing subprocess stdout and stderr.'
'',
'Example:',
' run-browser test-file.js --port 3030 --report text --report html --report=cobertura',
@@ -40,5 +42,9 @@ server.listen(port);
if (!phantom) {
console.log('Open a browser and navigate to "http://localhost:' + port + '"');
} else {
- runbrowser.runPhantom('http://localhost:' + port + '/');
+ var proc = runbrowser.runPhantom('http://localhost:' + port + '/');
+ if (debug) {
+ proc.stdout.pipe(process.stdout);
+ proc.stderr.pipe(process.stderr);
+ }
}
View
@@ -65,6 +65,10 @@ function createHandler(filename, reports, phantom) {
files = files.map(normalizePath);
files.unshift(path.join(__dirname, '/lib/override-log.js'));
+ if (phantom) {
+ files.unshift(path.join(__dirname, '/lib/phantom-function-bind-shim.js'));
+ }
+
var b = browserify(files);
if (reports) b.transform(instrumentTransform());
return b.bundle({debug: true}, onBrowserifySrc)
@@ -0,0 +1,2 @@
+'use strict';
+Function.prototype.bind = require("function-bind");
View
@@ -7,6 +7,7 @@
"dependencies": {
"browserify": "^3.28.0",
"browserify-istanbul": "^0.1.2",
+ "function-bind": "^1.0.2",
"glob": "~3.2.7",
"global": "^4.3.0",
"istanbul": "^0.3.2",

0 comments on commit f5d5192

Please sign in to comment.