Merge pull request #23 from mozilla/add-logging-to-tests

Added logging to test output.
This commit is contained in:
Gijs 2015-03-17 14:45:48 -07:00
commit 47d49dd43a
3 changed files with 16 additions and 3 deletions

View File

@ -18,7 +18,7 @@
* This code is heavily based on Arc90's readability.js (1.7.1) script
* available at: http://code.google.com/p/arc90labs-readability
*/
var root = this;
var Readability = function(uri, doc) {
var ENABLE_LOGGING = false;
@ -46,8 +46,13 @@ var Readability = function(uri, doc) {
// Control whether log messages are sent to the console
if (ENABLE_LOGGING) {
var logger;
this.log = function (msg) {
if ("dump" in root) {
dump("Reader: (Readability) " + msg + "\n");
} else if ("console" in root) {
console.log("Reader: (Readability) " + msg + "\n");
}
};
} else {
this.log = function () {};

View File

@ -21,6 +21,6 @@
"chai-as-promised": "^4.3.*",
"html": "0.0.*",
"mocha": "^2.2.*",
"readable-proxy": "1.2.*"
"readable-proxy": "1.3.*"
}
}

View File

@ -30,6 +30,14 @@ describe("Test page", function() {
return scrape("file://" + testPage.source).catch(function(err) {
throw err;
}).then(function(result) {
// print Readability log messages
(result.consoleLogs || [])
.filter(function(logMessage) {
return logMessage.indexOf("Reader: (Readability)") === 0;
})
.forEach(function(logMessage) {
console.log("[LOG]", logMessage);
});
// normalize html
return prettyPrint(result.content);
}).should.eventually.become(prettyPrint(expected));