adding logging for js tests

This commit is contained in:
Shruti Ranganathan Jothi
2017-03-08 19:30:02 -08:00
parent b0061b88ad
commit 1f5c5454f2
15 changed files with 579 additions and 151 deletions

View File

@@ -1,9 +1,10 @@
"use strict";
const colors = require("colors/safe");
const sprintf = require("sprintf-js").sprintf;
const winston = require("winston");
const moment = require("moment");
const colors = require("colors/safe");
const sprintf = require("sprintf-js").sprintf;
const winston = require("winston");
const moment = require("moment");
const keypress = require("keypress");
const levels = { error: 0, warn: 1, info: 2, verbose: 3, debug: 4 };
const transports = [
@@ -14,7 +15,7 @@ const transports = [
new (winston.transports.File)({
level: "debug",
name: "log_file",
filename: "log.txt",
filename: "js_tests_log.txt",
json: false,
formatter: fileFormatter,
options: { flags: "w" }
@@ -41,6 +42,29 @@ function fileFormatter(options) {
return str;
}
function ask(description) {
return new Q.Promise(function (resolve, reject) {
// make `process.stdin` begin emitting "keypress" events
keypress(process.stdin);
process.stdin.setRawMode(true);
process.stdin.resume();
console.log(description);
// listen for the "keypress" event
process.stdin.on("keypress", function (ch, key) {
if (key && key.name === "return") {
process.stdin.pause();
return resolve();
}
if (key && key.name === "backspace") {
process.stdin.pause();
return reject("User marked the step as FAILED");
}
});
});
}
function printTestInfo(testFile, description) {
winston.info(sprintf("[%-s] %-20s : %-s", moment().format("YYYY-MM-DDTHH:mm:ssZ"), "TEST", testFile));
winston.info(sprintf("[%-s] %-20s : %-s", moment().format("YYYY-MM-DDTHH:mm:ssZ"), "DESCRIPTION", description));