From 548df20a6d684df8bc5207cd4c373858d8165472 Mon Sep 17 00:00:00 2001 From: Honza Javorek Date: Thu, 17 Jan 2019 18:29:52 +0100 Subject: [PATCH] refactor: log only as error, warning, and debug --- docs/hooks/index.rst | 2 - docs/how-to-guides.rst | 2 - lib/CLI.js | 48 +++++++++--------- lib/Dredd.js | 18 +++---- lib/HooksWorkerClient.js | 34 ++++++------- lib/TransactionRunner.js | 41 +++++++-------- lib/addHooks.js | 2 +- lib/configuration.js | 2 +- lib/configureReporters.js | 2 +- lib/logger.js | 8 +-- lib/reporters/ApiaryReporter.js | 6 +-- lib/reporters/BaseReporter.js | 2 +- lib/reporters/CLIReporter.js | 6 +-- lib/reporters/DotReporter.js | 6 +-- lib/reporters/HTMLReporter.js | 2 +- lib/reporters/MarkdownReporter.js | 2 +- lib/reporters/NyanReporter.js | 4 +- lib/reporters/XUnitReporter.js | 2 +- lib/reporters/reporterOutputLogger.js | 2 + .../integration/cli/configuration-cli-test.js | 31 +++++------- test/integration/cli/hookfiles-cli-test.js | 4 +- .../cli/server-process-cli-test.js | 8 +-- test/integration/dredd-test.js | 2 +- test/unit/CLI-test.js | 30 +++++------ test/unit/Dredd-test.js | 14 +++--- test/unit/HooksWorkerClient-test.js | 2 +- test/unit/reporters/ApiaryReporter-test.js | 10 ++-- test/unit/reporters/CLIReporter-test.js | 7 +-- test/unit/reporters/DotReporter-test.js | 6 +-- test/unit/transactionRunner-test.js | 50 +++++++++---------- 30 files changed, 171 insertions(+), 184 deletions(-) diff --git a/docs/hooks/index.rst b/docs/hooks/index.rst index 821292b56..69e6e18e3 100644 --- a/docs/hooks/index.rst +++ b/docs/hooks/index.rst @@ -137,7 +137,6 @@ You can get a list of all transaction names available in your API description do :emphasize-lines: 3, 5 $ dredd ./blog.apib http://127.0.0.1 --names - info: Beginning Dredd testing... info: Articles > List articles skip: GET (200) /articles info: Articles > Publish an article @@ -156,7 +155,6 @@ You can get a list of all transaction names available in your API description do :emphasize-lines: 3, 5 $ dredd ./blog.yaml http://127.0.0.1 --names - info: Beginning Dredd testing... info: Articles > List articles > 200 > application/json skip: GET (200) /articles info: Articles > Publish an article > 201 > application/json diff --git a/docs/how-to-guides.rst b/docs/how-to-guides.rst index b153f5553..c4799b2ef 100644 --- a/docs/how-to-guides.rst +++ b/docs/how-to-guides.rst @@ -656,7 +656,6 @@ Dredd will detect two HTTP transaction examples and will compile following trans :: $ dredd api-description.apib http://127.0.0.1 --names - info: Beginning Dredd testing... info: Resource > Update Resource > Example 1 info: Resource > Update Resource > Example 2 @@ -687,7 +686,6 @@ Command-line output of complex HTTP responses and expectations can be hard to re $ dredd apiary.apib http://127.0.0.1 --reporter=apiary warn: Apiary API Key or API Project Subdomain were not provided. Configure Dredd to be able to save test reports alongside your Apiary API project: https://dredd.org/en/latest/how-to-guides/#using-apiary-reporter-and-apiary-tests - info: Beginning Dredd testing... pass: DELETE /honey duration: 884ms complete: 1 passing, 0 failing, 0 errors, 0 skipped, 1 total complete: Tests took 1631ms diff --git a/lib/CLI.js b/lib/CLI.js index 5c7b69255..3b65b3f88 100644 --- a/lib/CLI.js +++ b/lib/CLI.js @@ -58,14 +58,14 @@ Example: // Gracefully terminate server stopServer(callback) { if (!this.serverProcess || !this.serverProcess.spawned) { - logger.verbose('No backend server process to terminate.'); + logger.debug('No backend server process to terminate.'); return callback(); } if (this.serverProcess.terminated) { logger.debug('The backend server process has already terminated'); return callback(); } - logger.verbose('Terminating backend server process, PID', this.serverProcess.pid); + logger.debug('Terminating backend server process, PID', this.serverProcess.pid); this.serverProcess.terminate({ force: true }); this.serverProcess.on('exit', () => callback()); } @@ -80,7 +80,7 @@ Example: if (this.exit) { this._processExit = (exitStatus) => { - logger.verbose(`Exiting Dredd process with status '${exitStatus}'.`); + logger.debug(`Exiting Dredd process with status '${exitStatus}'.`); logger.debug('Using configured custom exit() method to terminate the Dredd process.'); this.finished = true; this.stopServer(() => { @@ -89,19 +89,19 @@ Example: }; } else { this._processExit = (exitStatus) => { - logger.verbose(`Exiting Dredd process with status '${exitStatus}'.`); + logger.debug(`Exiting Dredd process with status '${exitStatus}'.`); logger.debug('Using native process.exit() method to terminate the Dredd process.'); this.stopServer(() => process.exit(exitStatus)); }; } } else { this._processExit = (exitStatus) => { - logger.verbose(`Exiting Dredd process with status '${exitStatus}'.`); + logger.debug(`Exiting Dredd process with status '${exitStatus}'.`); logger.debug('Using configured custom callback to terminate the Dredd process.'); this.finished = true; if (this.sigIntEventAdded) { if (this.serverProcess && !this.serverProcess.terminated) { - logger.verbose('Killing backend server process before Dredd exits.'); + logger.debug('Killing backend server process before Dredd exits.'); this.serverProcess.signalKill(); } process.removeEventListener('SIGINT', this.commandSigInt); @@ -145,7 +145,7 @@ Example: runExitingActions() { // Run interactive config if (this.argv._[0] === 'init' || this.argv.init === true) { - logger.silly('Starting interactive configuration.'); + logger.debug('Starting interactive configuration.'); this.finished = true; interactiveConfig(this.argv, (config) => { configUtils.save(config); @@ -156,13 +156,13 @@ Example: // Show help } else if (this.argv.help === true) { - logger.silly('Printing help.'); + logger.debug('Printing help.'); this.optimist.showHelp(console.error); this._processExit(0); // Show version } else if (this.argv.version === true) { - logger.silly('Printing version.'); + logger.debug('Printing version.'); console.log(`\ ${packageData.name} v${packageData.version} \ (${os.type()} ${os.release()}; ${os.arch()})\ @@ -173,10 +173,10 @@ ${packageData.name} v${packageData.version} \ loadDreddFile() { const configPath = this.argv.config; - logger.verbose('Loading configuration file:', configPath); + logger.debug('Loading configuration file:', configPath); if (configPath && fs.existsSync(configPath)) { - logger.info(`Configuration '${configPath}' found, ignoring other arguments.`); + logger.debug(`Configuration '${configPath}' found, ignoring other arguments.`); this.argv = configUtils.load(configPath); } @@ -197,17 +197,17 @@ ${packageData.name} v${packageData.version} \ runServerAndThenDredd() { if (!this.argv.server) { - logger.verbose('No backend server process specified, starting testing at once'); + logger.debug('No backend server process specified, starting testing at once'); this.runDredd(this.dreddInstance); } else { - logger.verbose('Backend server process specified, starting backend server and then testing'); + logger.debug('Backend server process specified, starting backend server and then testing'); const parsedArgs = spawnArgs(this.argv.server); const command = parsedArgs.shift(); - logger.verbose(`Using '${command}' as a server command, ${JSON.stringify(parsedArgs)} as arguments`); + logger.debug(`Using '${command}' as a server command, ${JSON.stringify(parsedArgs)} as arguments`); this.serverProcess = spawn(command, parsedArgs); - logger.info(`Starting backend server process with command: ${this.argv.server}`); + logger.debug(`Starting backend server process with command: ${this.argv.server}`); this.serverProcess.stdout.setEncoding('utf8'); this.serverProcess.stdout.on('data', data => process.stdout.write(data.toString())); @@ -215,15 +215,15 @@ ${packageData.name} v${packageData.version} \ this.serverProcess.stderr.setEncoding('utf8'); this.serverProcess.stderr.on('data', data => process.stdout.write(data.toString())); - this.serverProcess.on('signalTerm', () => logger.verbose('Gracefully terminating the backend server process')); - this.serverProcess.on('signalKill', () => logger.verbose('Killing the backend server process')); + this.serverProcess.on('signalTerm', () => logger.debug('Gracefully terminating the backend server process')); + this.serverProcess.on('signalKill', () => logger.debug('Killing the backend server process')); this.serverProcess.on('crash', (exitStatus, killed) => { - if (killed) { logger.info('Backend server process was killed'); } + if (killed) { logger.debug('Backend server process was killed'); } }); this.serverProcess.on('exit', () => { - logger.info('Backend server process exited'); + logger.debug('Backend server process exited'); }); this.serverProcess.on('error', (err) => { @@ -234,7 +234,7 @@ ${packageData.name} v${packageData.version} \ // Ensure server is not running when dredd exits prematurely somewhere process.on('beforeExit', () => { if (this.serverProcess && !this.serverProcess.terminated) { - logger.verbose('Killing backend server process before Dredd exits'); + logger.debug('Killing backend server process before Dredd exits'); this.serverProcess.signalKill(); } }); @@ -242,14 +242,14 @@ ${packageData.name} v${packageData.version} \ // Ensure server is not running when dredd exits prematurely somewhere process.on('exit', () => { if (this.serverProcess && !this.serverProcess.terminated) { - logger.verbose('Killing backend server process on Dredd\'s exit'); + logger.debug('Killing backend server process on Dredd\'s exit'); this.serverProcess.signalKill(); } }); const waitSecs = parseInt(this.argv['server-wait'], 10); const waitMilis = waitSecs * 1000; - logger.info(`Waiting ${waitSecs} seconds for backend server process to start`); + logger.debug(`Waiting ${waitSecs} seconds for backend server process to start`); this.wait = setTimeout(() => { this.runDredd(this.dreddInstance); @@ -356,9 +356,9 @@ ${packageData.name} v${packageData.version} \ process.on('SIGINT', this.commandSigInt); } - logger.verbose('Running Dredd instance.'); + logger.debug('Running Dredd instance.'); dreddInstance.run((error, stats) => { - logger.verbose('Dredd instance run finished.'); + logger.debug('Dredd instance run finished.'); this.exitWithStatus(error, stats); }); diff --git a/lib/Dredd.js b/lib/Dredd.js index d7597afee..47b9847f3 100644 --- a/lib/Dredd.js +++ b/lib/Dredd.js @@ -69,7 +69,7 @@ ${proxySettings.join(', ')}. Please read documentation on how Dredd works with proxies: https://dredd.org/en/latest/how-it-works/#using-https-proxy `; - logger.verbose(message); + logger.debug(message); } } @@ -122,27 +122,27 @@ https://dredd.org/en/latest/how-it-works/#using-https-proxy } // Spin that merry-go-round - logger.verbose('Expanding glob patterns.'); + logger.debug('Expanding glob patterns.'); this.expandGlobs((globsErr) => { if (globsErr) { return callback(globsErr, this.stats); } - logger.verbose('Reading API description files.'); + logger.debug('Reading API description files.'); this.loadFiles((loadErr) => { if (loadErr) { return callback(loadErr, this.stats); } - logger.verbose('Parsing API description files and compiling a list of HTTP transactions to test.'); + logger.debug('Parsing API description files and compiling a list of HTTP transactions to test.'); this.compileTransactions((compileErr) => { if (compileErr) { return callback(compileErr, this.stats); } - logger.verbose('Starting reporters and waiting until all of them are ready.'); + logger.debug('Starting reporters and waiting until all of them are ready.'); this.emitStart((emitStartErr) => { if (emitStartErr) { return callback(emitStartErr, this.stats); } - logger.verbose('Starting transaction runner.'); + logger.debug('Starting transaction runner.'); this.startRunner((runnerErr) => { if (runnerErr) { return callback(runnerErr, this.stats); } - logger.verbose('Wrapping up testing.'); + logger.debug('Wrapping up testing.'); this.transactionsComplete(callback); }); }); @@ -196,7 +196,7 @@ API description document (or documents) not found on path: async.eachLimit(this.configuration.files, 6, (fileUrlOrPath, loadCallback) => { const { protocol, host } = url.parse(fileUrlOrPath); if (host && ['http:', 'https:'].includes(protocol)) { - logger.verbose('Downloading remote file:', fileUrlOrPath); + logger.debug('Downloading remote file:', fileUrlOrPath); this.downloadFile(fileUrlOrPath, loadCallback); } else { this.readLocalFile(fileUrlOrPath, loadCallback); @@ -255,7 +255,7 @@ Is the provided path correct? const fileData = this.configuration.data[filename]; if (!fileData.annotations) { fileData.annotations = []; } - logger.verbose('Compiling HTTP transactions from API description file:', filename); + logger.debug('Compiling HTTP transactions from API description file:', filename); dreddTransactions.compile(fileData.raw, filename, (compilationError, compilationResult) => { if (compilationError) { return next(compilationError); } diff --git a/lib/HooksWorkerClient.js b/lib/HooksWorkerClient.js index efedea836..693987a7c 100644 --- a/lib/HooksWorkerClient.js +++ b/lib/HooksWorkerClient.js @@ -29,19 +29,19 @@ class HooksWorkerClient { } start(callback) { - logger.verbose('Looking up hooks handler implementation:', this.language); + logger.debug('Looking up hooks handler implementation:', this.language); this.setCommandAndCheckForExecutables((executablesError) => { if (executablesError) { return callback(executablesError); } - logger.verbose('Starting hooks handler.'); + logger.debug('Starting hooks handler.'); this.spawnHandler((spawnHandlerError) => { if (spawnHandlerError) { return callback(spawnHandlerError); } - logger.verbose('Connecting to hooks handler.'); + logger.debug('Connecting to hooks handler.'); this.connectToHandler((connectHandlerError) => { if (connectHandlerError) { return callback(connectHandlerError); } - logger.verbose('Registering hooks.'); + logger.debug('Registering hooks.'); this.registerHooks((registerHooksError) => { if (registerHooksError) { return callback(registerHooksError); } callback(); @@ -57,7 +57,7 @@ class HooksWorkerClient { } terminateHandler(callback) { - logger.verbose('Terminating hooks handler process, PID', this.handler.pid); + logger.debug('Terminating hooks handler process, PID', this.handler.pid); if (this.handler.terminated) { logger.debug('The hooks handler process has already terminated'); return callback(); @@ -169,7 +169,7 @@ $ go get github.com/snikch/goodman/cmd/goodman this.handlerCommand = parsedArgs.shift(); this.handlerCommandArgs = parsedArgs; - logger.verbose(`Using '${this.handlerCommand}' as a hook handler command, '${this.handlerCommandArgs.join(' ')}' as arguments`); + logger.debug(`Using '${this.handlerCommand}' as a hook handler command, '${this.handlerCommandArgs.join(' ')}' as arguments`); if (!which.which(this.handlerCommand)) { msg = `Hooks handler command not found: ${this.handlerCommand}`; callback(new Error(msg)); @@ -183,14 +183,14 @@ $ go get github.com/snikch/goodman/cmd/goodman const pathGlobs = [].concat(this.runner.hooks.configuration.options.hookfiles); const handlerCommandArgs = this.handlerCommandArgs.concat(pathGlobs); - logger.info(`Spawning '${this.language}' hooks handler process.`); + logger.debug(`Spawning '${this.language}' hooks handler process.`); this.handler = spawn(this.handlerCommand, handlerCommandArgs); - this.handler.stdout.on('data', data => logger.info('Hooks handler stdout:', data.toString())); - this.handler.stderr.on('data', data => logger.info('Hooks handler stderr:', data.toString())); + this.handler.stdout.on('data', data => logger.debug('Hooks handler stdout:', data.toString())); + this.handler.stderr.on('data', data => logger.debug('Hooks handler stderr:', data.toString())); - this.handler.on('signalTerm', () => logger.verbose('Gracefully terminating the hooks handler process')); - this.handler.on('signalKill', () => logger.verbose('Killing the hooks handler process')); + this.handler.on('signalTerm', () => logger.debug('Gracefully terminating the hooks handler process')); + this.handler.on('signalKill', () => logger.debug('Killing the hooks handler process')); this.handler.on('crash', (exitStatus, killed) => { let msg; @@ -236,7 +236,7 @@ $ go get github.com/snikch/goodman/cmd/goodman }; const connectAndSetupClient = () => { - logger.verbose('Starting TCP connection with hooks handler process.'); + logger.debug('Starting TCP connection with hooks handler process.'); if (this.runner.hookHandlerError) { callback(this.runner.hookHandlerError); @@ -245,7 +245,7 @@ $ go get github.com/snikch/goodman/cmd/goodman this.handlerClient = net.connect({ port: this.handlerPort, host: this.handlerHost }); this.handlerClient.on('connect', () => { - logger.info(`Successfully connected to hooks handler. Waiting ${this.afterConnectWait / 1000}s to start testing.`); + logger.debug(`Successfully connected to hooks handler. Waiting ${this.afterConnectWait / 1000}s to start testing.`); this.clientConnected = true; clearTimeout(timeout); setTimeout(callback, this.afterConnectWait); @@ -278,10 +278,10 @@ $ go get github.com/snikch/goodman/cmd/goodman const result = []; for (const message of messages) { if (message.uuid) { - logger.verbose('Dredd received a valid message from hooks handler:', message.uuid); + logger.debug('Dredd received a valid message from hooks handler:', message.uuid); result.push(this.emitter.emit(message.uuid, message)); } else { - result.push(logger.verbose('UUID not present in hooks handler message, ignoring:', JSON.stringify(message, null, 2))); + result.push(logger.debug('UUID not present in hooks handler message, ignoring:', JSON.stringify(message, null, 2))); } } return result; @@ -312,14 +312,14 @@ $ go get github.com/snikch/goodman/cmd/goodman data, }; - logger.verbose('Sending HTTP transaction data to hooks handler:', uuid); + logger.debug('Sending HTTP transaction data to hooks handler:', uuid); this.handlerClient.write(JSON.stringify(message)); this.handlerClient.write(this.handlerMessageDelimiter); // Register event for the sent transaction function messageHandler(receivedMessage) { let value; - logger.verbose('Handling hook:', uuid); + logger.debug('Handling hook:', uuid); clearTimeout(timeout); // We are directly modifying the `data` argument here. Neither direct diff --git a/lib/TransactionRunner.js b/lib/TransactionRunner.js index fac47f174..eda5306b1 100644 --- a/lib/TransactionRunner.js +++ b/lib/TransactionRunner.js @@ -7,6 +7,7 @@ const url = require('url'); const addHooks = require('./addHooks'); const logger = require('./logger'); +const reporterOutputLogger = require('./reporters/reporterOutputLogger'); const packageData = require('../package.json'); const sortTransactions = require('./sortTransactions'); const performRequest = require('./performRequest'); @@ -41,18 +42,18 @@ class TransactionRunner { } run(transactions, callback) { - logger.verbose('Sorting HTTP transactions'); + logger.debug('Sorting HTTP transactions'); transactions = this.configuration.options.sorted ? sortTransactions(transactions) : transactions; - logger.verbose('Configuring HTTP transactions'); + logger.debug('Configuring HTTP transactions'); transactions = transactions.map(this.configureTransaction.bind(this)); // Remainings of functional approach, probs to be eradicated - logger.verbose('Reading hook files and registering hooks'); + logger.debug('Reading hook files and registering hooks'); addHooks(this, transactions, (addHooksError) => { if (addHooksError) { return callback(addHooksError); } - logger.verbose('Executing HTTP transactions'); + logger.debug('Executing HTTP transactions'); this.executeAllTransactions(transactions, this.hooks, callback); }); } @@ -74,7 +75,7 @@ class TransactionRunner { if (this.hookHandlerError) { return callback(this.hookHandlerError); } - logger.verbose('Running \'beforeAll\' hooks'); + logger.debug('Running \'beforeAll\' hooks'); this.runHooksForData(hooks.beforeAllHooks, transactions, () => { if (this.hookHandlerError) { return callback(this.hookHandlerError); } @@ -84,13 +85,13 @@ class TransactionRunner { // we need to work with indexes (keys) here, no other way of access. return async.timesSeries(transactions.length, (transactionIndex, iterationCallback) => { transaction = transactions[transactionIndex]; - logger.verbose(`Processing transaction #${transactionIndex + 1}:`, transaction.name); + logger.debug(`Processing transaction #${transactionIndex + 1}:`, transaction.name); - logger.verbose('Running \'beforeEach\' hooks'); + logger.debug('Running \'beforeEach\' hooks'); this.runHooksForData(hooks.beforeEachHooks, transaction, () => { if (this.hookHandlerError) { return iterationCallback(this.hookHandlerError); } - logger.verbose('Running \'before\' hooks'); + logger.debug('Running \'before\' hooks'); this.runHooksForData(hooks.beforeHooks[transaction.name], transaction, () => { if (this.hookHandlerError) { return iterationCallback(this.hookHandlerError); } @@ -104,11 +105,11 @@ class TransactionRunner { this.executeTransaction(transaction, hooks, () => { if (this.hookHandlerError) { return iterationCallback(this.hookHandlerError); } - logger.verbose('Running \'afterEach\' hooks'); + logger.debug('Running \'afterEach\' hooks'); this.runHooksForData(hooks.afterEachHooks, transaction, () => { if (this.hookHandlerError) { return iterationCallback(this.hookHandlerError); } - logger.verbose('Running \'after\' hooks'); + logger.debug('Running \'after\' hooks'); this.runHooksForData(hooks.afterHooks[transaction.name], transaction, () => { if (this.hookHandlerError) { return iterationCallback(this.hookHandlerError); } @@ -123,7 +124,7 @@ class TransactionRunner { (iterationError) => { if (iterationError) { return callback(iterationError); } - logger.verbose('Running \'afterAll\' hooks'); + logger.debug('Running \'afterAll\' hooks'); this.runHooksForData(hooks.afterAllHooks, transactions, () => { if (this.hookHandlerError) { return callback(this.hookHandlerError); } callback(); @@ -424,27 +425,27 @@ class TransactionRunner { this.ensureTransactionResultsGeneralSection(transaction); if (transaction.skip) { - logger.verbose('HTTP transaction was marked in hooks as to be skipped. Skipping'); + logger.debug('HTTP transaction was marked in hooks as to be skipped. Skipping'); transaction.test = test; this.skipTransaction(transaction, 'Skipped in before hook'); return callback(); } if (transaction.fail) { - logger.verbose('HTTP transaction was marked in hooks as to be failed. Reporting as failed'); + logger.debug('HTTP transaction was marked in hooks as to be failed. Reporting as failed'); transaction.test = test; this.failTransaction(transaction, `Failed in before hook: ${transaction.fail}`); return callback(); } if (this.configuration.options['dry-run']) { - logger.info('Dry run. Not performing HTTP request'); + reporterOutputLogger.info('Dry run. Not performing HTTP request'); transaction.test = test; this.skipTransaction(transaction); return callback(); } if (this.configuration.options.names) { - logger.info(transaction.name); + reporterOutputLogger.info(transaction.name); transaction.test = test; this.skipTransaction(transaction); return callback(); } if ((this.configuration.options.method.length > 0) && !(Array.from(this.configuration.options.method).includes(transaction.request.method))) { - logger.info(`\ + logger.debug(`\ Only ${(Array.from(this.configuration.options.method).map(m => m.toUpperCase())).join(', ')}\ requests are set to be executed. \ Not performing HTTP ${transaction.request.method.toUpperCase()} request.\ @@ -453,7 +454,7 @@ Not performing HTTP ${transaction.request.method.toUpperCase()} request.\ this.skipTransaction(transaction); return callback(); } if ((this.configuration.options.only.length > 0) && !(Array.from(this.configuration.options.only).includes(transaction.name))) { - logger.info(`\ + logger.debug(`\ Only '${this.configuration.options.only}' transaction is set to be executed. \ Not performing HTTP request for '${transaction.name}'.\ `); @@ -492,11 +493,11 @@ Not performing HTTP request for '${transaction.name}'.\ transaction.real.body = ''; } - logger.verbose('Running \'beforeEachValidation\' hooks'); + logger.debug('Running \'beforeEachValidation\' hooks'); this.runHooksForData(hooks && hooks.beforeEachValidationHooks, transaction, () => { if (this.hookHandlerError) { return callback(this.hookHandlerError); } - logger.verbose('Running \'beforeValidation\' hooks'); + logger.debug('Running \'beforeValidation\' hooks'); this.runHooksForData(hooks && hooks.beforeValidationHooks[transaction.name], transaction, () => { if (this.hookHandlerError) { return callback(this.hookHandlerError); } @@ -507,7 +508,7 @@ Not performing HTTP request for '${transaction.name}'.\ } validateTransaction(test, transaction, callback) { - logger.verbose('Validating HTTP transaction by Gavel.js'); + logger.debug('Validating HTTP transaction by Gavel.js'); logger.debug('Determining whether HTTP transaction is valid (getting boolean verdict)'); gavel.isValid(transaction.real, transaction.expected, 'response', (isValidError, isValid) => { if (isValidError) { diff --git a/lib/addHooks.js b/lib/addHooks.js index b5a5ac397..b379c26f4 100644 --- a/lib/addHooks.js +++ b/lib/addHooks.js @@ -42,7 +42,7 @@ Stack: ${error.stack} } catch (err) { return callback(err); } - logger.info('Found Hookfiles:', files); + logger.debug('Found Hookfiles:', files); // Clone the configuration object to hooks.configuration to make it // accessible in the node.js hooks API diff --git a/lib/configuration.js b/lib/configuration.js index 14e0e6002..07dcd2dc9 100644 --- a/lib/configuration.js +++ b/lib/configuration.js @@ -48,7 +48,7 @@ function applyLoggingOptions(options) { logger.transports.console.level = 'warn'; } - reporterOutputLogger.transports.console.level = 'test'; + reporterOutputLogger.transports.console.level = 'info'; return options; } diff --git a/lib/configureReporters.js b/lib/configureReporters.js index 60e548056..331284de3 100644 --- a/lib/configureReporters.js +++ b/lib/configureReporters.js @@ -29,7 +29,7 @@ function configureReporters(config, stats, tests, runner) { const reporters = config.options.reporter; const outputs = config.options.output; - logger.verbose('Configuring reporters:', reporters, outputs); + logger.debug('Configuring reporters:', reporters, outputs); function addCli(reportersArr) { if (reportersArr.length > 0) { diff --git a/lib/logger.js b/lib/logger.js index 3792d6f65..97e27005d 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -5,18 +5,12 @@ module.exports = new (winston.Logger)({ new (winston.transports.Console)({ colorize: true }), ], levels: { - debug: 5, - silly: 4, - verbose: 3, - info: 2, + debug: 2, warn: 1, error: 0, }, colors: { debug: 'cyan', - silly: 'gray', - verbose: 'magenta', - info: 'blue', warn: 'yellow', error: 'red', }, diff --git a/lib/reporters/ApiaryReporter.js b/lib/reporters/ApiaryReporter.js index 6d7c2e4c5..3803d9a0c 100644 --- a/lib/reporters/ApiaryReporter.js +++ b/lib/reporters/ApiaryReporter.js @@ -40,7 +40,7 @@ function ApiaryReporter(emitter, stats, tests, config, runner) { this.configureEmitter(emitter); - logger.verbose(`Using '${this.type}' reporter.`); + logger.debug(`Using '${this.type}' reporter.`); if (!this.configuration.apiToken && !this.configuration.apiSuite) { logger.warn(` @@ -218,7 +218,7 @@ ApiaryReporter.prototype._performRequestAsync = function _performRequestAsync(pa return callback(err); } - logger.verbose('Handling HTTP response from Apiary API'); + logger.debug('Handling HTTP response from Apiary API'); try { parsedBody = JSON.parse(resBody); @@ -257,7 +257,7 @@ ${error.message}\n${resBody} try { const protocol = options.uri.split(':')[0].toUpperCase(); - logger.verbose(` + logger.debug(` About to perform an ${protocol} request from Apiary reporter to Apiary API: ${options.method} ${options.uri} \ (${body ? 'with' : 'without'} body) diff --git a/lib/reporters/BaseReporter.js b/lib/reporters/BaseReporter.js index dca540eef..136c94a23 100644 --- a/lib/reporters/BaseReporter.js +++ b/lib/reporters/BaseReporter.js @@ -5,7 +5,7 @@ function BaseReporter(emitter, stats, tests) { this.stats = stats; this.tests = tests; this.configureEmitter(emitter); - logger.verbose(`Using '${this.type}' reporter.`); + logger.debug(`Using '${this.type}' reporter.`); } BaseReporter.prototype.configureEmitter = function configureEmitter(emitter) { diff --git a/lib/reporters/CLIReporter.js b/lib/reporters/CLIReporter.js index 517a90a61..039c7ddd7 100644 --- a/lib/reporters/CLIReporter.js +++ b/lib/reporters/CLIReporter.js @@ -24,19 +24,19 @@ function CLIReporter(emitter, stats, tests, inlineErrors, details) { this.configureEmitter(emitter); - logger.verbose(`Using '${this.type}' reporter.`); + logger.debug(`Using '${this.type}' reporter.`); } CLIReporter.prototype.configureEmitter = function configureEmitter(emitter) { emitter.on('start', (rawBlueprint, callback) => { - logger.info('Beginning Dredd testing...'); + logger.debug('Beginning Dredd testing...'); callback(); }); emitter.on('end', (callback) => { if (!this.inlineErrors) { if (this.errors.length) { - logger.info('Displaying failed tests...'); + reporterOutputLogger.info('Displaying failed tests...'); } this.errors.forEach((test) => { reporterOutputLogger.fail(`${test.title} duration: ${test.duration}ms`); diff --git a/lib/reporters/DotReporter.js b/lib/reporters/DotReporter.js index 9d00289ff..9949e3561 100644 --- a/lib/reporters/DotReporter.js +++ b/lib/reporters/DotReporter.js @@ -10,12 +10,12 @@ function DotReporter(emitter, stats, tests) { this.configureEmitter(emitter); - logger.verbose(`Using '${this.type}' reporter.`); + logger.debug(`Using '${this.type}' reporter.`); } DotReporter.prototype.configureEmitter = function configureEmitter(emitter) { emitter.on('start', (rawBlueprint, callback) => { - logger.info('Beginning Dredd testing...'); + logger.debug('Beginning Dredd testing...'); callback(); }); @@ -23,7 +23,7 @@ DotReporter.prototype.configureEmitter = function configureEmitter(emitter) { if (this.stats.tests > 0) { if (this.errors.length > 0) { this.write('\n'); - logger.info('Displaying failed tests...'); + reporterOutputLogger.info('Displaying failed tests...'); for (const test of this.errors) { reporterOutputLogger.fail(`${test.title} duration: ${test.duration}ms`); reporterOutputLogger.fail(test.message); diff --git a/lib/reporters/HTMLReporter.js b/lib/reporters/HTMLReporter.js index 9f80bd7ac..5d1cb4313 100644 --- a/lib/reporters/HTMLReporter.js +++ b/lib/reporters/HTMLReporter.js @@ -24,7 +24,7 @@ function HTMLReporter(emitter, stats, tests, path, details) { this.configureEmitter(emitter); - logger.verbose(`Using '${this.type}' reporter.`); + logger.debug(`Using '${this.type}' reporter.`); } HTMLReporter.prototype.sanitizedPath = function sanitizedPath(path = './report.html') { diff --git a/lib/reporters/MarkdownReporter.js b/lib/reporters/MarkdownReporter.js index d7bab1514..3b54d43c2 100644 --- a/lib/reporters/MarkdownReporter.js +++ b/lib/reporters/MarkdownReporter.js @@ -23,7 +23,7 @@ function MarkdownReporter(emitter, stats, tests, path, details) { this.configureEmitter(emitter); - logger.verbose(`Using '${this.type}' reporter.`); + logger.debug(`Using '${this.type}' reporter.`); } MarkdownReporter.prototype.sanitizedPath = function sanitizedPath(path = './report.md') { diff --git a/lib/reporters/NyanReporter.js b/lib/reporters/NyanReporter.js index 5f0f099f6..332e89604 100644 --- a/lib/reporters/NyanReporter.js +++ b/lib/reporters/NyanReporter.js @@ -34,7 +34,7 @@ function NyanCatReporter(emitter, stats, tests) { this.configureEmitter(emitter); - logger.verbose(`Using '${this.type}' reporter.`); + logger.debug(`Using '${this.type}' reporter.`); } NyanCatReporter.prototype.configureEmitter = function configureEmitter(emitter) { @@ -55,7 +55,7 @@ NyanCatReporter.prototype.configureEmitter = function configureEmitter(emitter) if (this.errors.length > 0) { this.write('\n'); - logger.info('Displaying failed tests...'); + reporterOutputLogger.info('Displaying failed tests...'); for (const test of this.errors) { reporterOutputLogger.fail(`${test.title} duration: ${test.duration}ms`); reporterOutputLogger.fail(test.message); diff --git a/lib/reporters/XUnitReporter.js b/lib/reporters/XUnitReporter.js index b5db268fe..5c262af58 100644 --- a/lib/reporters/XUnitReporter.js +++ b/lib/reporters/XUnitReporter.js @@ -22,7 +22,7 @@ function XUnitReporter(emitter, stats, tests, path, details) { this.configureEmitter(emitter); - logger.verbose(`Using '${this.type}' reporter.`); + logger.debug(`Using '${this.type}' reporter.`); } XUnitReporter.prototype.updateSuiteStats = function updateSuiteStats(path, stats, callback) { diff --git a/lib/reporters/reporterOutputLogger.js b/lib/reporters/reporterOutputLogger.js index 5722bb50f..0cd806d75 100644 --- a/lib/reporters/reporterOutputLogger.js +++ b/lib/reporters/reporterOutputLogger.js @@ -5,6 +5,7 @@ module.exports = new (winston.Logger)({ new (winston.transports.Console)({ colorize: true }), ], levels: { + info: 10, test: 9, pass: 8, fail: 7, @@ -17,6 +18,7 @@ module.exports = new (winston.Logger)({ error: 0, }, colors: { + info: 'blue', test: 'yellow', pass: 'green', fail: 'red', diff --git a/test/integration/cli/configuration-cli-test.js b/test/integration/cli/configuration-cli-test.js index 760028895..72022e01a 100644 --- a/test/integration/cli/configuration-cli-test.js +++ b/test/integration/cli/configuration-cli-test.js @@ -12,7 +12,6 @@ const PORT = 9876; let exitStatus; let stderr = ''; -let stdout = ''; const addHooksStub = proxyquire('../../../lib/addHooks', { './logger': loggerStub, @@ -36,7 +35,6 @@ const CLIStub = proxyquire('../../../lib/CLI', { }); function execCommand(custom = {}, cb) { - stdout = ''; stderr = ''; exitStatus = null; let finished = false; @@ -44,7 +42,7 @@ function execCommand(custom = {}, cb) { if (!finished) { finished = true; exitStatus = (exitStatusCode != null ? exitStatusCode : 0); - cb(null, stdout, stderr, (exitStatusCode != null ? exitStatusCode : 0)); + cb(); } })); @@ -53,20 +51,15 @@ function execCommand(custom = {}, cb) { describe('CLI class Integration', () => { before(() => { - ['warn', 'error'].forEach((method) => { + ['warn', 'error', 'debug'].forEach((method) => { sinon .stub(loggerStub, method) .callsFake((chunk) => { stderr += `\n${method}: ${chunk}`; }); }); - ['log', 'info', 'silly', 'verbose', 'debug'].forEach((method) => { - sinon - .stub(loggerStub, method) - .callsFake((chunk) => { stdout += `\n${method}: ${chunk}`; }); - }); }); after(() => { - ['warn', 'error', 'log', 'info', 'silly', 'verbose', 'debug'].forEach((method) => { + ['warn', 'error', 'debug'].forEach((method) => { loggerStub[method].restore(); }); }); @@ -74,7 +67,7 @@ describe('CLI class Integration', () => { describe('When using configuration file', () => { describe('When specifying custom configuration file by --config', () => { const configPath = '../../../custom-dredd-config-path.yaml'; - const cmd = { argv: ['--config', configPath] }; + const cmd = { argv: ['--config', configPath, '--loglevel=debug'] }; const options = { _: ['api-description.apib', 'http://127.0.0.1'] }; let fsExistsSync; @@ -92,12 +85,12 @@ describe('CLI class Integration', () => { it('should call fs.existsSync with given path', () => assert.isTrue(fsExistsSync.calledWith(configPath))); it('should call configUtils.load with given path', () => assert.isTrue(configUtilsLoad.calledWith(configPath))); - it('should print message about using given configuration file', () => assert.include(stdout, `info: Configuration '${configPath}' found`)); + it('should print message about using given configuration file', () => assert.include(stderr, `debug: Configuration '${configPath}' found`)); }); describe('When dredd.yml exists', () => { const configPath = './dredd.yml'; - const cmd = { argv: [] }; + const cmd = { argv: ['--loglevel=debug'] }; const options = { _: ['api-description.apib', 'http://127.0.0.1'] }; let fsExistsSync; @@ -115,12 +108,12 @@ describe('CLI class Integration', () => { it('should call fs.existsSync with dredd.yml', () => assert.isTrue(fsExistsSync.calledWith(configPath))); it('should call configUtils.load with dredd.yml', () => assert.isTrue(configUtilsLoad.calledWith(configPath))); - it('should print message about using dredd.yml', () => assert.include(stdout, `info: Configuration '${configPath}' found`)); + it('should print message about using dredd.yml', () => assert.include(stderr, `debug: Configuration '${configPath}' found`)); }); describe('When dredd.yml does not exist', () => { const configPath = './dredd.yml'; - const cmd = { argv: [] }; + const cmd = { argv: ['--loglevel=debug'] }; let fsExistsSync; let configUtilsLoad; @@ -137,7 +130,7 @@ describe('CLI class Integration', () => { it('should call fs.existsSync with dredd.yml', () => assert.isTrue(fsExistsSync.calledWith(configPath))); it('should never call configUtils.load', () => assert.isFalse(configUtilsLoad.called)); - it('should not print message about using configuration file', () => assert.notInclude(stdout, 'info: Configuration')); + it('should not print message about using configuration file', () => assert.notInclude(stderr, 'debug: Configuration')); }); }); @@ -187,7 +180,7 @@ describe('CLI class Integration', () => { })); describe('and I try to load a file from bad hostname at all', () => { - before(done => execCommand(errorCmd, () => done())); + before(done => execCommand(errorCmd, done)); it('should exit with status 1', () => assert.equal(exitStatus, 1)); @@ -199,7 +192,7 @@ describe('CLI class Integration', () => { }); describe('and I try to load a file that does not exist from an existing server', () => { - before(done => execCommand(wrongCmd, () => done())); + before(done => execCommand(wrongCmd, done)); it('should exit with status 1', () => assert.equal(exitStatus, 1)); @@ -211,7 +204,7 @@ describe('CLI class Integration', () => { }); describe('and I try to load a file that actually is there', () => { - before(done => execCommand(goodCmd, () => done())); + before(done => execCommand(goodCmd, done)); it('should exit with status 0', () => assert.equal(exitStatus, 0)); }); diff --git a/test/integration/cli/hookfiles-cli-test.js b/test/integration/cli/hookfiles-cli-test.js index 2e469c3a5..4126357e6 100644 --- a/test/integration/cli/hookfiles-cli-test.js +++ b/test/integration/cli/hookfiles-cli-test.js @@ -552,8 +552,8 @@ describe('CLI', () => { }); }); - it('should not display anything', () => { - assert.notInclude(runtimeInfo.dredd.output, 'info:'); + it('should not display any debug logging', () => { + assert.notInclude(runtimeInfo.dredd.output, 'debug:'); }); }); diff --git a/test/integration/cli/server-process-cli-test.js b/test/integration/cli/server-process-cli-test.js index 3fa444495..f9eba709c 100644 --- a/test/integration/cli/server-process-cli-test.js +++ b/test/integration/cli/server-process-cli-test.js @@ -77,7 +77,7 @@ describe('CLI - Server Process', () => { done(err); })); - it('should inform about starting server with custom command', () => assert.include(cliInfo.stdout, 'Starting backend server process with command')); + it('should inform about starting server with custom command', () => assert.include(cliInfo.stderr, 'Starting backend server process with command')); it('should redirect server\'s welcome message', () => assert.include(cliInfo.stdout, `Dummy server listening on port ${DEFAULT_SERVER_PORT}`)); it('should exit with status 0', () => assert.equal(cliInfo.exitStatus, 0)); }); @@ -97,7 +97,7 @@ describe('CLI - Server Process', () => { done(err); })); - it('should inform about starting server with custom command', () => assert.include(cliInfo.stdout, 'Starting backend server process with command')); + it('should inform about starting server with custom command', () => assert.include(cliInfo.stderr, 'Starting backend server process with command')); it('should report problem with server process spawn', () => assert.include(cliInfo.stderr, 'Command to start backend server process failed, exiting Dredd')); it('should exit with status 1', () => assert.equal(cliInfo.exitStatus, 1)); }); @@ -142,7 +142,7 @@ describe('CLI - Server Process', () => { done(err); })); - it('should inform about starting server with custom command', () => assert.include(cliInfo.stdout, 'Starting backend server process with command')); + it('should inform about starting server with custom command', () => assert.include(cliInfo.stderr, 'Starting backend server process with command')); if (scenario.expectServerBoot) { it('should redirect server\'s boot message', () => assert.include(cliInfo.stdout, `Dummy server listening on port ${DEFAULT_SERVER_PORT}`)); } @@ -170,7 +170,7 @@ describe('CLI - Server Process', () => { done(err); })); - it('should inform about starting server with custom command', () => assert.include(cliInfo.stdout, 'Starting backend server process with command')); + it('should inform about starting server with custom command', () => assert.include(cliInfo.stderr, 'Starting backend server process with command')); it('should inform about gracefully terminating the server', () => assert.include(cliInfo.stdout, 'Gracefully terminating the backend server process')); it('should redirect server\'s message about ignoring termination', () => assert.include(cliInfo.stdout, 'ignoring termination')); it('should inform about forcefully killing the server', () => assert.include(cliInfo.stdout, 'Killing the backend server process')); diff --git a/test/integration/dredd-test.js b/test/integration/dredd-test.js index 938431975..691e2b30c 100644 --- a/test/integration/dredd-test.js +++ b/test/integration/dredd-test.js @@ -98,7 +98,7 @@ describe('Dredd class Integration', () => { }); - describe("when using reporter -r apiary with 'verbose' logging with custom apiaryApiKey and apiaryApiName", () => { + describe("when using reporter -r apiary with 'debug' logging with custom apiaryApiKey and apiaryApiName", () => { let server; let server2; let receivedRequest; diff --git a/test/unit/CLI-test.js b/test/unit/CLI-test.js index 4e7a7fda2..75e479831 100644 --- a/test/unit/CLI-test.js +++ b/test/unit/CLI-test.js @@ -56,27 +56,25 @@ function execCommand(custom = {}, cb) { if (!finished) { finished = true; exitStatus = code || 0; - return cb(null, stdout, stderr, (code != null ? code : 0)); + return cb(); } })).run()); } describe('CLI class', () => { before(() => { - ['warn', 'error'].forEach((method) => { + ['warn', 'error', 'debug'].forEach((method) => { sinon .stub(loggerStub, method) .callsFake((chunk) => { stderr += `\n${method}: ${chunk}`; }); }); - ['log', 'info', 'silly', 'verbose', 'debug'].forEach((method) => { - sinon - .stub(loggerStub, method) - .callsFake((chunk) => { stdout += `\n${method}: ${chunk}`; }); - }); + sinon + .stub(loggerStub, 'log') + .callsFake((chunk) => { stdout += chunk; }); }); after(() => { - ['warn', 'error', 'log', 'info', 'silly', 'verbose', 'debug'].forEach((method) => { + ['warn', 'error', 'debug', 'log'].forEach((method) => { loggerStub[method].restore(); }); }); @@ -247,7 +245,7 @@ describe('CLI class', () => { describe('when called w/ OR wo/ exiting arguments', () => { describe('--help', () => { - before(done => execCommand({ argv: ['--help'] }, () => done())); + before(done => execCommand({ argv: ['--help'] }, done)); it('prints out some really nice help text with all options descriptions', () => { assert.include(stderr, 'Usage:'); @@ -258,15 +256,17 @@ describe('CLI class', () => { }); describe('--version', () => { - before(done => execCommand({ argv: ['--version'] }, () => done())); + before(done => execCommand({ argv: ['--version'] }, done)); - it('prints out version', () => assert.include(stdout, `${packageData.name} v${packageData.version}`)); + it('prints out version', () => { + assert.include(stdout, `${packageData.name} v${packageData.version}`); + }); }); describe('init', () => { before((done) => { sinon.stub(configUtilsStub, 'save'); - execCommand({ argv: ['init'] }, () => done()); + execCommand({ argv: ['init'] }, done); }); after(() => { @@ -278,7 +278,7 @@ describe('CLI class', () => { }); describe('without argv', () => { - before(done => execCommand({ argv: [] }, () => done())); + before(done => execCommand({ argv: [] }, done)); it('prints out an error message', () => assert.include(stderr, 'Error: Must specify')); }); @@ -332,7 +332,7 @@ describe('CLI class', () => { $0: 'node ./bin/dredd', })); - execCommand({ argv: ['--names'] }, () => done()); + execCommand({ argv: ['--names'] }, done); }); after(() => { @@ -367,7 +367,7 @@ describe('CLI class', () => { '--server', 'foo/bar', ], - }, () => done()); + }, done); }); afterEach(() => crossSpawnStub.spawn.restore()); diff --git a/test/unit/Dredd-test.js b/test/unit/Dredd-test.js index c782958dc..bb063d3be 100644 --- a/test/unit/Dredd-test.js +++ b/test/unit/Dredd-test.js @@ -664,10 +664,10 @@ GET /url }); describe('#logProxySettings', () => { - let verboseLogger; + let debugLogger; - beforeEach(() => { verboseLogger = sinon.spy(loggerStub, 'verbose'); }); - afterEach(() => loggerStub.verbose.restore()); + beforeEach(() => { debugLogger = sinon.spy(loggerStub, 'debug'); }); + afterEach(() => loggerStub.debug.restore()); describe('when the proxy is set by lowercase environment variable', () => { beforeEach(() => { @@ -676,7 +676,7 @@ GET /url }); afterEach(() => delete process.env.http_proxy); - it('logs about the setting', () => assert.include(verboseLogger.lastCall.args[0], + it('logs about the setting', () => assert.include(debugLogger.lastCall.args[0], 'HTTP(S) proxy specified by environment variables: http_proxy=http://proxy.example.com')); }); @@ -687,7 +687,7 @@ GET /url }); afterEach(() => delete process.env.HTTPS_PROXY); - it('logs about the setting', () => assert.include(verboseLogger.lastCall.args[0], + it('logs about the setting', () => assert.include(debugLogger.lastCall.args[0], 'HTTP(S) proxy specified by environment variables: ' + 'HTTPS_PROXY=http://proxy.example.com')); }); @@ -703,7 +703,7 @@ GET /url delete process.env.NO_PROXY; }); - it('logs about the setting', () => assert.include(verboseLogger.lastCall.args[0], + it('logs about the setting', () => assert.include(debugLogger.lastCall.args[0], 'HTTP(S) proxy specified by environment variables: ' + 'HTTPS_PROXY=http://proxy.example.com, ' + 'NO_PROXY=whitelisted.example.com')); @@ -720,7 +720,7 @@ GET /url delete process.env.NO_PROXY; }); - it('is ignored', () => assert.include(verboseLogger.lastCall.args[0], + it('is ignored', () => assert.include(debugLogger.lastCall.args[0], 'HTTP(S) proxy specified by environment variables: ' + 'NO_PROXY=whitelisted.example.com')); }); diff --git a/test/unit/HooksWorkerClient-test.js b/test/unit/HooksWorkerClient-test.js index fafc8ad98..f56057d6b 100644 --- a/test/unit/HooksWorkerClient-test.js +++ b/test/unit/HooksWorkerClient-test.js @@ -25,7 +25,7 @@ const MIN_COMMAND_EXECUTION_DURATION_MS = 2 * measureExecutionDurationMs(() => c const PORT = 61321; let runner; -const logLevels = ['error', 'log', 'info', 'warn']; +const logLevels = ['error', 'warn', 'debug']; const HooksWorkerClient = proxyquire('../../lib/HooksWorkerClient', { 'cross-spawn': crossSpawnStub, diff --git a/test/unit/reporters/ApiaryReporter-test.js b/test/unit/reporters/ApiaryReporter-test.js index e7204dab0..78a10eec3 100644 --- a/test/unit/reporters/ApiaryReporter-test.js +++ b/test/unit/reporters/ApiaryReporter-test.js @@ -20,12 +20,12 @@ nock.enableNetConnect(); describe('ApiaryReporter', () => { let env = {}; beforeEach(() => { - sinon.stub(loggerStub, 'verbose'); + sinon.stub(loggerStub, 'debug'); sinon.stub(reporterOutputLoggerStub, 'complete'); }); afterEach(() => { - sinon.stub(loggerStub.verbose.restore()); + sinon.stub(loggerStub.debug.restore()); sinon.stub(reporterOutputLoggerStub.complete.restore()); }); @@ -199,7 +199,7 @@ describe('ApiaryReporter', () => { emitter = new EventEmitter(); const apiaryReporter = new ApiaryReporter(emitter, {}, {}, { custom }); apiaryReporter._performRequestAsync('/', 'POST', '', () => { - assert.isOk(loggerStub.verbose.calledWithMatch('POST https://api.example.com:1234/ (without body)')); + assert.isOk(loggerStub.debug.calledWithMatch('POST https://api.example.com:1234/ (without body)')); done(); }); }); @@ -215,7 +215,7 @@ describe('ApiaryReporter', () => { emitter = new EventEmitter(); const apiaryReporter = new ApiaryReporter(emitter, {}, {}, { custom }); apiaryReporter._performRequestAsync('/', 'POST', '', () => { - assert.isOk(loggerStub.verbose.calledWithMatch('POST https://api.example.com:1234/ (without body)')); + assert.isOk(loggerStub.debug.calledWithMatch('POST https://api.example.com:1234/ (without body)')); done(); }); })); @@ -224,7 +224,7 @@ describe('ApiaryReporter', () => { emitter = new EventEmitter(); const apiaryReporter = new ApiaryReporter(emitter, {}, {}, { custom }); apiaryReporter._performRequestAsync('/hello?q=1', 'POST', '', () => { - assert.isOk(loggerStub.verbose.calledWithMatch('POST https://api.example.com:1234/hello?q=1 (without body)')); + assert.isOk(loggerStub.debug.calledWithMatch('POST https://api.example.com:1234/hello?q=1 (without body)')); done(); }); })); diff --git a/test/unit/reporters/CLIReporter-test.js b/test/unit/reporters/CLIReporter-test.js index fef1c8ddc..8c253c747 100644 --- a/test/unit/reporters/CLIReporter-test.js +++ b/test/unit/reporters/CLIReporter-test.js @@ -25,15 +25,16 @@ describe('CLIReporter', () => { }); describe('when starting', () => { - beforeEach(() => sinon.spy(loggerStub, 'info')); + beforeEach(() => sinon.spy(loggerStub, 'debug')); - afterEach(() => loggerStub.info.restore()); + afterEach(() => loggerStub.debug.restore()); it('should write starting to the console', (done) => { const emitter = new EventEmitter(); (new CLIReporter(emitter, {}, {}, true)); + loggerStub.debug.resetHistory(); emitter.emit('start', '', () => { - assert.isOk(loggerStub.info.calledOnce); + assert.isOk(loggerStub.debug.calledOnce); done(); }); }); diff --git a/test/unit/reporters/DotReporter-test.js b/test/unit/reporters/DotReporter-test.js index d90acb418..0a46ce458 100644 --- a/test/unit/reporters/DotReporter-test.js +++ b/test/unit/reporters/DotReporter-test.js @@ -39,11 +39,11 @@ describe('DotReporter', () => { }); describe('when starting', () => { - beforeEach(() => sinon.spy(loggerStub, 'info')); + beforeEach(() => sinon.spy(loggerStub, 'debug')); - afterEach(() => loggerStub.info.restore()); + afterEach(() => loggerStub.debug.restore()); - it('should log that testing has begun', () => emitter.emit('start', '', () => assert.isOk(loggerStub.info.called))); + it('should log that testing has begun', () => emitter.emit('start', '', () => assert.isOk(loggerStub.debug.called))); }); describe('when ending', () => { diff --git a/test/unit/transactionRunner-test.js b/test/unit/transactionRunner-test.js index 928162590..02f975198 100644 --- a/test/unit/transactionRunner-test.js +++ b/test/unit/transactionRunner-test.js @@ -409,18 +409,18 @@ describe('TransactionRunner', () => { describe('when printing the names', () => { beforeEach(() => { - sinon.spy(loggerStub, 'info'); + sinon.spy(loggerStub, 'debug'); configuration.options.names = true; runner = new Runner(configuration); }); afterEach(() => { - loggerStub.info.restore(); + loggerStub.debug.restore(); configuration.options.names = false; }); it('should print the names and return', done => runner.executeTransaction(transaction, () => { - assert.isOk(loggerStub.info.called); + assert.isOk(loggerStub.debug.called); done(); })); }); @@ -1268,75 +1268,75 @@ describe('TransactionRunner', () => { describe('with hooks', () => { beforeEach(() => { - sinon.spy(loggerStub, 'info'); + sinon.spy(loggerStub, 'debug'); runner.hooks.beforeHooks = { 'Group Machine > Machine > Delete Message > Bogus example name': [ // eslint-disable-next-line - transaction => loggerStub.info('before') + transaction => loggerStub.debug('before') ], }; runner.hooks.beforeValidationHooks = { 'Group Machine > Machine > Delete Message > Bogus example name': [ // eslint-disable-next-line - transaction => loggerStub.info('beforeValidation') + transaction => loggerStub.debug('beforeValidation') ], }; runner.hooks.afterHooks = { 'Group Machine > Machine > Delete Message > Bogus example name': [ // eslint-disable-next-line function (transaction, done) { - loggerStub.info('after'); + loggerStub.debug('after'); done(); }, ], }; }); - afterEach(() => loggerStub.info.restore()); + afterEach(() => loggerStub.debug.restore()); it('should run the hooks', done => runner.executeAllTransactions([transaction], runner.hooks, () => { - assert.isOk(loggerStub.info.calledWith('before')); - assert.isOk(loggerStub.info.calledWith('beforeValidation')); - assert.isOk(loggerStub.info.calledWith('after')); + assert.isOk(loggerStub.debug.calledWith('before')); + assert.isOk(loggerStub.debug.calledWith('beforeValidation')); + assert.isOk(loggerStub.debug.calledWith('after')); done(); })); }); describe('with hooks, but without hooks.transactions set', () => { beforeEach(() => { - sinon.spy(loggerStub, 'info'); + sinon.spy(loggerStub, 'debug'); runner.hooks.transactions = null; runner.hooks.beforeHooks = { 'Group Machine > Machine > Delete Message > Bogus example name': [ // eslint-disable-next-line - transaction => loggerStub.info('before') + transaction => loggerStub.debug('before') ], }; runner.hooks.beforeValidationHooks = { 'Group Machine > Machine > Delete Message > Bogus example name': [ // eslint-disable-next-line - transaction => loggerStub.info('beforeValidation') + transaction => loggerStub.debug('beforeValidation') ], }; runner.hooks.afterHooks = { 'Group Machine > Machine > Delete Message > Bogus example name': [ // eslint-disable-next-line function (transaction, done) { - loggerStub.info('after'); + loggerStub.debug('after'); done(); }, ], }; }); - afterEach(() => loggerStub.info.restore()); + afterEach(() => loggerStub.debug.restore()); it('should run the hooks', (done) => { runner.hooks.transactions = null; runner.executeAllTransactions([transaction], runner.hooks, () => { - assert.isOk(loggerStub.info.calledWith('before')); - assert.isOk(loggerStub.info.calledWith('beforeValidation')); - assert.isOk(loggerStub.info.calledWith('after')); + assert.isOk(loggerStub.debug.calledWith('before')); + assert.isOk(loggerStub.debug.calledWith('beforeValidation')); + assert.isOk(loggerStub.debug.calledWith('after')); done(); }); }); @@ -1344,25 +1344,25 @@ describe('TransactionRunner', () => { describe('with multiple hooks for the same transaction', () => { beforeEach(() => { - sinon.spy(loggerStub, 'info'); + sinon.spy(loggerStub, 'debug'); runner.hooks.beforeHooks = { 'Group Machine > Machine > Delete Message > Bogus example name': [ // eslint-disable-next-line - transaction => loggerStub.info('first'), + transaction => loggerStub.debug('first'), // eslint-disable-next-line function (transaction, cb) { - loggerStub.info('second'); + loggerStub.debug('second'); cb(); }, ], }; }); - afterEach(() => loggerStub.info.restore()); + afterEach(() => loggerStub.debug.restore()); it('should run all hooks', done => runner.executeAllTransactions([transaction], runner.hooks, () => { - assert.isOk(loggerStub.info.calledWith('first')); - assert.isOk(loggerStub.info.calledWith('second')); + assert.isOk(loggerStub.debug.calledWith('first')); + assert.isOk(loggerStub.debug.calledWith('second')); done(); })); });