diff --git a/src/add-hooks.js b/src/add-hooks.js index 6062a6cbe..9433e117d 100644 --- a/src/add-hooks.js +++ b/src/add-hooks.js @@ -58,29 +58,29 @@ Stack: ${error.stack} ); if (!isHooksDataCorrect) { - return next( - new Error('hooksData option must be an object e.g. {"filename.js":"console.log("Hey!")"}') - ); + return next(new Error('hooksData option must be an object e.g. {"filename.js":"console.log("Hey!")"}')); } // Run code in sandbox - async.eachSeries(Object.keys(runner.configuration.hooksData), (key, nextHook) => { - const data = runner.configuration.hooksData[key]; + async.eachSeries( + Object.keys(runner.configuration.hooksData), (key, nextHook) => { + const data = runner.configuration.hooksData[key]; - // Run code in sandbox - sandboxHooksCode(data, (sandboxError, result) => { - if (sandboxError) { return nextHook(sandboxError); } + // Run code in sandbox + sandboxHooksCode(data, (sandboxError, result) => { + if (sandboxError) { return nextHook(sandboxError); } - // Merge stringified hooks - runner.hooks = mergeSandboxedHooks(runner.hooks, result); + // Merge stringified hooks + runner.hooks = mergeSandboxedHooks(runner.hooks, result); - // Fixing #168 issue - fixLegacyTransactionNames(runner.hooks); + // Fixing #168 issue + fixLegacyTransactionNames(runner.hooks); - nextHook(); - }); - } - , next); + nextHook(); + }); + } + , next + ); } if (!runner.logs) { runner.logs = []; } @@ -153,22 +153,24 @@ Stack: ${error.stack} // Load sandbox files from fs logger.info('Loading hook files in sandboxed context:', files); - return async.eachSeries(files, (resolvedPath, nextFile) => + return async.eachSeries( + files, (resolvedPath, nextFile) => // Load hook file content - fs.readFile(resolvedPath, 'utf8', (readingError, data) => { - if (readingError) { return nextFile(readingError); } - // Run code in sandbox - sandboxHooksCode(data, (sandboxError, result) => { - if (sandboxError) { return nextFile(sandboxError); } - runner.hooks = mergeSandboxedHooks(runner.hooks, result); - - // Fixing #168 issue - fixLegacyTransactionNames(runner.hooks); - - return nextFile(); - }); - }) - , callback); + fs.readFile(resolvedPath, 'utf8', (readingError, data) => { + if (readingError) { return nextFile(readingError); } + // Run code in sandbox + sandboxHooksCode(data, (sandboxError, result) => { + if (sandboxError) { return nextFile(sandboxError); } + runner.hooks = mergeSandboxedHooks(runner.hooks, result); + + // Fixing #168 issue + fixLegacyTransactionNames(runner.hooks); + + return nextFile(); + }); + }) + , callback + ); } module.exports = addHooks; diff --git a/src/child-process.js b/src/child-process.js index 35c948004..290a41ee0 100644 --- a/src/child-process.js +++ b/src/child-process.js @@ -13,9 +13,7 @@ function signalKill(childProcess, callback) { const taskkill = spawn('taskkill', ['/F', '/T', '/PID', childProcess.pid]); taskkill.on('exit', (exitStatus) => { if (exitStatus) { - return callback( - new Error(`Unable to forcefully terminate process ${childProcess.pid}`) - ); + return callback(new Error(`Unable to forcefully terminate process ${childProcess.pid}`)); } callback(); }); @@ -108,9 +106,7 @@ function terminate(childProcess, options = {}, callback) { if (force) { signalKill(childProcess, callback); } else { - callback( - new Error(`Unable to gracefully terminate process ${childProcess.pid}`) - ); + callback(new Error(`Unable to gracefully terminate process ${childProcess.pid}`)); } } }; diff --git a/src/configure-reporters.js b/src/configure-reporters.js index db43870d9..09c5de1a5 100644 --- a/src/configure-reporters.js +++ b/src/configure-reporters.js @@ -36,15 +36,11 @@ function configureReporters(config, stats, tests, runner) { if (reportersArr.length > 0) { const usedCliReporters = intersection(reportersArr, cliReporters); if (usedCliReporters.length === 0) { - return new CliReporter( - config.emitter, stats, tests, config.options['inline-errors'], config.options.details - ); + return new CliReporter(config.emitter, stats, tests, config.options['inline-errors'], config.options.details); } return addReporter(usedCliReporters[0], config.emitter, stats, tests); } - return new CliReporter( - config.emitter, stats, tests, config.options['inline-errors'], config.options.details - ); + return new CliReporter(config.emitter, stats, tests, config.options['inline-errors'], config.options.details); } function addReporter(reporter, emitter, statistics, testsArg, path) { diff --git a/src/dredd-command.js b/src/dredd-command.js index 85650b681..207b3361d 100644 --- a/src/dredd-command.js +++ b/src/dredd-command.js @@ -274,10 +274,12 @@ ${packageData.name} v${packageData.version} \ const waitMilis = waitSecs * 1000; logger.info(`Waiting ${waitSecs} seconds for backend server process to start`); - this.wait = setTimeout(() => { - this.runDredd(this.dreddInstance); - } - , waitMilis); + this.wait = setTimeout( + () => { + this.runDredd(this.dreddInstance); + } + , waitMilis + ); } } diff --git a/src/dredd.js b/src/dredd.js index b42e6a3d0..1d4f6767f 100644 --- a/src/dredd.js +++ b/src/dredd.js @@ -136,56 +136,60 @@ https://dredd.readthedocs.io/en/latest/how-it-works/#using-https-proxy // Expand all globs expandGlobs(callback) { - async.each(this.configuration.options.path, (globToExpand, globCallback) => { - if (/^http(s)?:\/\//.test(globToExpand)) { - this.configuration.files = this.configuration.files.concat(globToExpand); - return globCallback(); - } + async.each( + this.configuration.options.path, (globToExpand, globCallback) => { + if (/^http(s)?:\/\//.test(globToExpand)) { + this.configuration.files = this.configuration.files.concat(globToExpand); + return globCallback(); + } - glob(globToExpand, (err, match) => { - if (err) { return globCallback(err); } - this.configuration.files = this.configuration.files.concat(match); - if (match.length === 0) { - err = new Error(` + glob(globToExpand, (err, match) => { + if (err) { return globCallback(err); } + this.configuration.files = this.configuration.files.concat(match); + if (match.length === 0) { + err = new Error(` API description document(s) not found on path: '${globToExpand}' `); - return globCallback(err); - } - globCallback(); - }); - } + return globCallback(err); + } + globCallback(); + }); + } , (err) => { - if (err) { return callback(err, this.stats); } + if (err) { return callback(err, this.stats); } - if (this.configDataIsEmpty && this.configuration.files.length === 0) { - err = new Error(` + if (this.configDataIsEmpty && this.configuration.files.length === 0) { + err = new Error(` API description document (or documents) not found on path: '${this.configuration.options.path}' `); - return callback(err, this.stats); - } + return callback(err, this.stats); + } - // Remove duplicate filenames - this.configuration.files = removeDuplicates(this.configuration.files); - callback(null, this.stats); - }); + // Remove duplicate filenames + this.configuration.files = removeDuplicates(this.configuration.files); + callback(null, this.stats); + } + ); } // Load all files loadFiles(callback) { // 6 parallel connections is a standard limit when connecting to one hostname, // use the same limit of parallel connections for reading/downloading files - 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); - this.downloadFile(fileUrlOrPath, loadCallback); - } else { - this.readLocalFile(fileUrlOrPath, loadCallback); + 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); + this.downloadFile(fileUrlOrPath, loadCallback); + } else { + this.readLocalFile(fileUrlOrPath, loadCallback); + } } - } - , callback); + , callback + ); } downloadFile(fileUrl, callback) { @@ -234,24 +238,26 @@ Is the provided path correct? this.transactions = []; // Compile HTTP transactions for each API description - async.each(Object.keys(this.configuration.data), (filename, next) => { - const fileData = this.configuration.data[filename]; - if (!fileData.annotations) { fileData.annotations = []; } - - logger.verbose('Compiling HTTP transactions from API description file:', filename); - dreddTransactions.compile(fileData.raw, filename, (compilationError, compilationResult) => { - if (compilationError) { return next(compilationError); } - - fileData.mediaType = compilationResult.mediaType; - fileData.annotations = fileData.annotations.concat(compilationResult.annotations); - this.transactions = this.transactions.concat(compilationResult.transactions); - next(); - }); - } + async.each( + Object.keys(this.configuration.data), (filename, next) => { + const fileData = this.configuration.data[filename]; + if (!fileData.annotations) { fileData.annotations = []; } + + logger.verbose('Compiling HTTP transactions from API description file:', filename); + dreddTransactions.compile(fileData.raw, filename, (compilationError, compilationResult) => { + if (compilationError) { return next(compilationError); } + + fileData.mediaType = compilationResult.mediaType; + fileData.annotations = fileData.annotations.concat(compilationResult.annotations); + this.transactions = this.transactions.concat(compilationResult.transactions); + next(); + }); + } , (runtimeError) => { - if (!runtimeError) { runtimeError = handleRuntimeProblems(this.configuration.data); } - callback(runtimeError, this.stats); - }); + if (!runtimeError) { runtimeError = handleRuntimeProblems(this.configuration.data); } + callback(runtimeError, this.stats); + } + ); } // Start the runner diff --git a/src/interactive-config.js b/src/interactive-config.js index 6a42c1d67..ac2e50289 100644 --- a/src/interactive-config.js +++ b/src/interactive-config.js @@ -127,8 +127,7 @@ interactiveConfig.processAnswers = function (config, answers, callback) { interactiveConfig.run = function (config, callback) { interactiveConfig.prompt(config, answers => - interactiveConfig.processAnswers(config, answers, callback) - ); + interactiveConfig.processAnswers(config, answers, callback)); }; interactiveConfig.updateCircle = function () { diff --git a/src/reporters/cli-reporter.js b/src/reporters/cli-reporter.js index 5912101d2..817691540 100644 --- a/src/reporters/cli-reporter.js +++ b/src/reporters/cli-reporter.js @@ -37,8 +37,7 @@ CliReporter.prototype.configureEmitter = function (emitter) { `${this.stats.failures} failing, ` + `${this.stats.errors} errors, ` + `${this.stats.skipped} skipped, ` + - `${this.stats.tests} total` - ); + `${this.stats.tests} total`); } logger.complete(`Tests took ${this.stats.duration}ms`); diff --git a/src/reporters/x-unit-reporter.js b/src/reporters/x-unit-reporter.js index 0b4fa117c..844b62a03 100644 --- a/src/reporters/x-unit-reporter.js +++ b/src/reporters/x-unit-reporter.js @@ -95,8 +95,7 @@ XUnitReporter.prototype.configureEmitter = function (emitter) { skip: this.stats.skipped, timestamp: (new Date()).toUTCString(), time: this.stats.duration / 1000 - }, false) - ); + }, false)); callback(); } else { logger.error(err); diff --git a/src/sandbox-hooks-code.js b/src/sandbox-hooks-code.js index ef11a9d47..3dbd53395 100644 --- a/src/sandbox-hooks-code.js +++ b/src/sandbox-hooks-code.js @@ -28,9 +28,11 @@ output\ `; const sandbox = new Pitboss(wrappedCode); - sandbox.run({ libraries: { - _Hooks: '../../../lib/hooks', console: 'console' - } }, (err, result) => { + sandbox.run({ + libraries: { + _Hooks: '../../../lib/hooks', console: 'console' + } + }, (err, result) => { sandbox.kill(); if (err) { return callback(err); } callback(undefined, result); diff --git a/src/transaction-runner.js b/src/transaction-runner.js index cbdf1cc71..3e069b0aa 100644 --- a/src/transaction-runner.js +++ b/src/transaction-runner.js @@ -86,53 +86,55 @@ class TransactionRunner { // Iterate over transactions' transaction // Because async changes the way referencing of properties work, // 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); + return async.timesSeries( + transactions.length, (transactionIndex, iterationCallback) => { + transaction = transactions[transactionIndex]; + logger.verbose(`Processing transaction #${transactionIndex + 1}:`, transaction.name); - logger.verbose('Running \'beforeEach\' hooks'); - this.runHooksForData(hooks.beforeEachHooks, transaction, false, () => { - if (this.hookHandlerError) { return iterationCallback(this.hookHandlerError); } - - logger.verbose('Running \'before\' hooks'); - this.runHooksForData(hooks.beforeHooks[transaction.name], transaction, false, () => { + logger.verbose('Running \'beforeEach\' hooks'); + this.runHooksForData(hooks.beforeEachHooks, transaction, false, () => { if (this.hookHandlerError) { return iterationCallback(this.hookHandlerError); } - // This method: - // - skips and fails based on hooks or options - // - executes a request - // - recieves a response - // - runs beforeEachValidation hooks - // - runs beforeValidation hooks - // - runs Gavel validation - this.executeTransaction(transaction, hooks, () => { + logger.verbose('Running \'before\' hooks'); + this.runHooksForData(hooks.beforeHooks[transaction.name], transaction, false, () => { if (this.hookHandlerError) { return iterationCallback(this.hookHandlerError); } - logger.verbose('Running \'afterEach\' hooks'); - this.runHooksForData(hooks.afterEachHooks, transaction, false, () => { + // This method: + // - skips and fails based on hooks or options + // - executes a request + // - recieves a response + // - runs beforeEachValidation hooks + // - runs beforeValidation hooks + // - runs Gavel validation + this.executeTransaction(transaction, hooks, () => { if (this.hookHandlerError) { return iterationCallback(this.hookHandlerError); } - logger.verbose('Running \'after\' hooks'); - this.runHooksForData(hooks.afterHooks[transaction.name], transaction, false, () => { + logger.verbose('Running \'afterEach\' hooks'); + this.runHooksForData(hooks.afterEachHooks, transaction, false, () => { if (this.hookHandlerError) { return iterationCallback(this.hookHandlerError); } - logger.debug(`Evaluating results of transaction execution #${transactionIndex + 1}:`, transaction.name); - this.emitResult(transaction, iterationCallback); + logger.verbose('Running \'after\' hooks'); + this.runHooksForData(hooks.afterHooks[transaction.name], transaction, false, () => { + if (this.hookHandlerError) { return iterationCallback(this.hookHandlerError); } + + logger.debug(`Evaluating results of transaction execution #${transactionIndex + 1}:`, transaction.name); + this.emitResult(transaction, iterationCallback); + }); }); }); }); }); - }); - } + } , (iterationError) => { - if (iterationError) { return callback(iterationError); } + if (iterationError) { return callback(iterationError); } - logger.verbose('Running \'afterAll\' hooks'); - this.runHooksForData(hooks.afterAllHooks, transactions, true, () => { - if (this.hookHandlerError) { return callback(this.hookHandlerError); } - callback(); - }); - }); + logger.verbose('Running \'afterAll\' hooks'); + this.runHooksForData(hooks.afterAllHooks, transactions, true, () => { + if (this.hookHandlerError) { return callback(this.hookHandlerError); } + callback(); + }); + } + ); }); } @@ -259,20 +261,22 @@ output;\ const wrappedCode = this.sandboxedWrappedCode(hookString); const sandbox = new Pitboss(wrappedCode, { timeout: 500 }); - return sandbox.run({ - context: { - _data: data, - _logs: [], - stash: this.hookStash - }, - libraries: { - _log: sandboxedLogLibraryPath + return sandbox.run( + { + context: { + _data: data, + _logs: [], + stash: this.hookStash + }, + libraries: { + _log: sandboxedLogLibraryPath + } } - } , (err, result = {}) => { - sandbox.kill(); - this.sandboxedHookResultsHandler(err, data, result, callback); - }); + sandbox.kill(); + this.sandboxedHookResultsHandler(err, data, result, callback); + } + ); } // Will be used runHook instead in next major release, see deprecation warning @@ -753,12 +757,8 @@ under test: ${options.method} ${options.uri}\ // Warn about empty responses // Expected is as string, actual is as integer :facepalm: - const isExpectedResponseStatusCodeEmpty = ['204', '205'].includes( - test.expected.statusCode ? test.expected.statusCode.toString() : undefined - ); - const isActualResponseStatusCodeEmpty = ['204', '205'].includes( - test.actual.statusCode ? test.actual.statusCode.toString() : undefined - ); + const isExpectedResponseStatusCodeEmpty = ['204', '205'].includes(test.expected.statusCode ? test.expected.statusCode.toString() : undefined); + const isActualResponseStatusCodeEmpty = ['204', '205'].includes(test.actual.statusCode ? test.actual.statusCode.toString() : undefined); const hasBody = (test.expected.body || test.actual.body); if ((isExpectedResponseStatusCodeEmpty || isActualResponseStatusCodeEmpty) && hasBody) { logger.warn(`\ diff --git a/test/integration/child-process-test.js b/test/integration/child-process-test.js index 808526f23..a6e7abdaa 100644 --- a/test/integration/child-process-test.js +++ b/test/integration/child-process-test.js @@ -38,20 +38,24 @@ function runChildProcess(command, fn, callback) { childProcess.on('crash', onCrash); - setTimeout(() => { - fn(childProcess); - - setTimeout(() => { - childProcess.removeListener('exit', onExit); - childProcess.removeListener('error', onError); - childProcess.removeListener('crash', onCrash); - - processInfo.childProcess = childProcess; - callback(null, processInfo); + setTimeout( + () => { + fn(childProcess); + + setTimeout( + () => { + childProcess.removeListener('exit', onExit); + childProcess.removeListener('error', onError); + childProcess.removeListener('crash', onCrash); + + processInfo.childProcess = childProcess; + callback(null, processInfo); + } + , WAIT_AFTER_COMMAND_TERMINATED_MS + ); } - , WAIT_AFTER_COMMAND_TERMINATED_MS); - } - , WAIT_AFTER_COMMAND_SPAWNED_MS); + , WAIT_AFTER_COMMAND_SPAWNED_MS + ); } describe('Babysitting Child Processes', () => { @@ -60,12 +64,13 @@ describe('Babysitting Child Processes', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/stdout.coffee', childProcess => childProcess.signalKill() + runChildProcess( + 'test/fixtures/scripts/stdout.coffee', childProcess => childProcess.signalKill() , (err, info) => { processInfo = info; done(err); - }) - ); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('does not log a message about being gracefully terminated', () => assert.notInclude(processInfo.stdout, 'exiting')); @@ -83,12 +88,13 @@ describe('Babysitting Child Processes', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/endless-ignore-term.coffee', childProcess => childProcess.signalKill() + runChildProcess( + 'test/fixtures/scripts/endless-ignore-term.coffee', childProcess => childProcess.signalKill() , (err, info) => { processInfo = info; done(err); - }) - ); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('does not log a message about ignoring graceful termination', () => assert.notInclude(processInfo.stdout, 'ignoring')); @@ -109,12 +115,13 @@ describe('Babysitting Child Processes', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/stdout.coffee', childProcess => childProcess[functionName]() + runChildProcess( + 'test/fixtures/scripts/stdout.coffee', childProcess => childProcess[functionName]() , (err, info) => { processInfo = info; done(err); - }) - ); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('logs a message about being gracefully terminated', () => assert.include(processInfo.stdout, 'exiting')); @@ -130,12 +137,13 @@ describe('Babysitting Child Processes', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/endless-ignore-term.coffee', childProcess => childProcess.terminate() + runChildProcess( + 'test/fixtures/scripts/endless-ignore-term.coffee', childProcess => childProcess.terminate() , (err, info) => { processInfo = info; done(err); - }) - ); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('logs a message about ignoring the graceful termination attempt', () => assert.include(processInfo.stdout, 'ignoring')); @@ -146,23 +154,22 @@ describe('Babysitting Child Processes', () => { assert.equal( processInfo.error.message, `Unable to gracefully terminate process ${processInfo.childProcess.pid}` - ) - ); + )); }); - }) - ); + })); describe('when gracefully terminated by childProcess.terminate({\'force\': true})', () => { describe('process with support for graceful termination', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/stdout.coffee', childProcess => childProcess.terminate({ force: true }) + runChildProcess( + 'test/fixtures/scripts/stdout.coffee', childProcess => childProcess.terminate({ force: true }) , (err, info) => { processInfo = info; done(err); - }) - ); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('logs a message about being gracefully terminated', () => assert.include(processInfo.stdout, 'exiting')); @@ -178,12 +185,13 @@ describe('Babysitting Child Processes', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/endless-ignore-term.coffee', childProcess => childProcess.terminate({ force: true }) + runChildProcess( + 'test/fixtures/scripts/endless-ignore-term.coffee', childProcess => childProcess.terminate({ force: true }) , (err, info) => { processInfo = info; done(err); - }) - ); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('logs a message about ignoring the graceful termination attempt', () => assert.include(processInfo.stdout, 'ignoring')); @@ -210,8 +218,8 @@ describe('Babysitting Child Processes', () => { , (err, info) => { processInfo = info; done(err); - }) - ); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('returns zero status code', () => assert.equal(processInfo.exitStatus, 0)); @@ -230,8 +238,8 @@ describe('Babysitting Child Processes', () => { , (err, info) => { processInfo = info; done(err); - }) - ); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('returns non-zero status code', () => assert.isAbove(processInfo.exitStatus, 0)); @@ -247,12 +255,13 @@ describe('Babysitting Child Processes', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/stdout.coffee', childProcess => childProcess.signalTerm() + runChildProcess( + 'test/fixtures/scripts/stdout.coffee', childProcess => childProcess.signalTerm() , (err, info) => { processInfo = info; done(err); - }) - ); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('returns zero status code', () => assert.equal(processInfo.exitStatus, 0)); @@ -266,12 +275,13 @@ describe('Babysitting Child Processes', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/stdout-exit-3.coffee', childProcess => childProcess.signalTerm() + runChildProcess( + 'test/fixtures/scripts/stdout-exit-3.coffee', childProcess => childProcess.signalTerm() , (err, info) => { processInfo = info; done(err); - }) - ); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('returns non-zero status code', () => assert.isAbove(processInfo.exitStatus, 0)); @@ -285,12 +295,13 @@ describe('Babysitting Child Processes', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/stdout.coffee', childProcess => childProcess.signalKill() + runChildProcess( + 'test/fixtures/scripts/stdout.coffee', childProcess => childProcess.signalKill() , (err, info) => { processInfo = info; done(err); - }) - ); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); if (process.platform === 'win32') { @@ -309,17 +320,18 @@ describe('Babysitting Child Processes', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/stdout.coffee', (childProcess) => { + runChildProcess( + 'test/fixtures/scripts/stdout.coffee', (childProcess) => { // Simulate that the process was terminated externally - const emit = sinon.stub(childProcess, 'emit'); - signalTerm(childProcess, () => {}); - emit.restore(); - } + const emit = sinon.stub(childProcess, 'emit'); + signalTerm(childProcess, () => {}); + emit.restore(); + } , (err, info) => { - processInfo = info; - done(err); - }) - ); + processInfo = info; + done(err); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('returns zero status code', () => assert.equal(processInfo.exitStatus, 0)); @@ -333,17 +345,18 @@ describe('Babysitting Child Processes', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/stdout-exit-3.coffee', (childProcess) => { + runChildProcess( + 'test/fixtures/scripts/stdout-exit-3.coffee', (childProcess) => { // Simulate that the process was terminated externally - const emit = sinon.stub(childProcess, 'emit'); - signalTerm(childProcess, () => {}); - emit.restore(); - } + const emit = sinon.stub(childProcess, 'emit'); + signalTerm(childProcess, () => {}); + emit.restore(); + } , (err, info) => { - processInfo = info; - done(err); - }) - ); + processInfo = info; + done(err); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); it('returns non-zero status code', () => assert.isAbove(processInfo.exitStatus, 0)); @@ -359,17 +372,18 @@ describe('Babysitting Child Processes', () => { let processInfo; before(done => - runChildProcess('test/fixtures/scripts/stdout.coffee', (childProcess) => { + runChildProcess( + 'test/fixtures/scripts/stdout.coffee', (childProcess) => { // Simulate that the process was killed externally - const emit = sinon.stub(childProcess, 'emit'); - signalKill(childProcess, () => {}); - emit.restore(); - } + const emit = sinon.stub(childProcess, 'emit'); + signalKill(childProcess, () => {}); + emit.restore(); + } , (err, info) => { - processInfo = info; - done(err); - }) - ); + processInfo = info; + done(err); + } + )); after(done => helpers.kill(processInfo.childProcess.pid, done)); if (process.platform === 'win32') { diff --git a/test/integration/cli/cli-test.js b/test/integration/cli/cli-test.js index 1f00764b9..c7ecc71f4 100644 --- a/test/integration/cli/cli-test.js +++ b/test/integration/cli/cli-test.js @@ -2,7 +2,9 @@ const net = require('net'); const path = require('path'); const { assert } = require('chai'); -const { isProcessRunning, killAll, createServer, runDreddCommandWithServer, runDreddCommand, DEFAULT_SERVER_PORT } = require('../helpers'); +const { + isProcessRunning, killAll, createServer, runDreddCommandWithServer, runDreddCommand, DEFAULT_SERVER_PORT +} = require('../helpers'); const COFFEE_BIN = 'node_modules/.bin/coffee'; const DEFAULT_HOOK_HANDLER_PORT = 61321; @@ -98,8 +100,7 @@ describe('CLI', () => { isProcessRunning('endless-ignore-term', (err, isRunning) => { if (!err) { assert.isFalse(isRunning); } done(err); - }) - ); + })); it('should not execute any transaction', () => assert.deepEqual(runtimeInfo.server.requestCounts, {})); }); @@ -134,8 +135,7 @@ describe('CLI', () => { isProcessRunning('endless-ignore-term', (err, isRunning) => { if (!err) { assert.isFalse(isRunning); } done(err); - }) - ); + })); it('should not execute any transaction', () => assert.deepEqual(runtimeInfo.server.requestCounts, {})); }); @@ -177,8 +177,7 @@ describe('CLI', () => { isProcessRunning('endless-ignore-term', (err, isRunning) => { if (!err) { assert.isFalse(isRunning); } done(err); - }) - ); + })); it('should not execute any transaction', () => assert.deepEqual(runtimeInfo.server.requestCounts, {})); }); @@ -217,8 +216,7 @@ describe('CLI', () => { hookHandler.close(); runtimeInfo = info; done(err); - }) - ); + })); }); after(done => killAll('test/fixtures/scripts/', done)); @@ -237,8 +235,7 @@ describe('CLI', () => { isProcessRunning('endless-ignore-term', (err, isRunning) => { if (!err) { assert.isFalse(isRunning); } done(err); - }) - ); + })); it('should execute the transaction', () => assert.deepEqual(runtimeInfo.server.requestCounts, { '/machines': 1 })); }); @@ -270,8 +267,7 @@ describe('CLI', () => { hookHandler.close(); runtimeInfo = info; done(err); - }) - ); + })); }); after(done => killAll('test/fixtures/scripts/', done)); @@ -287,8 +283,7 @@ describe('CLI', () => { isProcessRunning('endless-ignore-term', (err, isRunning) => { if (!err) { assert.isFalse(isRunning); } done(err); - }) - ); + })); it('should execute some transaction', () => assert.deepEqual(runtimeInfo.server.requestCounts, { '/machines': 1 })); }); @@ -361,12 +356,10 @@ describe('CLI', () => { }); it('should perform the POST, GET, PUT, DELETE in order', () => { - assert.isOk( - runtimeInfo.dredd.stdout.indexOf('POST') < + assert.isOk(runtimeInfo.dredd.stdout.indexOf('POST') < runtimeInfo.dredd.stdout.indexOf('GET') < runtimeInfo.dredd.stdout.indexOf('PUT') < - runtimeInfo.dredd.stdout.indexOf('DELETE') - ); + runtimeInfo.dredd.stdout.indexOf('DELETE')); }); }); @@ -416,8 +409,7 @@ describe('CLI', () => { it('should display details on passing tests', () => // The request: block is not shown for passing tests normally - assert.isOk(runtimeInfo.dredd.stdout.indexOf('request') > -1) - ); + assert.isOk(runtimeInfo.dredd.stdout.indexOf('request') > -1)); }); describe('when filtering request methods with -m', () => { @@ -516,8 +508,7 @@ describe('CLI', () => { it('should print without colors', () => // If colors are not on, there is no closing color code between // the "pass" and the ":" - assert.include(runtimeInfo.dredd.stdout, 'pass:') - ); + assert.include(runtimeInfo.dredd.stdout, 'pass:')); }); describe('when suppressing color with --color=false', () => { @@ -541,8 +532,7 @@ describe('CLI', () => { it('should print without colors', () => // If colors are not on, there is no closing color code between // the "pass" and the ":" - assert.include(runtimeInfo.dredd.stdout, 'pass:') - ); + assert.include(runtimeInfo.dredd.stdout, 'pass:')); }); describe('when setting the log output level with -l', () => { @@ -565,8 +555,7 @@ describe('CLI', () => { it('should not display anything', () => // At the "error" level, complete should not be shown - assert.isOk(runtimeInfo.dredd.stdout.indexOf('complete') === -1) - ); + assert.isOk(runtimeInfo.dredd.stdout.indexOf('complete') === -1)); }); describe('when showing timestamps with -t', () => { @@ -589,8 +578,7 @@ describe('CLI', () => { it('should display timestamps', () => // Look for the prefix for cli output with timestamps - assert.notEqual(runtimeInfo.dredd.stdout.indexOf('Z -'), -1) - ); + assert.notEqual(runtimeInfo.dredd.stdout.indexOf('Z -'), -1)); }); }); @@ -696,8 +684,7 @@ describe('CLI', () => { expires: 1234, token: 'this should pass since it is a string' } - }) - ); + })); const args = [ './test/fixtures/schema.apib', @@ -723,8 +710,7 @@ describe('CLI', () => { expires: 'this should fail since it is a string', token: 'this should pass since it is a string' } - }) - ); + })); const args = [ './test/fixtures/schema.apib', @@ -832,8 +818,7 @@ describe('CLI', () => { }); it('should exit with status 0', () => assert.equal(dreddCommandInfo.exitStatus, 0)); - }) - ); + })); describe('Using sandboxed hooks', () => { let runtimeInfo; diff --git a/test/integration/cli/reporters-cli-test.js b/test/integration/cli/reporters-cli-test.js index 42d420dd2..5fb1064a8 100644 --- a/test/integration/cli/reporters-cli-test.js +++ b/test/integration/cli/reporters-cli-test.js @@ -34,13 +34,11 @@ describe('CLI - Reporters', () => { runDreddCommand(args, (err, info) => { dreddCommandInfo = info; done(err); - }) - ); + })); it('should use given reporter', () => // Nyan cat ears should exist in stdout - assert.include(dreddCommandInfo.stdout, '/\\_/\\') - ); + assert.include(dreddCommandInfo.stdout, '/\\_/\\')); }); @@ -59,8 +57,7 @@ describe('CLI - Reporters', () => { _id: '1234_id', testRunId: '6789_testRunId', reportUrl: 'http://example.com/test/run/1234_id' - }) - ); + })); app.all('*', (req, res) => res.json({})); @@ -86,8 +83,7 @@ describe('CLI - Reporters', () => { dreddCommandInfo = info; stepRequest = apiaryRuntimeInfo.requests['/apis/public/tests/steps?testRunId=1234_id'][0]; done(err); - }) - ); + })); it('should print URL of the test report', () => assert.include(dreddCommandInfo.stdout, 'http://example.com/test/run/1234_id')); it('should print warning about missing Apiary API settings', () => assert.include(dreddCommandInfo.stdout, 'Apiary API Key or API Project Subdomain were not provided.')); @@ -127,13 +123,11 @@ describe('CLI - Reporters', () => { updateRequest = apiaryRuntimeInfo.requests['/apis/public/tests/run/1234_id'][0]; stepRequest = apiaryRuntimeInfo.requests['/apis/public/tests/steps?testRunId=1234_id'][0]; return done(err); - }) - ); + })); it('hooks.log should print also to console', () => // Because --level=info is lower than --level=hook - assert.include(dreddCommandInfo.output, 'using hooks.log to debug') - ); + assert.include(dreddCommandInfo.output, 'using hooks.log to debug')); it('hooks.log should use toString on objects', () => assert.include(dreddCommandInfo.output, 'Error object!')); it('should exit with status 0', () => assert.equal(dreddCommandInfo.exitStatus, 0)); @@ -204,8 +198,7 @@ describe('CLI - Reporters', () => { updateRequest = apiaryRuntimeInfo.requests['/apis/public/tests/run/1234_id'][0]; stepRequest = apiaryRuntimeInfo.requests['/apis/public/tests/steps?testRunId=1234_id'][0]; done(err); - }) - ); + })); it('hooks.log should not print also to console', () => { // Because we are running in sandboxed mode with higher --level @@ -265,8 +258,7 @@ describe('CLI - Reporters', () => { beforeEach(done => runDreddCommand(args, (err) => { done(err); - }) - ); + })); afterEach(() => fs.unlinkSync(`${process.cwd()}/__test_file_output__.xml`)); @@ -286,8 +278,7 @@ describe('CLI - Reporters', () => { beforeEach(done => runDreddCommand(args, (err) => { done(err); - }) - ); + })); afterEach(() => { fs.unlinkSync(`${process.cwd()}/__test_file_output1__.xml`); diff --git a/test/integration/cli/server-process-cli-test.js b/test/integration/cli/server-process-cli-test.js index 710295473..4d3843365 100644 --- a/test/integration/cli/server-process-cli-test.js +++ b/test/integration/cli/server-process-cli-test.js @@ -1,5 +1,7 @@ const { assert } = require('chai'); -const { isProcessRunning, killAll, runDreddCommand, createServer, DEFAULT_SERVER_PORT } = require('../helpers'); +const { + isProcessRunning, killAll, runDreddCommand, createServer, DEFAULT_SERVER_PORT +} = require('../helpers'); const COFFEE_BIN = 'node_modules/.bin/coffee'; const NON_EXISTENT_PORT = DEFAULT_SERVER_PORT + 1; @@ -33,8 +35,7 @@ describe('CLI - Server Process', () => { runDreddCommand(args, (err, info) => { dreddCommandInfo = info; done(err); - }) - ); + })); it('should request /machines', () => assert.deepEqual(serverRuntimeInfo.requestCounts, { '/machines': 1 })); it('should exit with status 0', () => assert.equal(dreddCommandInfo.exitStatus, 0)); @@ -48,8 +49,7 @@ describe('CLI - Server Process', () => { runDreddCommand(args, (err, info) => { dreddCommandInfo = info; done(err); - }) - ); + })); it('should return understandable message', () => assert.include(dreddCommandInfo.stdout, 'Error connecting')); it('should report error for all transactions', () => { @@ -78,8 +78,7 @@ describe('CLI - Server Process', () => { runDreddCommand(args, (err, info) => { dreddCommandInfo = info; done(err); - }) - ); + })); it('should inform about starting server with custom command', () => assert.include(dreddCommandInfo.stdout, 'Starting backend server process with command')); it('should redirect server\'s welcome message', () => assert.include(dreddCommandInfo.stdout, `Dummy server listening on port ${DEFAULT_SERVER_PORT}`)); @@ -99,8 +98,7 @@ describe('CLI - Server Process', () => { runDreddCommand(args, (err, info) => { dreddCommandInfo = info; done(err); - }) - ); + })); it('should inform about starting server with custom command', () => assert.include(dreddCommandInfo.stdout, 'Starting backend server process with command')); it('should report problem with server process spawn', () => assert.include(dreddCommandInfo.stderr, 'Command to start backend server process failed, exiting Dredd')); @@ -145,8 +143,7 @@ describe('CLI - Server Process', () => { runDreddCommand(args, (err, info) => { dreddCommandInfo = info; done(err); - }) - ); + })); it('should inform about starting server with custom command', () => assert.include(dreddCommandInfo.stdout, 'Starting backend server process with command')); if (scenario.expectServerBoot) { @@ -156,8 +153,7 @@ describe('CLI - Server Process', () => { isProcessRunning('test/fixtures/scripts/', (err, isRunning) => { if (!err) { assert.isFalse(isRunning); } done(err); - }) - ); + })); it('should report problems with connection to server', () => assert.include(dreddCommandInfo.stderr, 'Error connecting to server')); it('should exit with status 1', () => assert.equal(dreddCommandInfo.exitStatus, 1)); }); @@ -177,8 +173,7 @@ describe('CLI - Server Process', () => { runDreddCommand(args, (err, info) => { dreddCommandInfo = info; done(err); - }) - ); + })); it('should inform about starting server with custom command', () => assert.include(dreddCommandInfo.stdout, 'Starting backend server process with command')); it('should inform about gracefully terminating the server', () => assert.include(dreddCommandInfo.stdout, 'Gracefully terminating the backend server process')); @@ -188,8 +183,7 @@ describe('CLI - Server Process', () => { isProcessRunning('test/fixtures/scripts/', (err, isRunning) => { if (!err) { assert.isFalse(isRunning); } done(err); - }) - ); + })); it('should exit with status 0', () => assert.equal(dreddCommandInfo.exitStatus, 0)); }); }); diff --git a/test/integration/dredd-command-test.js b/test/integration/dredd-command-test.js index 7fcf8687c..442109b16 100644 --- a/test/integration/dredd-command-test.js +++ b/test/integration/dredd-command-test.js @@ -149,20 +149,23 @@ describe('DreddCommand class Integration', () => { let app = null; let server = null; - const errorCmd = { argv: [ - `http://127.0.0.1:${PORT + 1}/connection-error.apib`, - `http://127.0.0.1:${PORT + 1}` - ] + const errorCmd = { + argv: [ + `http://127.0.0.1:${PORT + 1}/connection-error.apib`, + `http://127.0.0.1:${PORT + 1}` + ] }; - const wrongCmd = { argv: [ - `http://127.0.0.1:${PORT}/not-found.apib`, - `http://127.0.0.1:${PORT}` - ] + const wrongCmd = { + argv: [ + `http://127.0.0.1:${PORT}/not-found.apib`, + `http://127.0.0.1:${PORT}` + ] }; - const goodCmd = { argv: [ - `http://127.0.0.1:${PORT}/file.apib`, - `http://127.0.0.1:${PORT}` - ] + const goodCmd = { + argv: [ + `http://127.0.0.1:${PORT}/file.apib`, + `http://127.0.0.1:${PORT}` + ] }; before((done) => { @@ -186,13 +189,11 @@ describe('DreddCommand class Integration', () => { app = null; server = null; done(); - }) - ); + })); describe('and I try to load a file from bad hostname at all', () => { before(done => - execCommand(errorCmd, () => done()) - ); + execCommand(errorCmd, () => done())); it('should exit with status 1', () => assert.equal(exitStatus, 1)); @@ -205,8 +206,7 @@ describe('DreddCommand class Integration', () => { describe('and I try to load a file that does not exist from an existing server', () => { before(done => - execCommand(wrongCmd, () => done()) - ); + execCommand(wrongCmd, () => done())); it('should exit with status 1', () => assert.equal(exitStatus, 1)); @@ -219,8 +219,7 @@ describe('DreddCommand class Integration', () => { describe('and I try to load a file that actually is there', () => { before(done => - execCommand(goodCmd, () => done()) - ); + execCommand(goodCmd, () => done())); it('should exit with status 0', () => assert.equal(exitStatus, 0)); }); diff --git a/test/integration/dredd-test.js b/test/integration/dredd-test.js index be92633a4..0e4cacfd7 100644 --- a/test/integration/dredd-test.js +++ b/test/integration/dredd-test.js @@ -90,8 +90,7 @@ describe('Dredd class Integration', () => { app.get('/machines', (req, res) => res.json([{ type: 'bulldozer', name: 'willy' }])); const server = app.listen(PORT, () => - execCommand(cmd, () => server.close()) - ); + execCommand(cmd, () => server.close())); server.on('close', done); }); @@ -112,8 +111,7 @@ describe('Dredd class Integration', () => { app.get('/machines', (req, res) => res.status(201).json([{ kind: 'bulldozer', imatriculation: 'willy' }])); const server = app.listen(PORT, () => - execCommand(cmd, () => server.close()) - ); + execCommand(cmd, () => server.close())); server.on('close', done); }); @@ -181,8 +179,7 @@ describe('Dredd class Integration', () => { server = app.listen(PORT, () => { server2 = apiary.listen((PORT + 1), () => { execCommand(cmd, () => - server2.close(() => server.close(() => done())) - ); + server2.close(() => server.close(() => done()))); }); }); }); @@ -234,8 +231,7 @@ describe('Dredd class Integration', () => { const server = app.listen(PORT, () => execCommand(cmd, () => { server.close(); - }) - ); + })); server.on('close', done); }); @@ -280,8 +276,7 @@ describe('Dredd class Integration', () => { apiary.all('*', (req, res) => res.json({})); server2 = apiary.listen((PORT + 1), () => - execCommand(cmd, () => server2.close(() => {})) - ); + execCommand(cmd, () => server2.close(() => {}))); server2.on('close', done); }); @@ -344,8 +339,7 @@ describe('Dredd class Integration', () => { server = app.listen(PORT, () => { server2 = apiary.listen((PORT + 1), () => {}); }); execCommand(cmd, () => - server2.close(() => server.close(() => {})) - ); + server2.close(() => server.close(() => {}))); server.on('close', done); }); @@ -428,13 +422,11 @@ describe('Dredd class Integration', () => { app = null; server = null; done(); - }) - ); + })); describe('and I try to load a file from bad hostname at all', () => { before(done => - execCommand(errorCmd, () => done()) - ); + execCommand(errorCmd, () => done())); after(() => { connectedToServer = null; }); @@ -451,8 +443,7 @@ describe('Dredd class Integration', () => { describe('and I try to load a file that does not exist from an existing server', () => { before(done => - execCommand(wrongCmd, () => done()) - ); + execCommand(wrongCmd, () => done())); after(() => { connectedToServer = null; }); @@ -471,8 +462,7 @@ describe('Dredd class Integration', () => { describe('and I try to load a file that actually is there', () => { before(done => - execCommand(goodCmd, () => done()) - ); + execCommand(goodCmd, () => done())); it('should send a GET to the right server', () => assert.isTrue(connectedToServer)); @@ -502,8 +492,7 @@ describe('Dredd class Integration', () => { }); const server = app.listen(PORT, () => - execCommand(cmd, () => server.close()) - ); + execCommand(cmd, () => server.close())); server.on('close', done); }); @@ -515,8 +504,7 @@ describe('Dredd class Integration', () => { it('stdout should contain sandbox messagae', () => assert.include(stdout, 'Loading hook files in sandboxed context')); it('should perform the request', () => assert.isTrue(requested)); - }) - ); + })); describe('when i use sandbox and hookData option', () => describe('and I run a test', () => { @@ -544,8 +532,7 @@ after('Machines > Machines collection > Get Machines', function(transaction){ }); const server = app.listen(PORT, () => - execCommand(cmd, () => server.close()) - ); + execCommand(cmd, () => server.close())); server.on('close', done); }); @@ -557,8 +544,7 @@ after('Machines > Machines collection > Get Machines', function(transaction){ it('stdout should not sandbox messagae', () => assert.notInclude(stdout, 'Loading hook files in sandboxed context')); it('should perform the request', () => assert.isTrue(requested)); - }) - ); + })); describe('when use old buggy (#168) path with leading whitespace in hooks', () => describe('and I run a test', () => { @@ -589,8 +575,7 @@ before('Machines collection > Get Machines', function(transaction){ }); const server = app.listen(PORT, () => - execCommand(cmd, () => server.close()) - ); + execCommand(cmd, () => server.close())); server.on('close', done); }); @@ -598,32 +583,36 @@ before('Machines collection > Get Machines', function(transaction){ it('should execute hook with whitespaced name', () => assert.include(stderr, 'Whitespace transaction name')); it('should execute hook with fuxed name', () => assert.include(stderr, 'Fixed transaction name')); - }) - ); + })); describe('when Swagger document has multiple responses', () => { const reTransaction = /(\w+): (\w+) \((\d+)\) \/honey/g; let actual; before(done => - execCommand({ - options: { - path: './test/fixtures/multiple-responses.yaml' + execCommand( + { + options: { + path: './test/fixtures/multiple-responses.yaml' + } } - } , (err) => { - let groups; - const matches = []; - // eslint-disable-next-line + let groups; + const matches = []; + // eslint-disable-next-line while (groups = reTransaction.exec(stdout)) { matches.push(groups); } - actual = matches.map((match) => { - const keyMap = { 0: 'name', 1: 'action', 2: 'method', 3: 'statusCode' }; - return match.reduce((result, element, i) => Object.assign(result, { [keyMap[i]]: element }) - , {}); - }); - done(err); - }) - ); + actual = matches.map((match) => { + const keyMap = { + 0: 'name', 1: 'action', 2: 'method', 3: 'statusCode' + }; + return match.reduce( + (result, element, i) => Object.assign(result, { [keyMap[i]]: element }) + , {} + ); + }); + done(err); + } + )); it('recognizes all 3 transactions', () => assert.equal(actual.length, 3)); @@ -635,8 +624,7 @@ before('Machines collection > Get Machines', function(transaction){ context(`the transaction #${i + 1}`, () => { it(`has status code ${expected.statusCode}`, () => assert.equal(expected.statusCode, actual[i].statusCode)); it(`is ${expected.action === 'skip' ? '' : 'not '}skipped by default`, () => assert.equal(expected.action, actual[i].action)); - }) - ); + })); }); describe('when Swagger document has multiple responses and hooks unskip some of them', () => { @@ -644,25 +632,30 @@ before('Machines collection > Get Machines', function(transaction){ let actual; before(done => - execCommand({ - options: { - path: './test/fixtures/multiple-responses.yaml', - hookfiles: './test/fixtures/swagger-multiple-responses.js' + execCommand( + { + options: { + path: './test/fixtures/multiple-responses.yaml', + hookfiles: './test/fixtures/swagger-multiple-responses.js' + } } - } , (err) => { - let groups; - const matches = []; - // eslint-disable-next-line + let groups; + const matches = []; + // eslint-disable-next-line while (groups = reTransaction.exec(stdout)) { matches.push(groups); } - actual = matches.map((match) => { - const keyMap = { 0: 'name', 1: 'action', 2: 'method', 3: 'statusCode' }; - return match.reduce((result, element, i) => Object.assign(result, { [keyMap[i]]: element }) - , {}); - }); - done(err); - }) - ); + actual = matches.map((match) => { + const keyMap = { + 0: 'name', 1: 'action', 2: 'method', 3: 'statusCode' + }; + return match.reduce( + (result, element, i) => Object.assign(result, { [keyMap[i]]: element }) + , {} + ); + }); + done(err); + } + )); it('recognizes all 3 transactions', () => assert.equal(actual.length, 3)); @@ -677,8 +670,7 @@ before('Machines collection > Get Machines', function(transaction){ const defaultMessage = `is ${expected.action === 'skip' ? '' : 'not '}skipped by default`; const unskippedMessage = 'is unskipped in hooks'; it(`${expected.statusCode === '500' ? unskippedMessage : defaultMessage}`, () => assert.equal(expected.action, actual[i].action)); - }) - ); + })); }); describe('when using Swagger document with hooks', () => { @@ -686,27 +678,27 @@ before('Machines collection > Get Machines', function(transaction){ let matches; beforeEach(done => - execCommand({ - options: { - path: './test/fixtures/multiple-responses.yaml', - hookfiles: './test/fixtures/swagger-transaction-names.js' + execCommand( + { + options: { + path: './test/fixtures/multiple-responses.yaml', + hookfiles: './test/fixtures/swagger-transaction-names.js' + } } - } , (err) => { - let groups; - matches = []; - // eslint-disable-next-line + let groups; + matches = []; + // eslint-disable-next-line while (groups = reTransactionName.exec(stdout)) { matches.push(groups[1]); } - done(err); - }) - ); + done(err); + } + )); it('transaction names contain status code and content type', () => assert.deepEqual(matches, [ '/honey > GET > 200 > application/json', '/honey > GET > 400 > application/json', '/honey > GET > 500 > application/json' - ]) - ); + ])); }); }); diff --git a/test/integration/helpers.js b/test/integration/helpers.js index 8d4ad6faf..684d858c1 100644 --- a/test/integration/helpers.js +++ b/test/integration/helpers.js @@ -133,13 +133,15 @@ function runDredd(dredd, serverPort, callback) { let stats; - recordLogging(next => dredd.run(next) + recordLogging( + next => dredd.run(next) , (err, args, logging) => { if (err) { return callback(err); } [err, stats] = Array.from(args); callback(null, { err, stats, logging }); - }); + } + ); } // Runs given Express.js server instance and then runs given Dredd class instance. @@ -151,8 +153,7 @@ function runDreddWithServer(dredd, app, serverPort, callback) { if (err) { return callback(err); } runDredd(dredd, serverPort, (error, dreddRuntimeInfo) => - server.close(() => callback(error, { server: serverRuntimeInfo, dredd: dreddRuntimeInfo })) - ); + server.close(() => callback(error, { server: serverRuntimeInfo, dredd: dreddRuntimeInfo }))); }); } @@ -177,7 +178,9 @@ function runCommand(command, args, spawnOptions = {}, callback) { output += data; }); - cli.on('exit', exitStatus => callback(null, { stdout, stderr, output, exitStatus })); + cli.on('exit', exitStatus => callback(null, { + stdout, stderr, output, exitStatus + })); } // Runs Dredd as a CLI command, with given arguments. @@ -192,8 +195,7 @@ function runDreddCommandWithServer(args, app, serverPort, callback) { if (err) { return callback(err); } runDreddCommand(args, (error, dreddCommandInfo) => - server.close(() => callback(error, { server: serverRuntimeInfo, dredd: dreddCommandInfo })) - ); + server.close(() => callback(error, { server: serverRuntimeInfo, dredd: dreddCommandInfo }))); }); } @@ -224,8 +226,10 @@ function killAll(pattern, callback) { return ps.lookup({ arguments: pattern }, (err, processList) => { if (err || !processList.length) { return callback(err); } - async.each(processList, (processListItem, next) => kill(processListItem.pid, next) - , callback); + async.each( + processList, (processListItem, next) => kill(processListItem.pid, next) + , callback + ); }); } diff --git a/test/integration/proxy-test.js b/test/integration/proxy-test.js index 23eb3c05e..175ea1ed0 100644 --- a/test/integration/proxy-test.js +++ b/test/integration/proxy-test.js @@ -2,7 +2,9 @@ const http = require('http'); const url = require('url'); const { assert } = require('chai'); -const { runDredd, recordLogging, createServer, DEFAULT_SERVER_PORT } = require('./helpers'); +const { + runDredd, recordLogging, createServer, DEFAULT_SERVER_PORT +} = require('./helpers'); const Dredd = require('../../src/dredd'); const PROXY_PORT = DEFAULT_SERVER_PORT + 1; @@ -29,8 +31,7 @@ function createAndRunDredd(configuration, done) { runDredd(dredd, (error, info) => { info.logging = `${dreddInitLogging}\n${info.logging}`; done(error, info); - }) - ); + })); } // Creates dummy proxy server for given protocol. Records details @@ -179,8 +180,7 @@ ${protocol}_proxy=${PROXY_URL}\ expectedLog, expectedDestination: 'server', expectedUrl: '/machines' - }) - ); + })); describe('Using Apiary Reporter', () => { beforeEach(() => { process.env.APIARY_API_URL = serverUrl; }); @@ -209,8 +209,7 @@ ${protocol}_proxy=${PROXY_URL}\ expectedLog, expectedDestination: 'proxy', expectedUrl: `${serverUrl}/example.apib` - }) - ); + })); }); }); @@ -241,8 +240,7 @@ http_proxy=${PROXY_URL}, no_proxy=${SERVER_HOST}\ expectedLog, expectedDestination: 'server', expectedUrl: '/machines' - }) - ); + })); describe('Using Apiary Reporter', () => { beforeEach(() => { process.env.APIARY_API_URL = serverUrl; }); @@ -271,6 +269,5 @@ http_proxy=${PROXY_URL}, no_proxy=${SERVER_HOST}\ expectedLog, expectedDestination: 'server', expectedUrl: '/example.apib' - }) - ); + })); }); diff --git a/test/integration/regressions/regression-152-test.js b/test/integration/regressions/regression-152-test.js index 523a9af37..ea2ad8c3b 100644 --- a/test/integration/regressions/regression-152-test.js +++ b/test/integration/regressions/regression-152-test.js @@ -27,5 +27,4 @@ describe('Regression: Issue #152', () => }); it('should modify the transaction with hooks', () => assert.deepEqual(Object.keys(runtimeInfo.server.requests), ['/machines?api-key=23456'])); - }) -); + })); diff --git a/test/integration/regressions/regression-319-354-test.js b/test/integration/regressions/regression-319-354-test.js index 1692e6f76..268402816 100644 --- a/test/integration/regressions/regression-319-354-test.js +++ b/test/integration/regressions/regression-319-354-test.js @@ -47,7 +47,9 @@ function parseDreddStdout(stdout) { }); // Re-arrange data from entries - const results = { summary: '', failures: [], bodies: [], schemas: [] }; + const results = { + summary: '', failures: [], bodies: [], schemas: [] + }; for (entry of entries) { switch (entry.label) { case 'body': results.bodies.push(parseIfJson(entry.body)); break; @@ -162,8 +164,7 @@ describe('Regression: Issues #319 and #354', () => { it('outputs no failures', () => // Intentionally not testing just '.length' as this approach will output the difference - assert.deepEqual(results.failures, []) - ); + assert.deepEqual(results.failures, [])); it('results in exactly four tests', () => assert.include(results.summary, '4 total')); it('results in four passing tests', () => assert.include(results.summary, '4 passing')); diff --git a/test/integration/regressions/regression-615-test.js b/test/integration/regressions/regression-615-test.js index cc0d011d2..23d1e284b 100644 --- a/test/integration/regressions/regression-615-test.js +++ b/test/integration/regressions/regression-615-test.js @@ -23,6 +23,5 @@ describe('Regression: Issue #615', () => { it('results in exactly three tests', () => assert.equal(runtimeInfo.dredd.stats.tests, 3)); it('results in three passing tests', () => // Ensures just the 200 responses were selected, because the server returns only 200s - assert.equal(runtimeInfo.dredd.stats.passes, 3) - ); + assert.equal(runtimeInfo.dredd.stats.passes, 3)); }); diff --git a/test/integration/request-test.js b/test/integration/request-test.js index 92f1064cf..8b782c28d 100644 --- a/test/integration/request-test.js +++ b/test/integration/request-test.js @@ -87,8 +87,7 @@ describe('Sending \'application/json\' request', () => { assert.equal(runtimeInfo.dredd.stats.tests, 1); assert.equal(runtimeInfo.dredd.stats.passes, 1); }); - }) -); + })); [{ name: 'API Blueprint', @@ -118,14 +117,12 @@ describe('Sending \'application/json\' request', () => { it('the request has the expected Content-Type', () => assert.equal(runtimeInfo.server.lastRequest.headers['content-type'], contentType)); it('the request has the expected format', () => // API Blueprint adds extra \n at the end: https://github.com/apiaryio/dredd/issues/67 - assert.equal(runtimeInfo.server.lastRequest.body.trim(), 'test=42') - ); + assert.equal(runtimeInfo.server.lastRequest.body.trim(), 'test=42')); it('results in one passing test', () => { assert.equal(runtimeInfo.dredd.stats.tests, 1); assert.equal(runtimeInfo.dredd.stats.passes, 1); }); - }) -); + })); describe('Sending \'text/plain\' request', () => { let runtimeInfo; diff --git a/test/integration/response-test.js b/test/integration/response-test.js index b22fa7386..2e66bd3eb 100644 --- a/test/integration/response-test.js +++ b/test/integration/response-test.js @@ -46,8 +46,7 @@ const Dredd = require('../../src/dredd'); it('evaluates the responses as valid', () => assert.deepInclude(runtimeInfo.dredd.stats, { tests: 2, passes: 2 })); }); - }) -); + })); [{ name: 'API Blueprint', @@ -91,8 +90,7 @@ const Dredd = require('../../src/dredd'); it('evaluates the response as valid', () => assert.deepInclude(runtimeInfo.dredd.stats, { tests: 1, passes: 1 })); }); - }) -); + })); [{ name: 'API Blueprint', @@ -148,8 +146,7 @@ const Dredd = require('../../src/dredd'); it('evaluates the responses as valid', () => assert.deepInclude(runtimeInfo.dredd.stats, { tests: 2, passes: 2 })); }); - }) -); + })); [{ name: 'API Blueprint', @@ -205,8 +202,7 @@ const Dredd = require('../../src/dredd'); it('evaluates the responses as valid', () => assert.deepInclude(runtimeInfo.dredd.stats, { tests: 2, passes: 2 })); }); - }) -); + })); [{ name: 'API Blueprint', @@ -238,15 +234,9 @@ const Dredd = require('../../src/dredd'); it('evaluates all the responses as invalid', () => assert.deepInclude(runtimeInfo.dredd.stats, { tests: 4, failures: 4 })); it('prints four warnings for each of the responses', () => - assert.equal(runtimeInfo.dredd.logging.match( - /HTTP 204 and 205 responses must not include a message body/g - ).length, 4) - ); + assert.equal(runtimeInfo.dredd.logging.match(/HTTP 204 and 205 responses must not include a message body/g).length, 4)); it('prints four failures for each non-matching status code', () => - assert.equal(runtimeInfo.dredd.logging.match( - /fail: statusCode: Status code is not/g - ).length, 4) - ); + assert.equal(runtimeInfo.dredd.logging.match(/fail: statusCode: Status code is not/g).length, 4)); it('does not print any failures regarding response bodies', () => assert.isNull(runtimeInfo.dredd.logging.match(/fail: body:/g))); }); @@ -271,20 +261,10 @@ const Dredd = require('../../src/dredd'); it('evaluates all the responses as invalid', () => assert.deepInclude(runtimeInfo.dredd.stats, { tests: 4, failures: 4 })); it('prints two warnings for each of the non-empty expectations', () => - assert.equal(runtimeInfo.dredd.logging.match( - /HTTP 204 and 205 responses must not include a message body/g - ).length, 2) - ); + assert.equal(runtimeInfo.dredd.logging.match(/HTTP 204 and 205 responses must not include a message body/g).length, 2)); it('prints two failures for each non-matching body (and status code)', () => - assert.equal(runtimeInfo.dredd.logging.match( - /fail: body: Real and expected data does not match.\nstatusCode: Status code is not/g - ).length, 2) - ); + assert.equal(runtimeInfo.dredd.logging.match(/fail: body: Real and expected data does not match.\nstatusCode: Status code is not/g).length, 2)); it('prints two failures for each non-matching status code', () => - assert.equal(runtimeInfo.dredd.logging.match( - /fail: statusCode: Status code is not/g - ).length, 2) - ); + assert.equal(runtimeInfo.dredd.logging.match(/fail: statusCode: Status code is not/g).length, 2)); }); - }) -); + })); diff --git a/test/integration/sanitation-test.js b/test/integration/sanitation-test.js index 6ebd35b56..ee902dcb5 100644 --- a/test/integration/sanitation-test.js +++ b/test/integration/sanitation-test.js @@ -75,8 +75,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('emitted test data does not contain request body', () => assert.equal(events[2].test.request.body, '')); it('sensitive data cannot be found anywhere in the emitted test data', () => { const test = JSON.stringify(events); @@ -110,8 +109,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('emitted test data does not contain response body', () => { assert.equal(events[2].test.actual.body, ''); assert.equal(events[2].test.expected.body, ''); @@ -148,8 +146,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('emitted test data does not contain confidential body attribute', () => { const attrs = Object.keys(JSON.parse(events[2].test.request.body)); assert.deepEqual(attrs, ['name']); @@ -186,8 +183,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('emitted test data does not contain confidential body attribute', () => { let attrs = Object.keys(JSON.parse(events[2].test.actual.body)); assert.deepEqual(attrs, ['name']); @@ -227,8 +223,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('emitted test data does contain the sensitive data censored', () => { assert.include(events[2].test.actual.body, '--- CENSORED ---'); assert.include(events[2].test.expected.body, '--- CENSORED ---'); @@ -258,8 +253,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('emitted test data does not contain confidential header', () => { const names = Object.keys(events[2].test.request.headers).map(name => name.toLowerCase()); assert.notInclude(names, sensitiveHeaderName); @@ -297,8 +291,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('emitted test data does not contain confidential header', () => { let names = Object.keys(events[2].test.actual.headers).map(name => name.toLowerCase()); assert.notInclude(names, sensitiveHeaderName); @@ -339,8 +332,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('emitted test data does contain the sensitive data censored', () => assert.include(events[2].test.request.uri, 'CENSORED')); it('sensitive data cannot be found anywhere in the emitted test data', () => assert.notInclude(JSON.stringify(events), sensitiveValue)); it('sensitive data cannot be found anywhere in Dredd output', () => assert.notInclude(dreddRuntimeInfo.logging, sensitiveValue)); @@ -369,8 +361,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('emitted test data does contain the sensitive data censored', () => assert.include(JSON.stringify(events), 'CENSORED')); it('sensitive data cannot be found anywhere in the emitted test data', () => assert.notInclude(JSON.stringify(events), sensitiveValue)); it('sensitive data cannot be found anywhere in Dredd output', () => assert.notInclude(dreddRuntimeInfo.logging, sensitiveValue)); @@ -397,8 +388,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('sensitive data cannot be found anywhere in the emitted test data', () => { const test = JSON.stringify(events); assert.notInclude(test, sensitiveValue); @@ -428,8 +418,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test pass', 'end' - ]) - ); + ])); it('emitted test data does not contain request body', () => assert.equal(events[2].test.request.body, '')); it('sensitive data cannot be found anywhere in the emitted test data', () => { const test = JSON.stringify(events); @@ -463,8 +452,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('emitted test is failed', () => { assert.equal(events[2].test.status, 'fail'); assert.include(events[2].test.results.general.results[0].message.toLowerCase(), 'fail'); @@ -502,8 +490,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('emitted test data does not contain request body', () => assert.equal(events[2].test.request.body, '')); it('emitted test is failed', () => { assert.equal(events[2].test.status, 'fail'); @@ -542,8 +529,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test skip', 'end' - ]) - ); + ])); it('emitted test is skipped', () => { assert.equal(events[2].test.status, 'skip'); assert.deepEqual(Object.keys(events[2].test.results), ['general']); @@ -581,8 +567,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test error', 'end' - ]) - ); + ])); it('sensitive data leak to emitted test data', () => { const test = JSON.stringify(events); assert.include(test, sensitiveKey); @@ -615,8 +600,7 @@ describe('Sanitation of Reported Data', () => { it('emits expected events in expected order', () => assert.deepEqual((Array.from(events).map(event => event.name)), [ 'start', 'test start', 'test fail', 'end' - ]) - ); + ])); it('sensitive data cannot be found anywhere in the emitted test data', () => { const test = JSON.stringify(events); assert.notInclude(test, sensitiveKey); diff --git a/test/unit/add-hooks-test.js b/test/unit/add-hooks-test.js index 765ce6e69..145836f74 100644 --- a/test/unit/add-hooks-test.js +++ b/test/unit/add-hooks-test.js @@ -51,8 +51,7 @@ describe('addHooks(runner, transactions, callback)', () => { assert.strictEqual(runner.hooks, runner.hooks); assert.nestedProperty(runner, 'hooks.transactions'); done(); - }) - ); + })); it('should pass runner.logs to runner.hooks.logs', done => @@ -64,8 +63,7 @@ describe('addHooks(runner, transactions, callback)', () => { assert.isDefined(runner.hooks.logs); assert.strictEqual(runner.hooks.logs, runner.logs); done(); - }) - ); + })); }); @@ -90,8 +88,7 @@ describe('addHooks(runner, transactions, callback)', () => { addHooks(runner, transactions, () => { assert.isOk(globStub.sync.notCalled); done(); - }) - ); + })); }); describe('with non `nodejs` language option', () => { @@ -117,8 +114,7 @@ describe('addHooks(runner, transactions, callback)', () => { if (err) { return done(err); } assert.isTrue(hooksWorkerClientStub.prototype.start.called); done(); - }) - ); + })); }); @@ -154,8 +150,7 @@ describe('addHooks(runner, transactions, callback)', () => { pathStub.resolve(process.cwd(), './test/fixtures/test_hooks.coffee') ]); done(); - }) - ); + })); describe('when files are valid js/coffeescript', () => { runner = null; @@ -181,8 +176,7 @@ describe('addHooks(runner, transactions, callback)', () => { if (err) { return done(err); } assert.isOk(pathStub.resolve.called); done(); - }) - ); + })); it('should add configuration object to the hooks object proxyquired to the each hookfile', done => addHooks(runner, transactions, (err) => { @@ -191,8 +185,7 @@ describe('addHooks(runner, transactions, callback)', () => { const hooksObject = call.args[1].hooks; assert.property(hooksObject, 'configuration'); done(); - }) - ); + })); }); }); @@ -231,32 +224,28 @@ describe('addHooks(runner, transactions, callback)', () => { if (err) { return done(err); } assert.isFalse(proxyquireSpy.called); done(); - }) - ); + })); it('should load files from the filesystem', done => addHooks(runner, transactions, (err) => { if (err) { return done(err); } assert.isTrue(fsStub.readFile.called); done(); - }) - ); + })); it('should run the loaded code', done => addHooks(runner, transactions, (err) => { if (err) { return err; } assert.isTrue(sandboxHooksCodeSpy.called); done(); - }) - ); + })); it('should add hook functions strings to the runner object', done => addHooks(runner, transactions, (err) => { if (err) { return err; } assert.property(runner.hooks.afterHooks, 'Machines > Machines collection > Get Machines'); done(); - }) - ); + })); }); describe('when hookfiles option is not given and hooks are passed as a string from Dredd class', () => { @@ -297,24 +286,21 @@ after('Machines > Machines collection > Get Machines', function(transaction){ if (err) { return done(err); } assert.isFalse(proxyquireSpy.called); done(); - }) - ); + })); it('should run the loaded code', done => addHooks(runner, transactions, (err) => { if (err) { return err; } assert.isTrue(sandboxHooksCodeSpy.called); done(); - }) - ); + })); it('should add hook functions strings to the runner object', done => addHooks(runner, transactions, (err) => { if (err) { return err; } assert.property(runner.hooks.afterHooks, 'Machines > Machines collection > Get Machines'); done(); - }) - ); + })); }); describe('when hooks are passed as a string from Dredd class', () => { @@ -339,8 +325,7 @@ after('Machines > Machines collection > Get Machines', function(transaction){ assert.isDefined(err); assert.include(err.message, 'not implemented'); done(); - }) - ); + })); }); @@ -397,8 +382,7 @@ before(' > Machines collection > Get Machines', function(transaction){ done(); }); }); - }) - ); + })); }); describe('when not sandboxed', () => { diff --git a/test/unit/blueprint-utils-test.js b/test/unit/blueprint-utils-test.js index a7e3232d8..a219145a6 100644 --- a/test/unit/blueprint-utils-test.js +++ b/test/unit/blueprint-utils-test.js @@ -13,16 +13,14 @@ describe('blueprintUtils', () => { const str = 'first\nsecond\nthird lines\ncontent continues'; const position = blueprintUtils.characterIndexToPosition(str.indexOf('lines', str), str); assert.deepEqual(position, { row: 3 }); - }) - ); + })); describe('when given one-line input and zero index', () => it('returns an object with row 1', () => { const str = 'hello\n'; const position = blueprintUtils.characterIndexToPosition(str.indexOf('hello', str), str); assert.deepEqual(position, { row: 1 }); - }) - ); + })); }); describe('warningLocationToRanges()', () => { @@ -102,8 +100,7 @@ describe('blueprintUtils', () => { { start: 10, end: 15 } ]); assert.strictEqual(line, 'lines 2-4, line 8, lines 10-15'); - }) - ); + })); describe('for a real API description document', () => { let warnings = 0; diff --git a/test/unit/config-utils-test.js b/test/unit/config-utils-test.js index 5286e42df..8b0ae9cfc 100644 --- a/test/unit/config-utils-test.js +++ b/test/unit/config-utils-test.js @@ -134,8 +134,7 @@ describe('configUtils', () => { const call = fsStub.writeFileSync.getCall(0); const { args } = call; assert.include(args[0], 'dredd.yml'); - }) - ); + })); describe('when path is given', () => it('should save to that path', () => { @@ -144,8 +143,7 @@ describe('configUtils', () => { const call = fsStub.writeFileSync.getCall(0); const { args } = call; assert.include(args[0], path); - }) - ); + })); }); describe('load(path)', () => { @@ -189,8 +187,7 @@ endpoint: endpoint\ const call = fsStub.readFileSync.getCall(0); const { args } = call; assert.include(args[0], 'dredd.yml'); - }) - ); + })); describe('when path is given', () => it('should load from that path', () => { @@ -199,8 +196,7 @@ endpoint: endpoint\ const call = fsStub.readFileSync.getCall(0); const { args } = call; assert.include(args[0], path); - }) - ); + })); it('should move blueprint and enpoint to an array under _ key', () => { const output = configUtils.load(); diff --git a/test/unit/configuration-test.js b/test/unit/configuration-test.js index d4e454194..e9f409394 100644 --- a/test/unit/configuration-test.js +++ b/test/unit/configuration-test.js @@ -28,15 +28,13 @@ describe('configuration.applyLoggingOptions()', () => { it('resulting configuration should contain \'color\' set to boolean true', () => { const options = configuration.applyLoggingOptions({ color: 'true' }); assert.propertyVal(options, 'color', true); - }) - ); + })); describe('with color option set to legacy \'false\' string value', () => it('resulting configuration should contain \'color\' set to boolean false', () => { const options = configuration.applyLoggingOptions({ color: 'false' }); assert.propertyVal(options, 'color', false); - }) - ); + })); }); describe('configuration.applyConfiguration()', () => { diff --git a/test/unit/dredd-command-test.js b/test/unit/dredd-command-test.js index bb5705ad4..9ee914982 100644 --- a/test/unit/dredd-command-test.js +++ b/test/unit/dredd-command-test.js @@ -113,9 +113,10 @@ describe('DreddCommand class', () => { let hasCalledExit; before(() => { - dc = new DreddCommand({ exit() { - hasCalledExit = true; - } + dc = new DreddCommand({ + exit() { + hasCalledExit = true; + } }); dc.run(); }); @@ -252,8 +253,7 @@ describe('DreddCommand class', () => { describe('when called w/ OR wo/ exiting arguments', () => { describe('--help', () => { before(done => - execCommand({ argv: ['--help'] }, () => done()) - ); + execCommand({ argv: ['--help'] }, () => done())); it('prints out some really nice help text with all options descriptions', () => { assert.include(stderr, 'Usage:'); @@ -265,8 +265,7 @@ describe('DreddCommand class', () => { describe('--version', () => { before(done => - execCommand({ argv: ['--version'] }, () => done()) - ); + execCommand({ argv: ['--version'] }, () => done())); it('prints out version', () => assert.include(stdout, `${packageData.name} v${packageData.version}`)); }); @@ -393,8 +392,7 @@ describe('DreddCommand class', () => { describe('without argv', () => { before(done => - execCommand({ argv: [] }, () => done()) - ); + execCommand({ argv: [] }, () => done())); it('prints out an error message', () => assert.include(stderr, 'Error: Must specify')); }); @@ -480,12 +478,13 @@ describe('DreddCommand class', () => { beforeEach((done) => { sinon.spy(crossSpawnStub, 'spawn'); sinon.stub(transactionRunner.prototype, 'executeAllTransactions').callsFake((transactions, hooks, cb) => cb()); - execCommand({ argv: [ - './test/fixtures/single-get.apib', - `http://127.0.0.1:${PORT}`, - '--server', - 'foo/bar' - ] + execCommand({ + argv: [ + './test/fixtures/single-get.apib', + `http://127.0.0.1:${PORT}`, + '--server', + 'foo/bar' + ] }, () => done()); }); diff --git a/test/unit/dredd-test.js b/test/unit/dredd-test.js index 946157e22..659e4b9aa 100644 --- a/test/unit/dredd-test.js +++ b/test/unit/dredd-test.js @@ -129,8 +129,7 @@ describe('Dredd class', () => { }); beforeEach(() => - sinon.stub(dredd.runner, 'executeTransaction').callsFake((transaction, hooks, callback) => callback()) - ); + sinon.stub(dredd.runner, 'executeTransaction').callsFake((transaction, hooks, callback) => callback())); afterEach(() => dredd.runner.executeTransaction.restore()); @@ -140,16 +139,14 @@ describe('Dredd class', () => { assert.equal(dredd.configuration.files.length, 3); assert.include(dredd.configuration.files, './test/fixtures/multifile/message.apib'); done(); - }) - ); + })); it('should remove globs from config', done => dredd.run((error) => { if (error) { return done(error); } assert.notInclude(dredd.configuration.files, './test/fixtures/multifile/*.apib'); done(); - }) - ); + })); it('should load file contents on paths to config', done => dredd.run((error) => { @@ -160,8 +157,7 @@ describe('Dredd class', () => { assert.property(dredd.configuration.data['./test/fixtures/multifile/greeting.apib'], 'filename'); assert.property(dredd.configuration.data['./test/fixtures/multifile/greeting.apib'], 'raw'); done(); - }) - ); + })); it('should parse loaded files', done => dredd.run((error) => { @@ -171,8 +167,7 @@ describe('Dredd class', () => { assert.property(dredd.configuration.data['./test/fixtures/multifile/greeting.apib'], 'filename'); assert.property(dredd.configuration.data['./test/fixtures/multifile/greeting.apib'], 'raw'); done(); - }) - ); + })); }); @@ -189,8 +184,7 @@ describe('Dredd class', () => { }); beforeEach(() => - sinon.stub(dredd.runner, 'executeTransaction').callsFake((transaction, hooks, callback) => callback()) - ); + sinon.stub(dredd.runner, 'executeTransaction').callsFake((transaction, hooks, callback) => callback())); afterEach(() => dredd.runner.executeTransaction.restore()); @@ -198,8 +192,7 @@ describe('Dredd class', () => { dredd.run((error) => { assert.isOk(error); done(); - }) - ); + })); }); @@ -216,8 +209,7 @@ describe('Dredd class', () => { }); beforeEach(() => - sinon.stub(dredd.runner, 'executeTransaction').callsFake((transaction, hooks, callback) => callback()) - ); + sinon.stub(dredd.runner, 'executeTransaction').callsFake((transaction, hooks, callback) => callback())); afterEach(() => dredd.runner.executeTransaction.restore()); @@ -225,8 +217,7 @@ describe('Dredd class', () => { dredd.run((error) => { assert.isOk(error); done(); - }) - ); + })); }); @@ -270,8 +261,7 @@ GET /url if (error) { return done(error); } assert.lengthOf(dredd.configuration.files, 0); done(); - }) - ); + })); it('should pass data contents to config', done => dredd.run((error) => { @@ -283,8 +273,7 @@ GET /url assert.nestedPropertyVal(dredd, 'configuration.data.testingDirectBlueprintString.filename', 'testingDirectBlueprintString'); assert.nestedProperty(dredd, 'configuration.data.testingDirectBlueprintString.raw'); done(); - }) - ); + })); it('should parse passed data contents', done => dredd.run((error) => { @@ -292,8 +281,7 @@ GET /url assert.nestedProperty(dredd, 'configuration.data.testingDirectObjectFilename.annotations'); assert.nestedProperty(dredd, 'configuration.data.testingDirectBlueprintString.annotations'); done(); - }) - ); + })); describe('and I also set configuration.options.path to an existing file', () => { let localdredd; @@ -323,8 +311,7 @@ GET /url assert.nestedProperty(localdredd, 'configuration.data.testingDirectBlueprintString.raw'); assert.nestedProperty(localdredd, 'configuration.data.testingDirectBlueprintString.annotations'); done(); - }) - ); + })); }); }); @@ -347,16 +334,14 @@ GET /url }); beforeEach(() => - sinon.stub(dredd.runner, 'executeTransaction').callsFake((transaction, hooks, callback) => callback()) - ); + sinon.stub(dredd.runner, 'executeTransaction').callsFake((transaction, hooks, callback) => callback())); afterEach(() => dredd.runner.executeTransaction.restore()); describe('when all URLs can be downloaded', () => { before(() => // eslint-disable-next-line - sinon.stub(requestStub, 'get').callsFake((receivedArgs = {}, cb) => cb(null, { statusCode: 200 }, blueprintCode)) - ); + sinon.stub(requestStub, 'get').callsFake((receivedArgs = {}, cb) => cb(null, { statusCode: 200 }, blueprintCode))); after(() => requestStub.get.restore()); @@ -372,16 +357,14 @@ GET /url './test/fixtures/multifile/name.apib' ]); done(); - }) - ); + })); it('should remove globs from config', done => dredd.run((error) => { if (error) { return done(error); } assert.notInclude(dredd.configuration.files, './test/fixtures/multifile/*.apib'); done(); - }) - ); + })); it('should load file contents on paths to config and parse these files', done => dredd.run((error) => { @@ -416,8 +399,7 @@ GET /url assert.property(dredd.configuration.data['https://another.path.to/apiary.apib'], 'raw'); assert.property(dredd.configuration.data['https://another.path.to/apiary.apib'], 'annotations'); done(); - }) - ); + })); }); describe('when an URL for one API description document returns 404 not-found', () => { @@ -427,8 +409,7 @@ GET /url return cb(null, { statusCode: 404 }, 'Page Not Found'); } cb(null, { statusCode: 200 }, blueprintCode); - }) - ); + })); after(() => requestStub.get.restore()); @@ -439,15 +420,13 @@ GET /url assert.property(error, 'message'); assert.include(error.message, 'Unable to load file from URL'); done(); - }) - ); + })); it('should not execute any transaction', done => dredd.run(() => { assert.notOk(dredd.runner.executeTransaction.called); done(); - }) - ); + })); }); describe('when an URL for one API description document is unreachable (erroneous)', () => { @@ -458,8 +437,7 @@ GET /url return cb({ code: 'ENOTFOUND' }); } cb(null, { statusCode: 200 }, blueprintCode); - }) - ); + })); after(() => requestStub.get.restore()); @@ -470,15 +448,13 @@ GET /url assert.property(error, 'message'); assert.include(error.message, 'Error when loading file from URL'); done(); - }) - ); + })); it('should not execute any transaction', done => dredd.run(() => { assert.notOk(dredd.runner.executeTransaction.called); done(); - }) - ); + })); }); }); }); @@ -496,8 +472,7 @@ GET /url }); beforeEach(() => - sinon.stub(dredd.runner, 'executeTransaction').callsFake((transaction, hooks, callback) => callback()) - ); + sinon.stub(dredd.runner, 'executeTransaction').callsFake((transaction, hooks, callback) => callback())); afterEach(() => dredd.runner.executeTransaction.restore()); @@ -505,15 +480,13 @@ GET /url dredd.run((error) => { assert.isOk(error); done(); - }) - ); + })); it('should NOT execute any transaction', done => dredd.run(() => { assert.notOk(dredd.runner.executeTransaction.called); done(); - }) - ); + })); }); describe('when API description document parsing warning', () => { @@ -542,15 +515,13 @@ GET /url dredd.run(() => { assert.isOk(dredd.runner.run.called); done(); - }) - ); + })); it('should write warnings to warn logger', done => dredd.run(() => { assert.isOk(loggerStub.warn.called); done(); - }) - ); + })); }); describe('when non existing API description document path', () => { @@ -572,15 +543,13 @@ GET /url dredd.run((error) => { assert.isOk(error); done(); - }) - ); + })); it('should NOT execute any transaction', done => dredd.run(() => { assert.notOk(dredd.runner.executeTransaction.called); done(); - }) - ); + })); }); describe('when runtime contains any error', () => { @@ -603,15 +572,13 @@ GET /url dredd.run(() => { assert.notOk(dredd.runner.executeTransaction.called); done(); - }) - ); + })); it('should exit with an error', done => dredd.run((error) => { assert.isOk(error); done(); - }) - ); + })); }); describe('when runtime contains any warning', () => { @@ -637,22 +604,19 @@ GET /url dredd.run(() => { assert.isOk(dredd.runner.executeTransaction.called); done(); - }) - ); + })); it('should print runtime warnings to stdout', done => dredd.run(() => { assert.isOk(loggerStub.warn.called); done(); - }) - ); + })); it('should not exit', done => dredd.run((error) => { assert.notOk(error); done(); - }) - ); + })); }); describe('when runtime is without errors and warnings', () => { @@ -674,8 +638,7 @@ GET /url dredd.run(() => { assert.isOk(dredd.runner.executeTransaction.called); done(); - }) - ); + })); }); describe('#emitStart', () => { @@ -710,8 +673,7 @@ GET /url _id: '1234_id', testRunId: '6789_testRunId', reportUrl: 'http://url.me/test/run/1234_id' - }) - ); + })); apiary.all('*', (req, res) => res.json({})); @@ -719,8 +681,7 @@ GET /url }); afterEach(done => - apiaryServer.close(() => done()) - ); + apiaryServer.close(() => done())); it('should call the callback', (done) => { @@ -774,8 +735,7 @@ GET /url dredd.emitStart(() => { assert.isTrue(errorLogger.called); done(); - }) - ); + })); }); }); @@ -793,10 +753,10 @@ GET /url afterEach(() => delete process.env.http_proxy); it('logs about the setting', () => - assert.include(verboseLogger.lastCall.args[0], + assert.include( + verboseLogger.lastCall.args[0], 'HTTP(S) proxy specified by environment variables: http_proxy=http://proxy.example.com' - ) - ); + )); }); describe('when the proxy is set by uppercase environment variable', () => { @@ -807,11 +767,11 @@ GET /url afterEach(() => delete process.env.HTTPS_PROXY); it('logs about the setting', () => - assert.include(verboseLogger.lastCall.args[0], + assert.include( + verboseLogger.lastCall.args[0], 'HTTP(S) proxy specified by environment variables: ' + 'HTTPS_PROXY=http://proxy.example.com' - ) - ); + )); }); describe('when NO_PROXY environment variable is set', () => { @@ -826,12 +786,12 @@ GET /url }); it('logs about the setting', () => - assert.include(verboseLogger.lastCall.args[0], + assert.include( + verboseLogger.lastCall.args[0], 'HTTP(S) proxy specified by environment variables: ' + 'HTTPS_PROXY=http://proxy.example.com, ' + 'NO_PROXY=whitelisted.example.com' - ) - ); + )); }); describe('when DUMMY_PROXY environment variable is set', () => { @@ -846,11 +806,11 @@ GET /url }); it('is ignored', () => - assert.include(verboseLogger.lastCall.args[0], + assert.include( + verboseLogger.lastCall.args[0], 'HTTP(S) proxy specified by environment variables: ' + 'NO_PROXY=whitelisted.example.com' - ) - ); + )); }); }); }); diff --git a/test/unit/handle-runtime-problems-test.js b/test/unit/handle-runtime-problems-test.js index 8c314e486..7ee806af9 100644 --- a/test/unit/handle-runtime-problems-test.js +++ b/test/unit/handle-runtime-problems-test.js @@ -6,7 +6,8 @@ const dreddTransactions = require('dredd-transactions'); const logger = require('../../src/logger'); -const handleRuntimeProblems = proxyquire('../../src/handle-runtime-problems', +const handleRuntimeProblems = proxyquire( + '../../src/handle-runtime-problems', { './logger': logger } ); @@ -53,8 +54,7 @@ FORMAT: 1A if (err) { return done(err); } error = handleRuntimeProblems(data); done(); - }) - ); + })); it('returns error', () => assert.isOk(error)); it('has no warning output', () => assert.equal(warnOutput, '')); @@ -85,8 +85,7 @@ FORMAT: 1A if (err) { return done(err); } error = handleRuntimeProblems(data); done(); - }) - ); + })); it('returns no error', () => assert.notOk(error)); it('has no error output', () => assert.equal(errorOutput, '')); @@ -114,8 +113,7 @@ So Long, and Thanks for All the Fish!\ if (err) { return done(err); } error = handleRuntimeProblems(data); done(); - }) - ); + })); it('returns no error', () => assert.notOk(error)); it('has no error output', () => assert.equal(errorOutput, '')); diff --git a/test/unit/hooks-test.js b/test/unit/hooks-test.js index 20b294c64..77d95d763 100644 --- a/test/unit/hooks-test.js +++ b/test/unit/hooks-test.js @@ -191,8 +191,7 @@ describe('Hooks', () => { const value = object[property][key]; assert.isString(value, `on ${property}['${key}']`); }); - }) - ); + })); }); properties = [ diff --git a/test/unit/hooks-worker-client-test.js b/test/unit/hooks-worker-client-test.js index c7a7cfc61..544c1c569 100644 --- a/test/unit/hooks-worker-client-test.js +++ b/test/unit/hooks-worker-client-test.js @@ -86,13 +86,15 @@ describe('Hooks worker client', () => { // finishes, so we need to manually stop it. However, it could happen // we'll stop it before it actually manages to do what we test here, so // we add some timeout here. - setTimeout(() => - hooksWorkerClient.stop((stopError) => { - if (stopError) { return done(stopError); } - assert.include(logs, 'Hooks handler stdout: standard output text\n'); - done(); - }) - , MIN_COMMAND_EXECUTION_DURATION_MS); + setTimeout( + () => + hooksWorkerClient.stop((stopError) => { + if (stopError) { return done(stopError); } + assert.include(logs, 'Hooks handler stdout: standard output text\n'); + done(); + }) + , MIN_COMMAND_EXECUTION_DURATION_MS + ); }); }); @@ -105,14 +107,16 @@ describe('Hooks worker client', () => { // finishes, so we need to manually stop it. However, it could happen // we'll stop it before it actually manages to do what we test here, so // we add some timeout here. - setTimeout(() => - hooksWorkerClient.stop((stopError) => { - if (stopError) { return done(stopError); } - assert.include(logs, 'Hooks handler stderr: error output text\n'); - done(); - }) - - , MIN_COMMAND_EXECUTION_DURATION_MS); + setTimeout( + () => + hooksWorkerClient.stop((stopError) => { + if (stopError) { return done(stopError); } + assert.include(logs, 'Hooks handler stderr: error output text\n'); + done(); + }) + + , MIN_COMMAND_EXECUTION_DURATION_MS + ); }); }); @@ -126,13 +130,15 @@ describe('Hooks worker client', () => { // finishes, so we need to manually stop it. However, it could happen // we'll stop it before it actually manages to do what we test here, so // we add some timeout here. - setTimeout(() => - hooksWorkerClient.stop((stopError) => { - if (stopError) { return done(stopError); } - assert.isNull(runner.hookHandlerError); - done(); - }) - , MIN_COMMAND_EXECUTION_DURATION_MS); + setTimeout( + () => + hooksWorkerClient.stop((stopError) => { + if (stopError) { return done(stopError); } + assert.isNull(runner.hookHandlerError); + done(); + }) + , MIN_COMMAND_EXECUTION_DURATION_MS + ); }); }); @@ -145,14 +151,16 @@ describe('Hooks worker client', () => { // finishes, so we need to manually stop it. However, it could happen // we'll stop it before it actually manages to do what we test here, so // we add some timeout here. - setTimeout(() => - hooksWorkerClient.stop((stopError) => { - if (stopError) { return done(stopError); } - assert.isOk(runner.hookHandlerError); - assert.include(runner.hookHandlerError.message, '3'); - done(); - }) - , MIN_COMMAND_EXECUTION_DURATION_MS); + setTimeout( + () => + hooksWorkerClient.stop((stopError) => { + if (stopError) { return done(stopError); } + assert.isOk(runner.hookHandlerError); + assert.include(runner.hookHandlerError.message, '3'); + done(); + }) + , MIN_COMMAND_EXECUTION_DURATION_MS + ); }); }); @@ -170,8 +178,7 @@ describe('Hooks worker client', () => { assert.isOk(err); assert.include(err.message, 'native Node.js hooks instead'); done(); - }) - ); + })); }); describe('when --language=ruby option is given and the worker is installed', () => { @@ -213,8 +220,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[0], 'dredd-hooks-ruby'); done(); }); - }) - ); + })); it('should pass --hookfiles option as an array of arguments', done => loadWorkerClient((err) => { @@ -225,8 +231,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[1][0], 'somefile.rb'); done(); }); - }) - ); + })); }); describe('when --language=ruby option is given and the worker is not installed', () => { @@ -249,8 +254,7 @@ describe('Hooks worker client', () => { assert.isOk(err); assert.include(err.message, 'gem install dredd_hooks'); done(); - }) - ); + })); }); describe('when --language=python option is given and the worker is installed', () => { @@ -292,8 +296,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[0], 'dredd-hooks-python'); done(); }); - }) - ); + })); it('should pass --hookfiles option as an array of arguments', done => loadWorkerClient((err) => { @@ -304,8 +307,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[1][0], 'somefile.py'); done(); }); - }) - ); + })); }); describe('when --language=python option is given and the worker is not installed', () => { @@ -327,8 +329,7 @@ describe('Hooks worker client', () => { assert.isOk(err); assert.include(err.message, 'pip install dredd_hooks'); done(); - }) - ); + })); }); describe('when --language=php option is given and the worker is installed', () => { @@ -370,8 +371,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[0], 'dredd-hooks-php'); done(); }); - }) - ); + })); it('should pass --hookfiles option as an array of arguments', done => loadWorkerClient((err) => { @@ -382,8 +382,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[1][0], 'somefile.py'); done(); }); - }) - ); + })); }); describe('when --language=php option is given and the worker is not installed', () => { @@ -405,8 +404,7 @@ describe('Hooks worker client', () => { assert.isOk(err); assert.include(err.message, 'composer require ddelnano/dredd-hooks-php --dev'); done(); - }) - ); + })); }); describe('when --language=go option is given and the worker is not installed', () => { @@ -438,8 +436,7 @@ describe('Hooks worker client', () => { assert.isOk(err); assert.include(err.message, 'go get github.com/snikch/goodman/cmd/goodman'); done(); - }) - ); + })); }); describe('when --language=go option is given and the worker is installed', () => { @@ -492,8 +489,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[0], path.join(dummyPath, 'goodman')); done(); }); - }) - ); + })); it('should pass --hookfiles option as an array of arguments', done => loadWorkerClient((err) => { @@ -504,8 +500,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[1][0], 'gobinary'); done(); }); - }) - ); + })); }); describe('when --language=rust option is given and the worker is not installed', () => { @@ -526,8 +521,7 @@ describe('Hooks worker client', () => { assert.isOk(err); assert.include(err.message, 'cargo install dredd-hooks'); done(); - }) - ); + })); }); describe('when --language=rust option is given and the worker is installed', () => { @@ -569,8 +563,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[0], 'dredd-hooks-rust'); done(); }); - }) - ); + })); it('should pass --hookfiles option as an array of arguments', done => loadWorkerClient((err) => { @@ -581,8 +574,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[1][0], 'rustbinary'); done(); }); - }) - ); + })); }); describe('when --language=perl option is given and the worker is installed', () => { @@ -624,8 +616,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[0], 'dredd-hooks-perl'); done(); }); - }) - ); + })); it('should pass --hookfiles option as an array of arguments', done => loadWorkerClient((err) => { @@ -636,8 +627,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[1][0], 'somefile.py'); done(); }); - }) - ); + })); }); describe('when --language=perl option is given and the worker is not installed', () => { @@ -659,8 +649,7 @@ describe('Hooks worker client', () => { assert.isOk(err); assert.include(err.message, 'cpanm Dredd::Hooks'); done(); - }) - ); + })); }); describe('when --language=./any/other-command is given', () => { @@ -702,8 +691,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[0], './my-fancy-command'); done(); }); - }) - ); + })); it('should pass --hookfiles option as an array of arguments', done => loadWorkerClient((err) => { @@ -714,8 +702,7 @@ describe('Hooks worker client', () => { assert.equal(crossSpawnStub.spawn.getCall(0).args[1][0], 'someotherfile'); done(); }); - }) - ); + })); }); describe('after loading', () => { @@ -894,7 +881,9 @@ describe('Hooks worker client', () => { describe('when hook handler server is running and modifying transactions', () => { let transaction = { name: 'API > Hello > World', - request: { method: 'POST', uri: '/message', headers: {}, body: 'Hello World!' } + request: { + method: 'POST', uri: '/message', headers: {}, body: 'Hello World!' + } }; return [ @@ -945,8 +934,7 @@ describe('Hooks worker client', () => { // got back from the hook handler, it triggers this event hooksWorkerClient.emitter.on(messageIn.uuid, () => // -- 7 -- - done() - ); + done()); // -- 5 --, modifying the transaction transaction = getFirstTransaction(messageIn.data); diff --git a/test/unit/interactive-config-test.js b/test/unit/interactive-config-test.js index a31eaf161..4d273a850 100644 --- a/test/unit/interactive-config-test.js +++ b/test/unit/interactive-config-test.js @@ -24,8 +24,7 @@ describe('interactiveConfig', () => { assert.isTrue(inquirerStub.prompt.called); done(); }); - }) - ); + })); }); describe('.processAnswers(config, answers, callback)', () => { @@ -57,8 +56,7 @@ describe('interactiveConfig', () => { interactiveConfig.processAnswers(config, answers, () => { object = config; done(); - }) - ); + })); it('should have properties set from the config on proper places', () => { assert.equal(object._[0], 'apiary.apib'); @@ -98,8 +96,7 @@ describe('interactiveConfig', () => { interactiveConfig.processAnswers(config, answers, () => { object = config; done(); - }) - ); + })); it('should have properties set from the config on proper places', () => { assert.equal(object._[0], 'apiary.apib'); @@ -114,8 +111,7 @@ describe('interactiveConfig', () => { }); describe('.run(config, callback)', () => - it('is a defined function', () => assert.isFunction(interactiveConfig.run)) - ); + it('is a defined function', () => assert.isFunction(interactiveConfig.run))); describe('.updateCircle()', () => { diff --git a/test/unit/prettify-response-test.js b/test/unit/prettify-response-test.js index 7bd930fe1..40557f712 100644 --- a/test/unit/prettify-response-test.js +++ b/test/unit/prettify-response-test.js @@ -12,7 +12,8 @@ describe('prettifyResponse(response)', () => { 'content-type': 'application/json' }, body: - { a: 'b' } }); + { a: 'b' } + }); const expectedOutput = `\ headers: \n content-type: application/json\n diff --git a/test/unit/reporters/apiary-reporter-test.js b/test/unit/reporters/apiary-reporter-test.js index d709f346e..6d61e204d 100644 --- a/test/unit/reporters/apiary-reporter-test.js +++ b/test/unit/reporters/apiary-reporter-test.js @@ -225,8 +225,7 @@ describe('ApiaryReporter', () => { assert.isOk(loggerStub.verbose.calledWithMatch('POST https://api.example.com:1234/ (without body)')); done(); }); - }) - ); + })); describe('when provided with non-root path', () => it('should use API URL without double slashes', (done) => { @@ -236,8 +235,7 @@ describe('ApiaryReporter', () => { assert.isOk(loggerStub.verbose.calledWithMatch('POST https://api.example.com:1234/hello?q=1 (without body)')); done(); }); - }) - ); + })); }); describe('when server is not available', () => { @@ -381,8 +379,7 @@ describe('ApiaryReporter', () => { assert.isFalse(call.isDone()); done(); }); - }) - ); + })); }); describe('when adding passing test', () => { @@ -449,8 +446,7 @@ describe('ApiaryReporter', () => { assert.isFalse(call.isDone()); done(); }); - }) - ); + })); }); describe('when adding failing test', () => { @@ -485,8 +481,7 @@ describe('ApiaryReporter', () => { assert.isFalse(call.isDone()); done(); }); - }) - ); + })); }); describe('when adding skipped test', () => { @@ -544,8 +539,7 @@ describe('ApiaryReporter', () => { assert.isFalse(call.isDone()); done(); }); - }) - ); + })); }); @@ -610,8 +604,10 @@ describe('ApiaryReporter', () => { error.code = errType; emitter.emit('test error', error, test, () => { assert.isArray(JSON.parse(requestBody).resultData.result.general); - assert.include(JSON.parse(requestBody).resultData.result.general.map(value => JSON.stringify(value)).join(), - 'Error connecting to server under test!'); + assert.include( + JSON.parse(requestBody).resultData.result.general.map(value => JSON.stringify(value)).join(), + 'Error connecting to server under test!' + ); done(); }); }); @@ -648,8 +644,10 @@ describe('ApiaryReporter', () => { const error = new Error('some error'); emitter.emit('test error', error, test, () => { assert.isArray(JSON.parse(requestBody).resultData.result.general); - assert.include(JSON.parse(requestBody).resultData.result.general.map(value => JSON.stringify(value)).join(), - 'Unhandled error occured when executing the transaction.'); + assert.include( + JSON.parse(requestBody).resultData.result.general.map(value => JSON.stringify(value)).join(), + 'Unhandled error occured when executing the transaction.' + ); done(); }); }); @@ -667,8 +665,7 @@ describe('ApiaryReporter', () => { assert.isFalse(call.isDone()); done(); }); - }) - ); + })); }); describe('when ending', () => { @@ -747,8 +744,7 @@ describe('ApiaryReporter', () => { assert.isFalse(call.isDone()); done(); }); - }) - ); + })); }); }); diff --git a/test/unit/reporters/base-reporter-test.js b/test/unit/reporters/base-reporter-test.js index c064d4966..ebfd81a61 100644 --- a/test/unit/reporters/base-reporter-test.js +++ b/test/unit/reporters/base-reporter-test.js @@ -39,8 +39,7 @@ describe('BaseReporter', () => { emitter.emit('start', '', () => { assert.isOk(stats.start); done(); - }) - ); + })); }); describe('when ending', () => { @@ -52,8 +51,7 @@ describe('BaseReporter', () => { emitter.emit('end', () => { assert.isOk(stats.end); done(); - }) - ); + })); }); describe('when test starts', () => { diff --git a/test/unit/reporters/cli-reporter-test.js b/test/unit/reporters/cli-reporter-test.js index 8b2b9972b..a53b31fd9 100644 --- a/test/unit/reporters/cli-reporter-test.js +++ b/test/unit/reporters/cli-reporter-test.js @@ -156,9 +156,7 @@ describe('CliReporter', () => { const messages = Object.keys(loggerStub.error.args).map((value, index) => loggerStub.error.args[index][0]); assert.include(messages.join(), 'Error connecting'); - }) - ) - ); + }))); }); describe('when adding skipped test', () => { @@ -205,8 +203,7 @@ describe('CliReporter', () => { assert.isOk(loggerStub.complete.calledTwice); done(); }); - }) - ); + })); describe('when there are no tests', () => @@ -217,7 +214,6 @@ describe('CliReporter', () => { assert.isOk(loggerStub.complete.calledOnce); done(); }); - }) - ); + })); }); }); diff --git a/test/unit/reporters/dot-reporter-test.js b/test/unit/reporters/dot-reporter-test.js index 89c8fffce..0ed4f35e3 100644 --- a/test/unit/reporters/dot-reporter-test.js +++ b/test/unit/reporters/dot-reporter-test.js @@ -43,8 +43,7 @@ describe('DotReporter', () => { afterEach(() => loggerStub.info.restore()); it('should log that testing has begun', () => - emitter.emit('start', '', () => assert.isOk(loggerStub.info.called)) - ); + emitter.emit('start', '', () => assert.isOk(loggerStub.info.called))); }); describe('when ending', () => { @@ -60,8 +59,7 @@ describe('DotReporter', () => { }); it('should log that testing is complete', () => - emitter.emit('end', () => assert.isOk(loggerStub.complete.calledTwice)) - ); + emitter.emit('end', () => assert.isOk(loggerStub.complete.calledTwice))); describe('when there are failures', () => { before(() => { @@ -84,8 +82,7 @@ describe('DotReporter', () => { emitter.emit('end', () => { assert.isOk(loggerStub.fail.called); done(); - }) - ); + })); }); }); diff --git a/test/unit/reporters/html-reporter-test.js b/test/unit/reporters/html-reporter-test.js index f959255fe..e7d937615 100644 --- a/test/unit/reporters/html-reporter-test.js +++ b/test/unit/reporters/html-reporter-test.js @@ -75,8 +75,7 @@ describe('HtmlReporter', () => { emitter.emit('start', '', () => { assert.isOk(~htmlReporter.buf.indexOf('Dredd')); done(); - }) - ); + })); }); describe('when ending', () => { @@ -98,8 +97,7 @@ describe('HtmlReporter', () => { assert.isOk(fsExtraStub.mkdirp.called); assert.isOk(fsStub.writeFile.called); done(); - }) - ); + })); }); describe('when cannot create output directory', () => { @@ -121,8 +119,7 @@ describe('HtmlReporter', () => { assert.isOk(fsStub.writeFile.notCalled); assert.isOk(loggerStub.error.called); done(); - }) - ); + })); }); }); @@ -146,8 +143,7 @@ describe('HtmlReporter', () => { htmlReporter.details = true; emitter.emit('test pass', test); assert.isOk(~htmlReporter.buf.indexOf('Request')); - }) - ); + })); }); describe('when test is skipped', () => { diff --git a/test/unit/reporters/markdown-reporter-test.js b/test/unit/reporters/markdown-reporter-test.js index 6766fbc80..d05c8ab0c 100644 --- a/test/unit/reporters/markdown-reporter-test.js +++ b/test/unit/reporters/markdown-reporter-test.js @@ -82,9 +82,7 @@ describe('MarkdownReporter', () => { emitter.emit('start', '', () => { assert.isOk(~mdReporter.buf.indexOf('Dredd')); done(); - }) - ) - ); + }))); describe('when ending', () => { describe('when can create output directory', () => { @@ -125,8 +123,7 @@ describe('MarkdownReporter', () => { assert.isOk(fsStub.writeFile.notCalled); assert.isOk(loggerStub.error.called); done(); - }) - ); + })); }); }); @@ -152,8 +149,7 @@ describe('MarkdownReporter', () => { emitter.emit('test pass', test); assert.isOk(~mdReporter.buf.indexOf('Request')); done(); - }) - ); + })); }); describe('when test is skipped', () => { diff --git a/test/unit/reporters/nyan-reporter-test.js b/test/unit/reporters/nyan-reporter-test.js index 17a0b414c..1abe796fc 100644 --- a/test/unit/reporters/nyan-reporter-test.js +++ b/test/unit/reporters/nyan-reporter-test.js @@ -54,8 +54,7 @@ describe('NyanCatReporter', () => { assert.isOk(nyanReporter.cursorHide.calledOnce); assert.isOk(nyanReporter.draw.calledOnce); done(); - }) - ); + })); }); describe('when ending', () => { @@ -75,8 +74,7 @@ describe('NyanCatReporter', () => { emitter.emit('end', () => { assert.isOk(loggerStub.complete.calledTwice); done(); - }) - ); + })); describe('when there are failures', () => { beforeEach(() => { @@ -95,8 +93,7 @@ describe('NyanCatReporter', () => { emitter.emit('end', () => { assert.isOk(loggerStub.fail.calledTwice); done(); - }) - ); + })); }); }); diff --git a/test/unit/reporters/x-unit-reporter-test.js b/test/unit/reporters/x-unit-reporter-test.js index 83eefcbea..43987e3d2 100644 --- a/test/unit/reporters/x-unit-reporter-test.js +++ b/test/unit/reporters/x-unit-reporter-test.js @@ -148,8 +148,7 @@ describe('XUnitReporter', () => { assert.isOk(fsStub.writeFile.called); done(); }); - }) - ); + })); }); describe('when there are no tests', () => @@ -161,8 +160,7 @@ describe('XUnitReporter', () => { assert.isOk(fsStub.writeFile.called); done(); }); - }) - ); + })); }); describe('when test passes', () => { @@ -213,8 +211,7 @@ describe('XUnitReporter', () => { emitter.emit('test start', test); emitter.emit('test pass', test); assert.isOk(fsStub.appendFileSync.called); - }) - ); + })); }); describe('when test is skipped', () => { diff --git a/test/unit/resolve-hookfiles-test.js b/test/unit/resolve-hookfiles-test.js index f1fd19311..30b7d409e 100644 --- a/test/unit/resolve-hookfiles-test.js +++ b/test/unit/resolve-hookfiles-test.js @@ -10,8 +10,7 @@ describe('resolveHookfiles()', () => { it('produces no results', () => { const paths = resolveHookfiles([], cwd); assert.deepEqual(paths, []); - }) - ); + })); describe('when given existing absolute filenames', () => it('resolves them into absolute paths', () => { @@ -21,8 +20,7 @@ describe('resolveHookfiles()', () => { ]; const paths = resolveHookfiles(hookfiles, cwd); assert.deepEqual(paths, hookfiles); - }) - ); + })); describe('when given existing relative filenames', () => it('resolves them into absolute paths', () => { @@ -31,17 +29,14 @@ describe('resolveHookfiles()', () => { path.join(cwd, 'hooks.js'), path.join(cwd, 'non-js-hooks.rb') ]); - }) - ); + })); describe('when given non-existing filenames', () => it('throws an error', () => assert.throws( () => resolveHookfiles(['./hooks.js', './foo/bar/42'], cwd) , './foo/bar/42' - ) - ) - ); + ))); describe('when given glob pattern resolving to existing files', () => it('resolves them into absolute paths', () => { @@ -49,17 +44,14 @@ describe('resolveHookfiles()', () => { assert.deepEqual(paths, [ path.join(cwd, 'hooks.js') ]); - }) - ); + })); describe('when given glob pattern resolving to no files', () => it('throws an error', () => assert.throws( () => resolveHookfiles(['./**/hooks.js', './**/foo/bar/foobar.js'], cwd) , './**/foo/bar/foobar.js' - ) - ) - ); + ))); describe('when given both globs and filenames', () => { it('resolves them into absolute paths', () => { @@ -74,15 +66,13 @@ describe('resolveHookfiles()', () => { assert.throws( () => resolveHookfiles(['./**/hooks.js', './foo/bar/42'], cwd) , './foo/bar/42' - ) - ); + )); it('throws an error on globs resolving to no files', () => assert.throws( () => resolveHookfiles(['./hooks.js', './**/foo/bar/foobar.js'], cwd) , './**/foo/bar/foobar.js' - ) - ); + )); it('returns the absolute paths alphabetically sorted', () => { const paths = resolveHookfiles([ diff --git a/test/unit/sandbox-hooks-code-test.js b/test/unit/sandbox-hooks-code-test.js index 272617a0e..1338040a1 100644 --- a/test/unit/sandbox-hooks-code-test.js +++ b/test/unit/sandbox-hooks-code-test.js @@ -12,8 +12,7 @@ describe('sandboxHooksCode(hooksCode, callback)', () => { assert.include(err, 'sandbox'); done(); }); - }) - ); + })); describe('context of code adding hooks', () => { it('should not have access to this context', (done) => { diff --git a/test/unit/transaction-runner-test.js b/test/unit/transaction-runner-test.js index 275c83152..9a1427aae 100644 --- a/test/unit/transaction-runner-test.js +++ b/test/unit/transaction-runner-test.js @@ -78,8 +78,7 @@ describe('TransactionRunner', () => { runner.config(configuration); assert.notOk(runner.multiBlueprint); - }) - ); + })); describe('when multiple files in data are present', () => it('should set multiBlueprint to true', () => { @@ -99,8 +98,7 @@ describe('TransactionRunner', () => { runner.config(configuration); assert.isOk(runner.multiBlueprint); - }) - ); + })); }); describe('configureTransaction(transaction)', () => { @@ -145,67 +143,93 @@ describe('TransactionRunner', () => { [{ description: 'is hostname', input: { serverUrl: 'https://127.0.0.1:8000', requestPath: '/hello' }, - expected: { host: '127.0.0.1', port: '8000', protocol: 'https:', fullPath: '/hello' } + expected: { + host: '127.0.0.1', port: '8000', protocol: 'https:', fullPath: '/hello' + } }, { description: 'is IPv4', input: { serverUrl: 'https://127.0.0.1:8000', requestPath: '/hello' }, - expected: { host: '127.0.0.1', port: '8000', protocol: 'https:', fullPath: '/hello' } + expected: { + host: '127.0.0.1', port: '8000', protocol: 'https:', fullPath: '/hello' + } }, { description: 'has path', input: { serverUrl: 'http://127.0.0.1:8000/v1', requestPath: '/hello' }, - expected: { host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1/hello' } + expected: { + host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1/hello' + } }, { description: 'has path with trailing slash', input: { serverUrl: 'http://127.0.0.1:8000/v1/', requestPath: '/hello' }, - expected: { host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1/hello' } + expected: { + host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1/hello' + } }, { description: 'has path and request path is /', input: { serverUrl: 'http://127.0.0.1:8000/v1', requestPath: '/' }, - expected: { host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1/' } + expected: { + host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1/' + } }, { description: 'has path with trailing slash and request path is /', input: { serverUrl: 'http://127.0.0.1:8000/v1/', requestPath: '/' }, - expected: { host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1/' } + expected: { + host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1/' + } }, { description: 'has path and request has no path', input: { serverUrl: 'http://127.0.0.1:8000/v1', requestPath: '' }, - expected: { host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1' } + expected: { + host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1' + } }, { description: 'has path with trailing slash and request has no path', input: { serverUrl: 'http://127.0.0.1:8000/v1/', requestPath: '' }, - expected: { host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1/' } + expected: { + host: '127.0.0.1', port: '8000', protocol: 'http:', fullPath: '/v1/' + } }, { description: 'is hostname with no protocol', input: { serverUrl: '127.0.0.1', requestPath: '/hello' }, - expected: { host: '127.0.0.1', port: null, protocol: 'http:', fullPath: '/hello' } + expected: { + host: '127.0.0.1', port: null, protocol: 'http:', fullPath: '/hello' + } }, { description: 'is IPv4 with no protocol', input: { serverUrl: '127.0.0.1:4000', requestPath: '/hello' }, - expected: { host: '127.0.0.1', port: '4000', protocol: 'http:', fullPath: '/hello' } + expected: { + host: '127.0.0.1', port: '4000', protocol: 'http:', fullPath: '/hello' + } }, { description: 'is hostname with // instead of protocol', input: { serverUrl: '//127.0.0.1', requestPath: '/hello' }, - expected: { host: '127.0.0.1', port: null, protocol: 'http:', fullPath: '/hello' } + expected: { + host: '127.0.0.1', port: null, protocol: 'http:', fullPath: '/hello' + } }, { description: 'is hostname with trailing slash', input: { serverUrl: 'http://127.0.0.1/', requestPath: '/hello' }, - expected: { host: '127.0.0.1', port: null, protocol: 'http:', fullPath: '/hello' } + expected: { + host: '127.0.0.1', port: null, protocol: 'http:', fullPath: '/hello' + } }, { description: 'is hostname with no protocol and with trailing slash', input: { serverUrl: '127.0.0.1/', requestPath: '/hello' }, - expected: { host: '127.0.0.1', port: null, protocol: 'http:', fullPath: '/hello' } + expected: { + host: '127.0.0.1', port: null, protocol: 'http:', fullPath: '/hello' + } } ].forEach(({ description, input, expected }) => @@ -228,10 +252,8 @@ describe('TransactionRunner', () => { port: configuredTransaction.port, protocol: configuredTransaction.protocol, fullPath: configuredTransaction.fullPath - }, expected) - ); - }) - ); + }, expected)); + })); }); describe('when processing Swagger document and given transaction has non-2xx status code', () => { @@ -252,8 +274,7 @@ describe('TransactionRunner', () => { }); it('skips the transaction by default', () => assert.isTrue(configuredTransaction.skip)); - }) - ); + })); }); describe('when processing Swagger document and given transaction has 2xx status code', () => { @@ -274,8 +295,7 @@ describe('TransactionRunner', () => { }); it('does not skip the transaction by default', () => assert.isFalse(configuredTransaction.skip)); - }) - ); + })); }); describe('when processing other than Swagger document and given transaction has non-2xx status code', () => { @@ -301,24 +321,21 @@ describe('TransactionRunner', () => { runner.multiBlueprint = true; const configuredTransaction = runner.configureTransaction(transaction); assert.include(configuredTransaction.name, 'Machines API'); - }) - ); + })); describe('when processing only single API description document', () => it('should not include api name in the transaction name', () => { runner.multiBlueprint = false; const configuredTransaction = runner.configureTransaction(transaction); assert.notInclude(configuredTransaction.name, 'Machines API'); - }) - ); + })); describe('when request does not have User-Agent', () => it('should add the Dredd User-Agent', () => { const configuredTransaction = runner.configureTransaction(transaction); assert.isOk(configuredTransaction.request.headers['User-Agent']); - }) - ); + })); describe('when an additional header has a colon', () => { beforeEach(() => { @@ -342,8 +359,7 @@ describe('TransactionRunner', () => { assert.isOk(configuredTransaction.request); assert.isOk(configuredTransaction.expected); assert.strictEqual(transaction.origin, configuredTransaction.origin); - }) - ); + })); describe('when endpoint URL contains PORT and path', () => { beforeEach(() => { @@ -388,8 +404,7 @@ describe('TransactionRunner', () => { method: 'POST' }, expected: { - headers: { 'content-type': 'application/json' - }, + headers: { 'content-type': 'application/json' }, body: '{\n "type": "bulldozer",\n "name": "willy",\n "id": "5229c6e8e4b0bd7dbb07e29c"\n}\n', status: '202' }, @@ -420,8 +435,7 @@ describe('TransactionRunner', () => { runner.executeTransaction(transaction, () => { assert.isOk(loggerStub.info.called); done(); - }) - ); + })); }); describe('when a dry run', () => { @@ -441,8 +455,7 @@ describe('TransactionRunner', () => { runner.executeTransaction(transaction, () => { assert.isOk(runner.performRequest.notCalled); done(); - }) - ); + })); }); describe('when only certain methods are allowed by the configuration', () => { @@ -461,17 +474,18 @@ describe('TransactionRunner', () => { runner.executeTransaction(transaction, () => { assert.isOk(runner.skipTransaction.called); done(); - }) - ); + })); }); describe('when only certain names are allowed by the configuration', () => { beforeEach(() => { server = nock('http://127.0.0.1:3000') .post('/machines', { type: 'bulldozer', name: 'willy' }) - .reply(transaction.expected.status, + .reply( + transaction.expected.status, transaction.expected.body, - { 'Content-Type': 'application/json' }); + { 'Content-Type': 'application/json' } + ); configuration.options.only = ['Group Machine > Machine > Delete Message > Bogus example name']; runner = new Runner(configuration); @@ -488,8 +502,7 @@ describe('TransactionRunner', () => { runner.executeTransaction(transaction, () => { assert.notOk(runner.skipTransaction.called); done(); - }) - ); + })); it('should skip transactions with different names', (done) => { transaction.name = 'Group Machine > Machine > Delete Message > Bogus different example name'; @@ -531,30 +544,25 @@ describe('TransactionRunner', () => { runner.executeAllTransactions([clonedTransaction], runner.hooks, (err) => { assert.isOk(configuration.emitter.emit.calledWith('test skip')); done(err); - }) - ); + })); it('should add skip message as a warning under `general` to the results on transaction', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, (err) => { const messages = clonedTransaction.results.general.results.map(value => value.message); assert.include(messages.join().toLowerCase(), 'skipped'); done(err); - }) - ); + })); it('should add fail message as a warning under `general` to the results on test passed to the emitter', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, (err) => { const messages = []; const { callCount } = configuration.emitter.emit; for (let callNo = 0, end = callCount - 1, asc = end >= 0; asc ? callNo <= end : callNo >= end; asc ? callNo++ : callNo--) { - messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map( - value => value.message) - ); + messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map(value => value.message)); } assert.include(messages.join().toLowerCase(), 'skipped'); done(err); - }) - ); + })); it('should set status `skip` on test passed to the emitter', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, (err) => { @@ -567,17 +575,18 @@ describe('TransactionRunner', () => { assert.equal(tests.length, 1); assert.equal(tests[0].status, 'skip'); done(err); - }) - ); + })); }); describe('when server uses https', () => { beforeEach(() => { server = nock('https://127.0.0.1:3000') .post('/machines', { type: 'bulldozer', name: 'willy' }) - .reply(transaction.expected.status, + .reply( + transaction.expected.status, transaction.expected.body, - { 'Content-Type': 'application/json' }); + { 'Content-Type': 'application/json' } + ); configuration.server = 'https://127.0.0.1:3000'; transaction.protocol = 'https:'; runner = new Runner(configuration); @@ -589,17 +598,18 @@ describe('TransactionRunner', () => { runner.executeTransaction(transaction, () => { assert.isOk(server.isDone()); done(); - }) - ); + })); }); describe('when server uses http', () => { beforeEach(() => { server = nock('http://127.0.0.1:3000') .post('/machines', { type: 'bulldozer', name: 'willy' }) - .reply(transaction.expected.status, + .reply( + transaction.expected.status, transaction.expected.body, - { 'Content-Type': 'application/json' }); + { 'Content-Type': 'application/json' } + ); configuration.server = 'http://127.0.0.1:3000'; transaction.protocol = 'http:'; runner = new Runner(configuration); @@ -611,17 +621,18 @@ describe('TransactionRunner', () => { runner.executeTransaction(transaction, () => { assert.isOk(server.isDone()); done(); - }) - ); + })); }); describe('when backend responds as it should', () => { beforeEach(() => { server = nock('http://127.0.0.1:3000') .post('/machines', { type: 'bulldozer', name: 'willy' }) - .reply(transaction.expected.status, + .reply( + transaction.expected.status, transaction.expected.body, - { 'Content-Type': 'application/json' }); + { 'Content-Type': 'application/json' } + ); runner = new Runner(configuration); }); @@ -631,24 +642,24 @@ describe('TransactionRunner', () => { runner.executeTransaction(transaction, () => { assert.isOk(server.isDone()); done(); - }) - ); + })); it('should not return an error', done => runner.executeTransaction(transaction, (error) => { assert.notOk(error); done(); - }) - ); + })); }); describe('when backend responds with invalid response', () => { beforeEach(() => { server = nock('http://127.0.0.1:3000') .post('/machines', { type: 'bulldozer', name: 'willy' }) - .reply(400, + .reply( + 400, 'Foo bar', - { 'Content-Type': 'text/plain' }); + { 'Content-Type': 'text/plain' } + ); runner = new Runner(configuration); }); @@ -658,8 +669,7 @@ describe('TransactionRunner', () => { runner.executeTransaction(transaction, () => { assert.isOk(server.isDone()); done(); - }) - ); + })); }); describe('when backend responds a GET request with a redirection', () => { @@ -671,9 +681,11 @@ describe('TransactionRunner', () => { .get('/machines/latest') .reply(303, '', { Location: '/machines/123' }) .get('/machines/123') - .reply(transaction.expected.status, + .reply( + transaction.expected.status, transaction.expected.body, - { 'Content-Type': 'application/json' }); + { 'Content-Type': 'application/json' } + ); runner = new Runner(configuration); }); @@ -684,8 +696,7 @@ describe('TransactionRunner', () => { assert.equal(transaction.real.statusCode, 303); assert.notOk(server.isDone()); done(); - }) - ); + })); }); describe('when backend responds a POST request with a redirection', () => { @@ -695,9 +706,11 @@ describe('TransactionRunner', () => { .post('/machines') .reply(303, '', { Location: '/machines/123' }) .get('/machines/123') - .reply(transaction.expected.status, + .reply( + transaction.expected.status, transaction.expected.body, - { 'Content-Type': 'application/json' }); + { 'Content-Type': 'application/json' } + ); runner = new Runner(configuration); }); @@ -708,8 +721,7 @@ describe('TransactionRunner', () => { assert.equal(transaction.real.statusCode, 303); assert.notOk(server.isDone()); done(); - }) - ); + })); }); describe('when server is not running', () => { @@ -726,8 +738,7 @@ describe('TransactionRunner', () => { const events = Object.keys(configuration.emitter.emit.args).map(value => configuration.emitter.emit.args[value][0]); assert.include(events, 'test error'); done(); - }) - ); + })); }); }); @@ -752,8 +763,7 @@ describe('TransactionRunner', () => { method: 'POST' }, expected: { - headers: { 'content-type': 'application/json' - }, + headers: { 'content-type': 'application/json' }, status: '202', body: bodyFixture }, @@ -860,8 +870,7 @@ describe('TransactionRunner', () => { assert.equal( caseless(realRequest.headers).get('Content-Length'), expectedContentLength - ) - ); + )); }); context('the transaction object', () => { it('has the Content-Length header', () => assert.isOk(caseless(transaction.request.headers).has('Content-Length'))); @@ -869,11 +878,9 @@ describe('TransactionRunner', () => { assert.equal( caseless(transaction.request.headers).get('Content-Length'), expectedContentLength - ) - ); + )); }); - }) - ); + })); }); describe('exceuteAllTransactions(transactions, hooks, callback)', () => { @@ -906,8 +913,7 @@ describe('TransactionRunner', () => { method: 'POST' }, expected: { - headers: { 'content-type': 'application/json' - }, + headers: { 'content-type': 'application/json' }, body: '{\n "type": "bulldozer",\n "name": "willy",\n "id": "5229c6e8e4b0bd7dbb07e29c"\n}\n', statusCode: '202' }, @@ -960,14 +966,16 @@ describe('TransactionRunner', () => { serverNock1 = nock('http://127.0.0.1:3000') .post('/machines1', { type: 'bulldozer', name: 'willy' }) - .reply(transaction.expected.statusCode, + .reply( + transaction.expected.statusCode, transaction.expected.body, { 'Content-Type': 'application/json' } ); serverNock2 = nock('http://127.0.0.1:3000') .post('/machines2', { type: 'bulldozer', name: 'willy' }) - .reply(transaction.expected.statusCode, + .reply( + transaction.expected.statusCode, transaction.expected.body, { 'Content-Type': 'application/json' } ); @@ -995,8 +1003,7 @@ describe('TransactionRunner', () => { assert.isTrue(serverNock1.isDone(), 'first resource'); assert.isTrue(serverNock2.isDone(), 'second resource'); done(); - }) - ); + })); it('should execute all ‘all’ hooks once', done => runner.executeAllTransactions(transactions, hooks, (error) => { @@ -1007,8 +1014,7 @@ describe('TransactionRunner', () => { assert.isTrue(spies[spyName].called, spyName); }); done(); - }) - ); + })); it('should execute all other hooks once', done => runner.executeAllTransactions(transactions, hooks, (error) => { @@ -1020,8 +1026,7 @@ describe('TransactionRunner', () => { assert.isTrue(spies[spyName].calledTwice, spyName); }); done(); - }) - ); + })); }); describe('and it crashes (hook handler error was set)', () => { @@ -1474,8 +1479,7 @@ describe('TransactionRunner', () => { assert.equal(multiPartTransaction.request.body, parsedBody, 'Body'); assert.include(multiPartTransaction.request.body, '\r\n'); done(); - }) - ); + })); }); describe('when multipart header in request is with lowercase key', () => { @@ -1498,8 +1502,7 @@ describe('TransactionRunner', () => { assert.equal(multiPartTransaction.request.body, parsedBody, 'Body'); assert.include(multiPartTransaction.request.body, '\r\n'); done(); - }) - ); + })); }); describe('when multipart header in request, but body already has some CR (added in hooks e.g.s)', () => { @@ -1518,8 +1521,7 @@ describe('TransactionRunner', () => { assert.isOk(server.isDone()); assert.notInclude(multiPartTransaction.request.body, '\r\r'); done(); - }) - ); + })); }); describe('when multipart header is not in request', () => { @@ -1537,8 +1539,7 @@ describe('TransactionRunner', () => { assert.isOk(server.isDone()); assert.notInclude(multiPartTransaction.request.body, '\r\n'); done(); - }) - ); + })); }); }); @@ -1577,8 +1578,7 @@ describe('TransactionRunner', () => { method: 'POST' }, expected: { - headers: { 'content-type': 'application/json' - }, + headers: { 'content-type': 'application/json' }, body: '{\n "type": "bulldozer",\n "name": "willy",\n "id": "5229c6e8e4b0bd7dbb07e29c"\n}\n', statusCode: '202' }, @@ -1594,9 +1594,11 @@ describe('TransactionRunner', () => { server = nock('http://127.0.0.1:3000') .post('/machines', { type: 'bulldozer', name: 'willy' }) - .reply(transaction.expected.statusCode, + .reply( + transaction.expected.statusCode, transaction.expected.body, - { 'Content-Type': 'application/json' }); + { 'Content-Type': 'application/json' } + ); transactions = {}; transactions[transaction.name] = clone(transaction, false); @@ -1640,8 +1642,7 @@ describe('TransactionRunner', () => { assert.isOk(loggerStub.info.calledWith('beforeValidation')); assert.isOk(loggerStub.info.calledWith('after')); done(); - }) - ); + })); }); describe('with hooks, but without hooks.transactions set', () => { @@ -1707,8 +1708,7 @@ describe('TransactionRunner', () => { assert.isOk(loggerStub.info.calledWith('first')); assert.isOk(loggerStub.info.calledWith('second')); done(); - }) - ); + })); }); describe('‘*All’ hooks with legacy async interface (fist argument is a callback)', () => { @@ -1729,8 +1729,7 @@ describe('TransactionRunner', () => { assert.isOk(beforeAllStub.called); assert.isOk(beforeAllStubAnother.called); done(); - }) - ); + })); }); describe('with an ‘afterAll’ hook', () => { @@ -1750,8 +1749,7 @@ describe('TransactionRunner', () => { assert.isOk(afterAllStub.called); assert.isOk(afterAllStubAnother.called); done(); - }) - ); + })); }); describe('with multiple hooks for the same events', () => { @@ -1777,8 +1775,7 @@ describe('TransactionRunner', () => { assert.isOk(afterAllStub1.calledBefore(afterAllStub2)); assert.isOk(afterAllStub2.called); done(); - }) - ); + })); }); }); @@ -1795,8 +1792,7 @@ describe('TransactionRunner', () => { runner.executeAllTransactions([], runner.hooks, () => { assert.isOk(beforeAllStub.called); done(); - }) - ); + })); }); describe('with an ‘afterAll’ hook', () => { @@ -1811,8 +1807,7 @@ describe('TransactionRunner', () => { runner.executeAllTransactions([], runner.hooks, () => { assert.isOk(afterAllStub.called); done(); - }) - ); + })); }); describe('with multiple hooks for the same events', () => { @@ -1839,16 +1834,14 @@ describe('TransactionRunner', () => { assert.isOk(afterAllStub1.calledBefore(afterAllStub2)); assert.isOk(afterAllStub2.called); done(); - }) - ); + })); }); }); describe('‘*All’ hooks with sandboxed API (functions as strings)', () => describe('with a ‘beforeAll’ hook', () => { beforeEach(() => - sinon.stub(configuration.emitter, 'emit').callsFake(() => { }) - ); + sinon.stub(configuration.emitter, 'emit').callsFake(() => { })); afterEach(() => configuration.emitter.emit.restore()); @@ -1973,8 +1966,7 @@ function(transactions){ done(err); }); }); - }) - ); + })); describe('*Each hooks with standard async API (first argument transactions, second callback)', () => { const transactionsForExecution = []; @@ -1996,8 +1988,7 @@ function(transactions){ method: 'POST' }, expected: { - headers: { 'content-type': 'application/json' - }, + headers: { 'content-type': 'application/json' }, body: '{\n "type": "bulldozer",\n "name": "willy",\n "id": "5229c6e8e4b0bd7dbb07e29c"\n}\n', statusCode: '202' }, @@ -2028,7 +2019,8 @@ function(transactions){ runner.hooks.beforeEach(beforeEachStub); server = nock('http://127.0.0.1:3000') .post('/machines', { type: 'bulldozer', name: 'willy' }) - .reply(transactionsForExecution[0].expected.statusCode, + .reply( + transactionsForExecution[0].expected.statusCode, transactionsForExecution[0].expected.body, { 'Content-Type': 'application/json' } ); @@ -2043,15 +2035,13 @@ function(transactions){ runner.executeAllTransactions(transactionsForExecution, runner.hooks, () => { assert.isOk(beforeEachStub.called); done(); - }) - ); + })); it('should run the hook for each transaction', done => runner.executeAllTransactions(transactionsForExecution, runner.hooks, () => { assert.equal(beforeEachStub.callCount, transactionsForExecution.length); done(); - }) - ); + })); }); describe('with a ‘beforeEachValidation’ hook', () => { @@ -2067,7 +2057,8 @@ function(transactions){ runner.hooks.beforeEachValidation(beforeEachValidationStub); server = nock('http://127.0.0.1:3000') .post('/machines', { type: 'bulldozer', name: 'willy' }) - .reply(transactionsForExecution[0].expected.statusCode, + .reply( + transactionsForExecution[0].expected.statusCode, transactionsForExecution[0].expected.body, { 'Content-Type': 'application/json' } ); @@ -2100,8 +2091,7 @@ function(transactions){ runner.executeAllTransactions(transactionsForExecution, runner.hooks, () => { assert.equal(beforeEachValidationStub.callCount, transactionsForExecution.length); done(); - }) - ); + })); }); describe('with a ‘afterEach’ hook', () => { @@ -2114,7 +2104,8 @@ function(transactions){ runner.hooks.afterEach(afterEachStub); server = nock('http://127.0.0.1:3000') .post('/machines', { type: 'bulldozer', name: 'willy' }) - .reply(transactionsForExecution[0].expected.statusCode, + .reply( + transactionsForExecution[0].expected.statusCode, transactionsForExecution[0].expected.body, { 'Content-Type': 'application/json' } ); @@ -2129,15 +2120,13 @@ function(transactions){ runner.executeAllTransactions(transactionsForExecution, runner.hooks, () => { assert.isOk(afterEachStub.called); done(); - }) - ); + })); it('should run the hook for each transaction', done => runner.executeAllTransactions(transactionsForExecution, runner.hooks, () => { assert.equal(afterEachStub.callCount, transactionsForExecution.length); done(); - }) - ); + })); }); describe('with multiple hooks for the same events', () => { @@ -2163,8 +2152,7 @@ function(transactions){ assert.isOk(afterAllStub1.calledBefore(afterAllStub2)); assert.isOk(afterAllStub2.called); done(); - }) - ); + })); }); }); @@ -2185,8 +2173,7 @@ function(transactions){ runner.executeAllTransactions([transaction], runner.hooks, () => { assert.isOk(configuration.emitter.emit.calledWith('test error')); done(); - }) - ); + })); }); describe('with ‘after’ hook that throws an error', () => { @@ -2206,8 +2193,7 @@ function(transactions){ runner.executeAllTransactions([transaction], runner.hooks, () => { assert.isOk(configuration.emitter.emit.calledWith('test error')); done(); - }) - ); + })); }); describe('with ‘before’ hook that throws a chai expectation error', () => { @@ -2227,37 +2213,31 @@ function(transactions){ runner.executeAllTransactions([transaction], runner.hooks, () => { assert.notOk(configuration.emitter.emit.calledWith('test error')); done(); - }) - ); + })); it('should report a fail', done => runner.executeAllTransactions([transaction], runner.hooks, () => { assert.isOk(configuration.emitter.emit.calledWith('test fail')); done(); - }) - ); + })); it('should add fail message as a error under `general` to the results on transaction', done => runner.executeAllTransactions([transaction], runner.hooks, () => { const messages = transaction.results.general.results.map(value => value.message); assert.include(messages.join(), 'expected false to be truthy'); done(); - }) - ); + })); it('should add fail message as a error under `general` to the results on test passed to the emitter', done => runner.executeAllTransactions([transaction], runner.hooks, () => { const messages = []; const { callCount } = configuration.emitter.emit; for (let callNo = 0, end = callCount - 1, asc = end >= 0; asc ? callNo <= end : callNo >= end; asc ? callNo++ : callNo--) { - messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map( - value => value.message - )); + messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map(value => value.message)); } assert.include(messages.join(), 'expected false to be truthy'); done(); - }) - ); + })); }); describe('with ‘after’ hook that throws a chai expectation error', () => { @@ -2277,44 +2257,37 @@ function(transactions){ runner.executeAllTransactions([transaction], runner.hooks, () => { assert.notOk(configuration.emitter.emit.calledWith('test error')); done(); - }) - ); + })); it('should report a fail', done => runner.executeAllTransactions([transaction], runner.hooks, () => { assert.isOk(configuration.emitter.emit.calledWith('test fail')); done(); - }) - ); + })); it('should set test as failed', done => runner.executeAllTransactions([transaction], runner.hooks, () => { assert.equal(transaction.test.status, 'fail'); done(); - }) - ); + })); it('should add fail message as a error under `general` to the results on transaction', done => runner.executeAllTransactions([transaction], runner.hooks, () => { const messages = transaction.results.general.results.map(value => value.message); assert.include(messages.join(), 'expected false to be truthy'); done(); - }) - ); + })); it('should add fail message as a error under `general` to the results on test passed to the emitter', done => runner.executeAllTransactions([transaction], runner.hooks, () => { const messages = []; const { callCount } = configuration.emitter.emit; for (let callNo = 0, end = callCount - 1, asc = end >= 0; asc ? callNo <= end : callNo >= end; asc ? callNo++ : callNo--) { - messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map( - value => value.message - )); + messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map(value => value.message)); } assert.include(messages.join(), 'expected false to be truthy'); done(); - }) - ); + })); }); describe('with hook failing the transaction', () => { @@ -2336,15 +2309,13 @@ function(transactions){ runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { assert.isOk(configuration.emitter.emit.calledWith('test fail')); done(); - }) - ); + })); it('should not run the transaction', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { assert.notOk(server.isDone()); done(); - }) - ); + })); it('should pass the failing message to the emitter', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { @@ -2355,8 +2326,7 @@ function(transactions){ } assert.include(messages.join(), 'Message before'); done(); - }) - ); + })); it('should mention before hook in the error message', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { @@ -2367,30 +2337,25 @@ function(transactions){ } assert.include(messages.join(), 'Failed in before hook:'); done(); - }) - ); + })); it('should add fail message as a error under `general` to the results on the transaction', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { const messages = clonedTransaction.results.general.results.map(value => value.message); assert.include(messages.join(), 'Message before'); done(); - }) - ); + })); it('should add fail message as a error under `general` to the results on test passed to the emitter', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { const messages = []; const { callCount } = configuration.emitter.emit; for (let callNo = 0, end = callCount - 1, asc = end >= 0; asc ? callNo <= end : callNo >= end; asc ? callNo++ : callNo--) { - messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map( - value => value.message) - ); + messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map(value => value.message)); } assert.include(messages.join(), 'Message before'); done(); - }) - ); + })); describe('when message is set to fail also in ‘after’ hook', () => { clonedTransaction = null; @@ -2412,8 +2377,7 @@ function(transactions){ } assert.notInclude(messages.join(), 'Message after fail'); done(); - }) - ); + })); it('should not mention after hook in the error message', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { @@ -2424,30 +2388,25 @@ function(transactions){ } assert.notInclude(messages.join(), 'Failed in after hook:'); done(); - }) - ); + })); it('should not add fail message as a error under `general` to the results on the transaction', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { const messages = clonedTransaction.results.general.results.map(value => value.message); assert.notInclude(messages.join(), 'Message after fail'); done(); - }) - ); + })); it('should not add fail message as a error under `general` to the results on test passed to the emitter', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { const messages = []; const { callCount } = configuration.emitter.emit; for (let callNo = 0, end = callCount - 1, asc = end >= 0; asc ? callNo <= end : callNo >= end; asc ? callNo++ : callNo--) { - messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map( - value => value.message - )); + messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map(value => value.message)); } assert.notInclude(messages.join(), 'Message after fail'); done(); - }) - ); + })); }); }); @@ -2474,8 +2433,7 @@ function(transactions){ runner.executeAllTransactions([modifiedTransaction], runner.hooks, () => { assert.isOk(server.isDone()); done(); - }) - ); + })); it('should not fail again', done => runner.executeAllTransactions([modifiedTransaction], runner.hooks, () => { @@ -2488,8 +2446,7 @@ function(transactions){ } assert.equal(failCount, 1); done(); - }) - ); + })); it('should not pass the hook message to the emitter', done => runner.executeAllTransactions([modifiedTransaction], runner.hooks, () => { @@ -2500,8 +2457,7 @@ function(transactions){ } assert.notInclude(messages, 'Message after fail'); done(); - }) - ); + })); it('should not mention after hook in the error message', done => runner.executeAllTransactions([modifiedTransaction], runner.hooks, () => { @@ -2512,30 +2468,25 @@ function(transactions){ } assert.notInclude(messages, 'Failed in after hook:'); done(); - }) - ); + })); it('should not add fail message as a error under `general` to the results on the transaction', done => runner.executeAllTransactions([modifiedTransaction], runner.hooks, () => { const messages = modifiedTransaction.results.general.results.map(value => value.message); assert.notInclude(messages.join(), 'Message after fail'); done(); - }) - ); + })); it('should not add fail message as a error under `general` to the results on test passed to the emitter', done => runner.executeAllTransactions([modifiedTransaction], runner.hooks, () => { const messages = []; const { callCount } = configuration.emitter.emit; for (let callNo = 0, end = callCount - 1, asc = end >= 0; asc ? callNo <= end : callNo >= end; asc ? callNo++ : callNo--) { - messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map( - value => value.message - )); + messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map(value => value.message)); } assert.notInclude(messages.join(), 'Message after fail'); done(); - }) - ); + })); }); describe('in ‘after’ hook when transaction passes ', () => { @@ -2559,22 +2510,19 @@ function(transactions){ runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { assert.isOk(server.isDone()); done(); - }) - ); + })); it('it should fail the test', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { assert.isOk(configuration.emitter.emit.calledWith('test fail')); done(); - }) - ); + })); it('it should not pass the test', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { assert.notOk(configuration.emitter.emit.calledWith('test pass')); done(); - }) - ); + })); it('it should pass the failing message to the emitter', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { @@ -2585,8 +2533,7 @@ function(transactions){ } assert.include(messages.join(), 'Message after pass'); done(); - }) - ); + })); it('should mention after hook in the error message', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { @@ -2597,37 +2544,31 @@ function(transactions){ } assert.include(messages.join(), 'Failed in after hook:'); done(); - }) - ); + })); it('should set transaction test status to failed', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { assert.equal(clonedTransaction.test.status, 'fail'); done(); - }) - ); + })); it('should add fail message as a error under `general` to the results', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { const messages = clonedTransaction.results.general.results.map(value => value.message); assert.include(messages.join(), 'Message after pass'); done(); - }) - ); + })); it('should not add fail message as a error under `general` to the results on test passed to the emitter', done => runner.executeAllTransactions([clonedTransaction], runner.hooks, () => { const messages = []; const { callCount } = configuration.emitter.emit; for (let callNo = 0, end = callCount - 1, asc = end >= 0; asc ? callNo <= end : callNo >= end; asc ? callNo++ : callNo--) { - messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map( - value => value.message - )); + messages.push(configuration.emitter.emit.getCall(callNo).args[1].results.general.results.map(value => value.message)); } assert.include(messages.join(), 'Message after pass'); done(); - }) - ); + })); }); }); @@ -2640,16 +2581,14 @@ function(transactions){ }); it('should not run the hooks', done => - runner.executeAllTransactions([transaction], runner.hooks, () => done()) - ); + runner.executeAllTransactions([transaction], runner.hooks, () => done())); it('should pass the transactions', done => runner.executeAllTransactions([transaction], runner.hooks, (error) => { if (error) { done(error); } assert.isOk(configuration.emitter.emit.calledWith('test pass')); done(); - }) - ); + })); }); describe('with hook modifying the transaction body and backend Express app using the body parser', () => { @@ -2687,8 +2626,7 @@ function(transactions){ // Should not hang here assert.isOk(true); server.close(); - }) - ); + })); server.on('close', () => { assert.equal(receivedRequests.length, 1); @@ -2727,9 +2665,7 @@ function(transcaction){ done(); }); }); - }) - ) - ); + }))); describe('runHook(hook, transaction, callback)', () => describe('when sandbox mode is on (hook function is a string)', () => { @@ -2865,6 +2801,5 @@ function(transaction){ done(); }); }); - }) - ); + })); });