How to run mocha and mocha-phantomjs tests from one “npm test” command in node.js?

I like the following: “scripts”: { “test”: “npm run test-node && npm run test-browser”, “test-node”: “mocha -R spec ./test/node/index.js”, “test-browser”: “mocha-phantomjs ./test/browser/index.html”} The && only runs the second if the first passes, and you can run either separately if you want. Note that npm always uses the relative mocha (inside node_modules), not the global one, … Read more

Save and render a webpage with PhantomJS and node.js

From your comments, I’d guess you have 2 options Try to find a phantomjs node module – https://github.com/amir20/phantomjs-node Run phantomjs as a child process inside node – http://nodejs.org/api/child_process.html Edit: It seems the child process is suggested by phantomjs as a way of interacting with node, see faq – http://code.google.com/p/phantomjs/wiki/FAQ Edit: Example Phantomjs script for getting … Read more

Nodejs Child Process: write to stdin from an already initialised process

You need to pass also \n symbol to get your command work: var spawn = require(‘child_process’).spawn, child = spawn(‘phantomjs’); child.stdin.setEncoding(‘utf-8’); child.stdout.pipe(process.stdout); child.stdin.write(“console.log(‘Hello from PhantomJS’)\n”); child.stdin.end(); /// this call seems necessary, at least with plain node.js executable

PhantomJS; click an element

.click() is not standard. You need to create an event and dispatch it: function click(el){ var ev = document.createEvent(“MouseEvent”); ev.initMouseEvent( “click”, true /* bubble */, true /* cancelable */, window, null, 0, 0, 0, 0, /* coordinates */ false, false, false, false, /* modifier keys */ 0 /*left*/, null ); el.dispatchEvent(ev); }

PhantomJS failing to open HTTPS site

I tried Fred’s and Cameron Tinker’s answers, but only –ssl-protocol=any option seem to help me: phantomjs –ssl-protocol=any test.js Also I think it should be way safer to use –ssl-protocol=any as you still are using encryption, but –ignore-ssl-errors=true will ignore (duh) all ssl errors, including malicious ones.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)