diff --git a/src/phantom.js b/src/phantom.js index cd86de1e..84ed53c3 100644 --- a/src/phantom.js +++ b/src/phantom.js @@ -26,6 +26,9 @@ function init(instance) { sslProtocol: 'any' })); }).then(function (ph) { + /* Phridge outputs everything to stdout by default */ + ph.childProcess.cleanStdout.unpipe(); + ph.childProcess.cleanStdout.pipe(process.stderr); phantom = ph; }).disposer(phridge.disposeAll); } diff --git a/tests/errors.js b/tests/errors.js index 574c42a0..be4a492b 100644 --- a/tests/errors.js +++ b/tests/errors.js @@ -66,6 +66,24 @@ describe('Error reporting', function () { }); }); + it('PhantomJS errors to stderr', function (done) { + var stderrBuffer = ''; + var oldWrite = process.stderr.write; + process.stderr.write = function (data) { + stderrBuffer += data; + }; + + uncss( + ['tests/phantomjs/throw.html'], + { raw: '' }, + function (error) { + expect(error).to.equal(null); + expect(stderrBuffer).to.contain('Exception'); + process.stderr.write = oldWrite; + done(); + }); + }); + it('css-parse errors', function (done) { uncss( ['tests/selectors/index.html'], diff --git a/tests/phantomjs/throw.html b/tests/phantomjs/throw.html new file mode 100644 index 00000000..9f98897c --- /dev/null +++ b/tests/phantomjs/throw.html @@ -0,0 +1,14 @@ + + + + + PhantomJS basic test + + + + + +