From 0af37be08e98b35161f00f59f28e25a970d1568b Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Mon, 22 Jan 2018 21:05:28 -0800 Subject: [PATCH 01/12] update --- .eslintrc.yml | 38 - features/step_definitions/file_steps.js | 2 +- package.json | 20 +- src/cli/argv_parser.js | 12 +- src/cli/configuration_builder.js | 26 +- src/cli/configuration_builder_spec.js | 36 +- src/cli/helpers.js | 6 +- src/cli/helpers_spec.js | 64 +- src/cli/i18n.js | 6 +- src/cli/index.js | 14 +- src/cli/install_validator.js | 2 +- src/cli/option_splitter.js | 4 +- src/cli/option_splitter_spec.js | 4 +- src/cli/path_expander.js | 12 +- src/cli/path_expander_spec.js | 34 +- src/cli/profile_loader.js | 8 +- src/cli/profile_loader_spec.js | 52 +- src/cli/run.js | 4 +- src/formatter/builder.js | 8 +- src/formatter/event_protocol_formatter.js | 6 +- src/formatter/get_color_fns.js | 2 +- src/formatter/helpers/error_helpers.js | 2 +- src/formatter/helpers/event_data_collector.js | 20 +- .../helpers/gherkin_document_parser.js | 4 +- src/formatter/helpers/issue_helpers.js | 10 +- src/formatter/helpers/issue_helpers_spec.js | 42 +- src/formatter/helpers/keyword_type.js | 2 +- src/formatter/helpers/keyword_type_spec.js | 56 +- src/formatter/helpers/location_helpers.js | 2 +- src/formatter/helpers/pickle_parser.js | 6 +- src/formatter/helpers/step_result_helpers.js | 10 +- src/formatter/helpers/summary_helpers.js | 6 +- src/formatter/helpers/summary_helpers_spec.js | 54 +- src/formatter/helpers/usage_helpers/index.js | 10 +- .../helpers/usage_helpers/index_spec.js | 20 +- src/formatter/index.js | 2 +- src/formatter/json_formatter.js | 20 +- src/formatter/json_formatter_spec.js | 62 +- src/formatter/progress_bar_formatter.js | 12 +- src/formatter/progress_bar_formatter_spec.js | 96 ++- src/formatter/progress_formatter.js | 4 +- src/formatter/progress_formatter_spec.js | 50 +- src/formatter/rerun_formatter.js | 6 +- src/formatter/rerun_formatter_spec.js | 36 +- src/formatter/snippets_formatter.js | 6 +- .../step_definition_snippet_builder/index.js | 8 +- .../index_spec.js | 68 +- .../javascript_snippet_syntax.js | 4 +- .../javascript_snippet_syntax_spec.js | 40 +- src/formatter/summary_formatter.js | 10 +- src/formatter/summary_formatter_spec.js | 52 +- src/formatter/usage_formatter.js | 4 +- src/formatter/usage_formatter_spec.js | 46 +- src/formatter/usage_json_formatter.js | 4 +- src/formatter/usage_json_formatter_spec.js | 10 +- src/models/data_table.js | 10 +- src/models/data_table_spec.js | 26 +- src/models/step_definition.js | 14 +- src/models/test_case_hook_definition.js | 10 +- src/models/test_case_hook_definition_spec.js | 33 +- src/models/test_run_hook_definition.js | 6 +- src/pickle_filter.js | 16 +- src/pickle_filter_spec.js | 250 +++---- src/runtime/attachment_manager/index.js | 10 +- src/runtime/attachment_manager/index_spec.js | 86 +-- src/runtime/helpers.js | 2 +- src/runtime/helpers_spec.js | 8 +- src/runtime/index.js | 10 +- src/runtime/stack_trace_filter.js | 15 +- src/runtime/step_runner.js | 2 +- src/runtime/test_case_runner.js | 34 +- src/runtime/test_case_runner_spec.js | 198 ++--- src/status.js | 2 +- src/status_spec.js | 10 +- src/step_arguments.js | 4 +- .../define_helpers.js | 10 +- .../finalize_helpers.js | 2 +- src/support_code_library_builder/index.js | 8 +- .../index_spec.js | 80 +- .../parameter_type_registry_builder.js | 2 +- .../validate_arguments.js | 12 +- src/time.js | 6 +- src/uncaught_exception_manager.js | 4 +- src/user_code_runner.js | 12 +- src/user_code_runner_spec.js | 174 ++--- yarn.lock | 696 +++++++++++++----- 86 files changed, 1585 insertions(+), 1311 deletions(-) delete mode 100644 .eslintrc.yml diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index b5d058382..000000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,38 +0,0 @@ -env: - browser: true - es6: true - node: true -extends: - - 'eslint:recommended' - - prettier -globals: - afterEach: false - beforeEach: false - createMock: false - describe: false - expect: false - it: false - sinon: false -parser: babel-eslint -parserOptions: - sourceType: module -plugins: - - babel - - prettier -rules: - babel/new-cap: error - complexity: error - eqeqeq: [error, always] - no-await-in-loop: error - no-negated-condition: error - no-nested-ternary: error - no-plusplus: error - no-shadow: error - no-unneeded-ternary: [error, {defaultAssignment: false}] - no-var: error - object-shorthand: [error, always] - prettier/prettier: - - error - - trailingComma: none - singleQuote: true - semi: false diff --git a/features/step_definitions/file_steps.js b/features/step_definitions/file_steps.js index ff37b8963..363d1ff3d 100644 --- a/features/step_definitions/file_steps.js +++ b/features/step_definitions/file_steps.js @@ -29,7 +29,7 @@ Given(/^a directory named "(.*)"$/, function(filePath) { Given(/^"([^"]*)" is an absolute path$/, function(filePath) { filePath = Mustache.render(filePath, this) - expect(path.isAbsolute(filePath)).to.be.true + expect(path.isAbsolute(filePath)).to.eql(true) }) Then(/^the file "([^"]*)" has the text:$/, async function(filePath, text) { diff --git a/package.json b/package.json index f3bc63165..a35f81d55 100644 --- a/package.json +++ b/package.json @@ -180,19 +180,15 @@ "connect": "^3.4.0", "coveralls": "^3.0.0", "dependency-lint": "^5.0.1", - "eslint": "^4.1.1", - "eslint-config-prettier": "^2.2.0", - "eslint-plugin-babel": "^4.0.0", - "eslint-plugin-prettier": "^2.1.2", "fs-extra": "^4.0.2", "mocha": "^4.0.1", "mustache": "^2.3.0", "nyc": "^11.0.2", - "prettier": "^1.5.2", "regenerator-runtime": "^0.11.0", "serve-static": "^1.10.0", "sinon": "^4.0.1", "sinon-chai": "^2.11.0", + "standard": "^10.0.3", "stream-to-string": "^1.1.0", "tmp": "^0.0.33" }, @@ -222,5 +218,17 @@ "bin/", "dist/", "lib/" - ] + ], + "standard": { + "globals": [ + "afterEach", + "beforeEach", + "createMock", + "describe", + "expect", + "it", + "sinon" + ], + "parser": "babel-eslint" + } } diff --git a/src/cli/argv_parser.js b/src/cli/argv_parser.js index e5562181b..4969c5967 100644 --- a/src/cli/argv_parser.js +++ b/src/cli/argv_parser.js @@ -5,13 +5,13 @@ import path from 'path' import Gherkin from 'gherkin' export default class ArgvParser { - static collect(val, memo) { + static collect (val, memo) { memo.push(val) return memo } - static mergeJson(option) { - return function(str, memo) { + static mergeJson (option) { + return function (str, memo) { let val try { val = JSON.parse(str) @@ -27,18 +27,18 @@ export default class ArgvParser { } } - static mergeTags(val, memo) { + static mergeTags (val, memo) { return memo === '' ? `(${val})` : `${memo} and (${val})` } - static validateLanguage(val) { + static validateLanguage (val) { if (!_.includes(_.keys(Gherkin.DIALECTS), val)) { throw new Error('Unsupported ISO 639-1: ' + val) } return val } - static parse(argv) { + static parse (argv) { const program = new Command(path.basename(argv[1])) program diff --git a/src/cli/configuration_builder.js b/src/cli/configuration_builder.js index ffc140700..68e5ed326 100644 --- a/src/cli/configuration_builder.js +++ b/src/cli/configuration_builder.js @@ -7,12 +7,12 @@ import OptionSplitter from './option_splitter' import Promise from 'bluebird' export default class ConfigurationBuilder { - static async build(options) { + static async build (options) { const builder = new ConfigurationBuilder(options) - return await builder.build() + return builder.build() } - constructor({ argv, cwd }) { + constructor ({ argv, cwd }) { this.cwd = cwd this.pathExpander = new PathExpander(cwd) @@ -21,7 +21,7 @@ export default class ConfigurationBuilder { this.options = parsedArgv.options } - async build() { + async build () { const listI18nKeywordsFor = this.options.i18nKeywords const listI18nLanguages = !!this.options.i18nLanguages const unexpandedFeaturePaths = await this.getUnexpandedFeaturePaths() @@ -63,14 +63,14 @@ export default class ConfigurationBuilder { } } - async expandFeaturePaths(featurePaths) { + async expandFeaturePaths (featurePaths) { featurePaths = featurePaths.map(p => p.replace(/(:\d+)*$/g, '')) // Strip line numbers - return await this.pathExpander.expandPathsWithExtensions(featurePaths, [ + return this.pathExpander.expandPathsWithExtensions(featurePaths, [ 'feature' ]) } - getFeatureDirectoryPaths(featurePaths) { + getFeatureDirectoryPaths (featurePaths) { const featureDirs = featurePaths.map(featurePath => { let featureDir = path.dirname(featurePath) let childDir @@ -88,25 +88,25 @@ export default class ConfigurationBuilder { return _.uniq(featureDirs) } - getFormatOptions() { + getFormatOptions () { const formatOptions = _.clone(this.options.formatOptions) formatOptions.cwd = this.cwd _.defaults(formatOptions, { colorsEnabled: true }) return formatOptions } - getFormats() { + getFormats () { const mapping = { '': 'progress' } this.options.format.forEach(format => { const [type, outputTo] = OptionSplitter.split(format) mapping[outputTo || ''] = type }) - return _.map(mapping, function(type, outputTo) { + return _.map(mapping, function (type, outputTo) { return { outputTo, type } }) } - async getUnexpandedFeaturePaths() { + async getUnexpandedFeaturePaths () { if (this.args.length > 0) { const nestedFeaturePaths = await Promise.map(this.args, async arg => { const filename = path.basename(arg) @@ -130,14 +130,14 @@ export default class ConfigurationBuilder { return ['features'] } - async expandSupportCodePaths(supportCodePaths) { + async expandSupportCodePaths (supportCodePaths) { const extensions = ['js'] this.options.compiler.forEach(compiler => { const [extension, module] = OptionSplitter.split(compiler) extensions.push(extension) require(module) }) - return await this.pathExpander.expandPathsWithExtensions( + return this.pathExpander.expandPathsWithExtensions( supportCodePaths, extensions ) diff --git a/src/cli/configuration_builder_spec.js b/src/cli/configuration_builder_spec.js index c97f9940c..3a132d1a4 100644 --- a/src/cli/configuration_builder_spec.js +++ b/src/cli/configuration_builder_spec.js @@ -6,8 +6,8 @@ import tmp from 'tmp' const outputFile = promisify(fsExtra.outputFile) -describe('Configuration', function() { - beforeEach(async function() { +describe('Configuration', function () { + beforeEach(async function () { this.tmpDir = await promisify(tmp.dir)({ unsafeCleanup: true }) await promisify(fsExtra.mkdirp)(path.join(this.tmpDir, 'features')) this.argv = ['path/to/node', 'path/to/cucumber.js'] @@ -17,12 +17,12 @@ describe('Configuration', function() { } }) - describe('no argv', function() { - beforeEach(async function() { + describe('no argv', function () { + beforeEach(async function () { this.result = await ConfigurationBuilder.build(this.configurationOptions) }) - it('returns the default configuration', function() { + it('returns the default configuration', function () { expect(this.result).to.eql({ featureDefaultLanguage: '', featurePaths: [], @@ -52,8 +52,8 @@ describe('Configuration', function() { }) }) - describe('path to a feature', function() { - beforeEach(async function() { + describe('path to a feature', function () { + beforeEach(async function () { this.relativeFeaturePath = path.join('features', 'a.feature') this.featurePath = path.join(this.tmpDir, this.relativeFeaturePath) await outputFile(this.featurePath, '') @@ -63,7 +63,7 @@ describe('Configuration', function() { this.result = await ConfigurationBuilder.build(this.configurationOptions) }) - it('returns the appropriate feature and support code paths', async function() { + it('returns the appropriate feature and support code paths', async function () { const { featurePaths, pickleFilterOptions, @@ -77,8 +77,8 @@ describe('Configuration', function() { }) }) - describe('path to a nested feature', function() { - beforeEach(async function() { + describe('path to a nested feature', function () { + beforeEach(async function () { this.relativeFeaturePath = path.join('features', 'nested', 'a.feature') this.featurePath = path.join(this.tmpDir, this.relativeFeaturePath) await outputFile(this.featurePath, '') @@ -88,7 +88,7 @@ describe('Configuration', function() { this.result = await ConfigurationBuilder.build(this.configurationOptions) }) - it('returns the appropriate feature and support code paths', async function() { + it('returns the appropriate feature and support code paths', async function () { const { featurePaths, pickleFilterOptions, @@ -102,13 +102,13 @@ describe('Configuration', function() { }) }) - describe('formatters', function() { - it('adds a default', async function() { + describe('formatters', function () { + it('adds a default', async function () { const formats = await getFormats(this.configurationOptions) expect(formats).to.eql([{ outputTo: '', type: 'progress' }]) }) - it('splits relative unix paths', async function() { + it('splits relative unix paths', async function () { this.argv.push('-f', '../custom/formatter:../formatter/output.txt') const formats = await getFormats(this.configurationOptions) @@ -118,7 +118,7 @@ describe('Configuration', function() { ]) }) - it('splits absolute unix paths', async function() { + it('splits absolute unix paths', async function () { this.argv.push('-f', '/custom/formatter:/formatter/output.txt') const formats = await getFormats(this.configurationOptions) @@ -128,7 +128,7 @@ describe('Configuration', function() { ]) }) - it('splits absolute windows paths', async function() { + it('splits absolute windows paths', async function () { this.argv.push('-f', 'C:\\custom\\formatter:D:\\formatter\\output.txt') const formats = await getFormats(this.configurationOptions) @@ -138,14 +138,14 @@ describe('Configuration', function() { ]) }) - it('does not split absolute windows paths without an output', async function() { + it('does not split absolute windows paths without an output', async function () { this.argv.push('-f', 'C:\\custom\\formatter') const formats = await getFormats(this.configurationOptions) expect(formats).to.eql([{ outputTo: '', type: 'C:\\custom\\formatter' }]) }) - async function getFormats(options) { + async function getFormats (options) { const result = await ConfigurationBuilder.build(options) return result.formats } diff --git a/src/cli/helpers.js b/src/cli/helpers.js index 04615259a..0e1edd1a9 100644 --- a/src/cli/helpers.js +++ b/src/cli/helpers.js @@ -6,7 +6,7 @@ import path from 'path' import ProfileLoader from './profile_loader' import Promise from 'bluebird' -export async function getExpandedArgv({ argv, cwd }) { +export async function getExpandedArgv ({ argv, cwd }) { let { options } = ArgvParser.parse(argv) let fullArgv = argv const profileArgv = await new ProfileLoader(cwd).getArgv(options.profile) @@ -16,7 +16,7 @@ export async function getExpandedArgv({ argv, cwd }) { return fullArgv } -export async function getTestCasesFromFilesystem({ +export async function getTestCasesFromFilesystem ({ cwd, eventBroadcaster, featureDefaultLanguage, @@ -39,7 +39,7 @@ export async function getTestCasesFromFilesystem({ return result } -export async function getTestCases({ +export async function getTestCases ({ eventBroadcaster, language, pickleFilter, diff --git a/src/cli/helpers_spec.js b/src/cli/helpers_spec.js index 7c922903f..e8cdb3bcc 100644 --- a/src/cli/helpers_spec.js +++ b/src/cli/helpers_spec.js @@ -6,9 +6,9 @@ import path from 'path' import PickleFilter from '../pickle_filter' import tmp from 'tmp' -describe('helpers', function() { - describe('getTestCasesFromFilesystem', function() { - beforeEach(async function() { +describe('helpers', function () { + describe('getTestCasesFromFilesystem', function () { + beforeEach(async function () { this.onSource = sinon.stub() this.onGherkinDocument = sinon.stub() this.onPickle = sinon.stub() @@ -22,8 +22,8 @@ describe('helpers', function() { this.eventBroadcaster.on('pickle-rejected', this.onPickleRejected) }) - describe('empty feature', function() { - beforeEach(async function() { + describe('empty feature', function () { + beforeEach(async function () { this.tmpDir = await promisify(tmp.dir)() this.relativeFeaturePath = path.join('features', 'a.feature') const featurePath = path.join(this.tmpDir, 'features', 'a.feature') @@ -36,12 +36,12 @@ describe('helpers', function() { }) }) - it('returns an empty array', function() { + it('returns an empty array', function () { expect(this.result).to.eql([]) }) - it('emits a source event', function() { - expect(this.onSource).to.have.been.calledOnce + it('emits a source event', function () { + expect(this.onSource).to.have.callCount(1) expect(this.onSource).to.have.been.calledWith({ data: '', media: { encoding: 'utf-8', type: 'text/x.cucumber.gherkin+plain' }, @@ -49,22 +49,22 @@ describe('helpers', function() { }) }) - it('emits a gherkin-document event', function() { - expect(this.onGherkinDocument).to.have.been.calledOnce + it('emits a gherkin-document event', function () { + expect(this.onGherkinDocument).to.have.callCount(1) const arg = this.onGherkinDocument.firstCall.args[0] expect(arg).to.have.keys(['document', 'uri']) expect(arg.uri).to.eql(this.relativeFeaturePath) }) - it('does not emit pickle events', function() { - expect(this.onPickle).not.to.have.been.called - expect(this.onPickleAccepted).not.to.have.been.called - expect(this.onPickleRejected).not.to.have.been.called + it('does not emit pickle events', function () { + expect(this.onPickle).to.have.callCount(0) + expect(this.onPickleAccepted).to.have.callCount(0) + expect(this.onPickleRejected).to.have.callCount(0) }) }) - describe('feature with scenario that does not match the filter', function() { - beforeEach(async function() { + describe('feature with scenario that does not match the filter', function () { + beforeEach(async function () { this.tmpDir = await promisify(tmp.dir)() this.relativeFeaturePath = path.join('features', 'a.feature') const featurePath = path.join(this.tmpDir, 'features', 'a.feature') @@ -82,12 +82,12 @@ describe('helpers', function() { }) }) - it('returns an empty array', function() { + it('returns an empty array', function () { expect(this.result).to.eql([]) }) - it('emits a source event', function() { - expect(this.onSource).to.have.been.calledOnce + it('emits a source event', function () { + expect(this.onSource).to.have.callCount(1) expect(this.onSource).to.have.been.calledWith({ data: 'Feature: a\nScenario: b\nGiven a step', media: { encoding: 'utf-8', type: 'text/x.cucumber.gherkin+plain' }, @@ -95,16 +95,16 @@ describe('helpers', function() { }) }) - it('emits a gherkin-document event', function() { - expect(this.onGherkinDocument).to.have.been.calledOnce + it('emits a gherkin-document event', function () { + expect(this.onGherkinDocument).to.have.callCount(1) const arg = this.onGherkinDocument.firstCall.args[0] expect(arg).to.have.keys(['document', 'uri']) expect(arg.uri).to.eql(this.relativeFeaturePath) }) }) - describe('feature with scenario that matches the filter', function() { - beforeEach(async function() { + describe('feature with scenario that matches the filter', function () { + beforeEach(async function () { this.tmpDir = await promisify(tmp.dir)() this.relativeFeaturePath = path.join('features', 'a.feature') const featurePath = path.join(this.tmpDir, 'features', 'a.feature') @@ -120,14 +120,14 @@ describe('helpers', function() { }) }) - it('returns the test case', function() { + it('returns the test case', function () { expect(this.result).to.have.lengthOf(1) expect(this.result[0]).to.have.keys(['pickle', 'uri']) expect(this.result[0].uri).to.eql(this.relativeFeaturePath) }) - it('emits a source event', function() { - expect(this.onSource).to.have.been.calledOnce + it('emits a source event', function () { + expect(this.onSource).to.have.callCount(1) expect(this.onSource).to.have.been.calledWith({ data: 'Feature: a\nScenario: b\nGiven a step', media: { encoding: 'utf-8', type: 'text/x.cucumber.gherkin+plain' }, @@ -135,17 +135,17 @@ describe('helpers', function() { }) }) - it('emits a gherkin-document event', function() { - expect(this.onGherkinDocument).to.have.been.calledOnce + it('emits a gherkin-document event', function () { + expect(this.onGherkinDocument).to.have.callCount(1) const arg = this.onGherkinDocument.firstCall.args[0] expect(arg).to.have.keys(['document', 'uri']) expect(arg.uri).to.eql(this.relativeFeaturePath) }) - it('emits a pickle and pickle-accepted event', function() { - expect(this.onPickle).to.have.been.calledOnce - expect(this.onPickleAccepted).to.have.been.calledOnce - expect(this.onPickleRejected).not.to.have.been.called + it('emits a pickle and pickle-accepted event', function () { + expect(this.onPickle).to.have.callCount(1) + expect(this.onPickleAccepted).to.have.callCount(1) + expect(this.onPickleRejected).to.have.callCount(0) const onPickleArg = this.onPickle.firstCall.args[0] expect(onPickleArg).to.have.keys(['pickle', 'uri']) expect(onPickleArg.uri).to.eql(this.relativeFeaturePath) diff --git a/src/cli/i18n.js b/src/cli/i18n.js index 23ff26b95..f94517495 100644 --- a/src/cli/i18n.js +++ b/src/cli/i18n.js @@ -16,7 +16,7 @@ const keywords = [ 'but' ] -function getAsTable(header, rows) { +function getAsTable (header, rows) { const table = new Table({ chars: { bottom: '', @@ -46,14 +46,14 @@ function getAsTable(header, rows) { return table.toString() } -export function getLanguages() { +export function getLanguages () { const rows = _.map(Gherkin.DIALECTS, (data, isoCode) => { return [isoCode, data.name, data['native']] }) return getAsTable(['ISO 639-1', 'ENGLISH NAME', 'NATIVE NAME'], rows) } -export function getKeywords(isoCode) { +export function getKeywords (isoCode) { const language = Gherkin.DIALECTS[isoCode] const rows = _.map(keywords, keyword => { const words = _.map(language[keyword], s => `"${s}"`).join(', ') diff --git a/src/cli/index.js b/src/cli/index.js index 9512cbd96..a3b7de5a4 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -13,18 +13,18 @@ import Runtime from '../runtime' import supportCodeLibraryBuilder from '../support_code_library_builder' export default class Cli { - constructor({ argv, cwd, stdout }) { + constructor ({ argv, cwd, stdout }) { this.argv = argv this.cwd = cwd this.stdout = stdout } - async getConfiguration() { + async getConfiguration () { const fullArgv = await getExpandedArgv({ argv: this.argv, cwd: this.cwd }) - return await ConfigurationBuilder.build({ argv: fullArgv, cwd: this.cwd }) + return ConfigurationBuilder.build({ argv: fullArgv, cwd: this.cwd }) } - async initializeFormatters({ + async initializeFormatters ({ eventBroadcaster, formatOptions, formats, @@ -49,20 +49,20 @@ export default class Cli { } return FormatterBuilder.build(type, typeOptions) }) - return function() { + return function () { return Promise.each(streamsToClose, stream => Promise.promisify(::stream.end)() ) } } - getSupportCodeLibrary(supportCodePaths) { + getSupportCodeLibrary (supportCodePaths) { supportCodeLibraryBuilder.reset(this.cwd) supportCodePaths.forEach(codePath => require(codePath)) return supportCodeLibraryBuilder.finalize() } - async run() { + async run () { await validateInstall(this.cwd) const configuration = await this.getConfiguration() if (configuration.listI18nLanguages) { diff --git a/src/cli/install_validator.js b/src/cli/install_validator.js index 1387ce86e..7af97d3e6 100644 --- a/src/cli/install_validator.js +++ b/src/cli/install_validator.js @@ -3,7 +3,7 @@ import fs from 'mz/fs' import path from 'path' import resolve from 'resolve' -export async function validateInstall(cwd) { +export async function validateInstall (cwd) { const projectPath = path.join(__dirname, '..', '..') if (projectPath === cwd) { return // cucumber testing itself diff --git a/src/cli/option_splitter.js b/src/cli/option_splitter.js index 19cee5342..3326d3f5e 100644 --- a/src/cli/option_splitter.js +++ b/src/cli/option_splitter.js @@ -1,5 +1,5 @@ export default class OptionSplitter { - static split(option) { + static split (option) { const parts = option.split(/([^A-Z]):(?!\\)/) return parts.reduce((memo, part, i) => { @@ -12,6 +12,6 @@ export default class OptionSplitter { } } -function partNeedsRecombined(i) { +function partNeedsRecombined (i) { return i % 2 === 0 } diff --git a/src/cli/option_splitter_spec.js b/src/cli/option_splitter_spec.js index 7a772b460..d60463260 100644 --- a/src/cli/option_splitter_spec.js +++ b/src/cli/option_splitter_spec.js @@ -1,6 +1,6 @@ import OptionSplitter from './option_splitter' -describe('OptionSplitter', function() { +describe('OptionSplitter', function () { const examples = [ { description: "doesn't split when nothing to split on", @@ -45,7 +45,7 @@ describe('OptionSplitter', function() { ] examples.forEach(({ description, input, output }) => { - it(description, function() { + it(description, function () { expect(OptionSplitter.split(input)).to.eql(output) }) }) diff --git a/src/cli/path_expander.js b/src/cli/path_expander.js index ebab1b337..3a83f3ced 100644 --- a/src/cli/path_expander.js +++ b/src/cli/path_expander.js @@ -5,28 +5,28 @@ import path from 'path' import Promise from 'bluebird' export default class PathExpander { - constructor(directory) { + constructor (directory) { this.directory = directory } - async expandPathsWithExtensions(paths, extensions) { + async expandPathsWithExtensions (paths, extensions) { const expandedPaths = await Promise.map(paths, async p => { - return await this.expandPathWithExtensions(p, extensions) + return this.expandPathWithExtensions(p, extensions) }) return _.uniq(_.flatten(expandedPaths)) } - async expandPathWithExtensions(p, extensions) { + async expandPathWithExtensions (p, extensions) { const fullPath = path.resolve(this.directory, p) const stats = await fs.stat(fullPath) if (stats.isDirectory()) { - return await this.expandDirectoryWithExtensions(fullPath, extensions) + return this.expandDirectoryWithExtensions(fullPath, extensions) } else { return [fullPath] } } - async expandDirectoryWithExtensions(realPath, extensions) { + async expandDirectoryWithExtensions (realPath, extensions) { let pattern = realPath + '/**/*.' if (extensions.length > 1) { pattern += '{' + extensions.join(',') + '}' diff --git a/src/cli/path_expander_spec.js b/src/cli/path_expander_spec.js index c243e81c7..04a166131 100644 --- a/src/cli/path_expander_spec.js +++ b/src/cli/path_expander_spec.js @@ -4,15 +4,15 @@ import path from 'path' import PathExpander from './path_expander' import tmp from 'tmp' -describe('PathExpander', function() { - describe('expandPathsWithExtensions', function() { - beforeEach(async function() { +describe('PathExpander', function () { + describe('expandPathsWithExtensions', function () { + beforeEach(async function () { this.tmpDir = await promisify(tmp.dir)({ unsafeCleanup: true }) this.pathExpander = new PathExpander(this.tmpDir) }) - describe('with a file', function() { - beforeEach(async function() { + describe('with a file', function () { + beforeEach(async function () { await fs.writeFile(path.join(this.tmpDir, 'a.ext'), 'content') this.results = await this.pathExpander.expandPathsWithExtensions( ['a.ext'], @@ -20,32 +20,32 @@ describe('PathExpander', function() { ) }) - it('returns the file', async function() { + it('returns the file', async function () { expect(this.results).to.eql([path.join(this.tmpDir, 'a.ext')]) }) }) - describe('with a folder', function() { - beforeEach(async function() { + describe('with a folder', function () { + beforeEach(async function () { this.subdirectoryPath = path.join(this.tmpDir, 'subdirectory') await fs.mkdir(this.subdirectoryPath) }) - describe('no files with the extension', function() { - beforeEach(async function() { + describe('no files with the extension', function () { + beforeEach(async function () { this.results = await this.pathExpander.expandPathsWithExtensions( ['subdirectory'], ['ext'] ) }) - it('returns an empty array', function() { + it('returns an empty array', function () { expect(this.results).to.eql([]) }) }) - describe('child file with the extension', function() { - beforeEach(async function() { + describe('child file with the extension', function () { + beforeEach(async function () { await fs.writeFile( path.join(this.subdirectoryPath, 'a.ext'), 'content' @@ -56,15 +56,15 @@ describe('PathExpander', function() { ) }) - it('returns the file', async function() { + it('returns the file', async function () { expect(this.results).to.eql([ path.join(this.subdirectoryPath, 'a.ext') ]) }) }) - describe('nested child file with the extension', function() { - beforeEach(async function() { + describe('nested child file with the extension', function () { + beforeEach(async function () { this.nestedSubdirectoryPath = path.join( this.subdirectoryPath, 'nested-subdirectory' @@ -80,7 +80,7 @@ describe('PathExpander', function() { ) }) - it('returns the file', async function() { + it('returns the file', async function () { expect(this.results).to.eql([ path.join(this.nestedSubdirectoryPath, 'a.ext') ]) diff --git a/src/cli/profile_loader.js b/src/cli/profile_loader.js index ca2033f6b..78c440f6c 100644 --- a/src/cli/profile_loader.js +++ b/src/cli/profile_loader.js @@ -4,11 +4,11 @@ import path from 'path' import stringArgv from 'string-argv' export default class ProfileLoader { - constructor(directory) { + constructor (directory) { this.directory = directory } - async getDefinitions() { + async getDefinitions () { const definitionsFilePath = path.join(this.directory, 'cucumber.js') const exists = await fs.exists(definitionsFilePath) if (!exists) { @@ -21,12 +21,12 @@ export default class ProfileLoader { return definitions } - async getArgv(profiles) { + async getArgv (profiles) { const definitions = await this.getDefinitions() if (profiles.length === 0 && definitions['default']) { profiles = ['default'] } - const argvs = profiles.map(function(profile) { + const argvs = profiles.map(function (profile) { if (!definitions[profile]) { throw new Error('Undefined profile: ' + profile) } diff --git a/src/cli/profile_loader_spec.js b/src/cli/profile_loader_spec.js index 8808eea7e..a463a3f54 100644 --- a/src/cli/profile_loader_spec.js +++ b/src/cli/profile_loader_spec.js @@ -4,24 +4,24 @@ import path from 'path' import ProfileLoader from './profile_loader' import tmp from 'tmp' -describe('ProfileLoader', function() { - describe('getArgv', function() { - beforeEach(async function() { +describe('ProfileLoader', function () { + describe('getArgv', function () { + beforeEach(async function () { this.tmpDir = await promisify(tmp.dir)({ unsafeCleanup: true }) this.profileLoader = new ProfileLoader(this.tmpDir) }) - describe('with no identifiers', function() { - describe('no definition file', function() { - it('returns an empty array', async function() { + describe('with no identifiers', function () { + describe('no definition file', function () { + it('returns an empty array', async function () { const result = await this.profileLoader.getArgv([]) expect(result).to.eql([]) }) }) - describe('with definition file', function() { - describe('with a default', function() { - beforeEach(async function() { + describe('with definition file', function () { + describe('with a default', function () { + beforeEach(async function () { const fileContent = 'module.exports = {default: "--opt1 --opt2"}' await fs.writeFile( path.join(this.tmpDir, 'cucumber.js'), @@ -29,14 +29,14 @@ describe('ProfileLoader', function() { ) }) - it('returns the argv for the default profile', async function() { + it('returns the argv for the default profile', async function () { const result = await this.profileLoader.getArgv([]) expect(result).to.eql(['--opt1', '--opt2']) }) }) - describe('without a default', function() { - beforeEach(async function() { + describe('without a default', function () { + beforeEach(async function () { const fileContent = 'module.exports = {profile1: "--opt1 --opt2"}' await fs.writeFile( path.join(this.tmpDir, 'cucumber.js'), @@ -44,7 +44,7 @@ describe('ProfileLoader', function() { ) }) - it('returns an empty array', async function() { + it('returns an empty array', async function () { const result = await this.profileLoader.getArgv([]) expect(result).to.eql([]) }) @@ -52,9 +52,9 @@ describe('ProfileLoader', function() { }) }) - describe('with identifiers', function() { - describe('no definition file', function() { - it('throws', async function() { + describe('with identifiers', function () { + describe('no definition file', function () { + it('throws', async function () { let thrown = false try { await this.profileLoader.getArgv(['profile1']) @@ -62,12 +62,12 @@ describe('ProfileLoader', function() { thrown = true expect(error.message).to.eql('Undefined profile: profile1') } - expect(thrown).to.be.true + expect(thrown).to.eql(true) }) }) - describe('with definition file', function() { - beforeEach(async function() { + describe('with definition file', function () { + beforeEach(async function () { const fileContent = 'module.exports = {\n' + ' profile1: "--opt1 --opt2",\n' + @@ -76,22 +76,22 @@ describe('ProfileLoader', function() { await fs.writeFile(path.join(this.tmpDir, 'cucumber.js'), fileContent) }) - describe('profile is defined', function() { - it('returns the argv for the given profile', async function() { + describe('profile is defined', function () { + it('returns the argv for the given profile', async function () { const result = await this.profileLoader.getArgv(['profile1']) expect(result).to.eql(['--opt1', '--opt2']) }) }) - describe('profile is defined and contains quoted string', function() { - it('returns the argv for the given profile', async function() { + describe('profile is defined and contains quoted string', function () { + it('returns the argv for the given profile', async function () { const result = await this.profileLoader.getArgv(['profile2']) expect(result).to.eql(['--opt3', 'some value']) }) }) - describe('profile is not defined', function() { - it('throws', async function() { + describe('profile is not defined', function () { + it('throws', async function () { let thrown = false try { await this.profileLoader.getArgv(['profile3']) @@ -99,7 +99,7 @@ describe('ProfileLoader', function() { thrown = true expect(error.message).to.eql('Undefined profile: profile3') } - expect(thrown).to.be.true + expect(thrown).to.eql(true) }) }) }) diff --git a/src/cli/run.js b/src/cli/run.js index 37eb56757..5b5a24df6 100644 --- a/src/cli/run.js +++ b/src/cli/run.js @@ -1,12 +1,12 @@ import Cli from './' import VError from 'verror' -function exitWithError(error) { +function exitWithError (error) { console.error(VError.fullStack(error)) // eslint-disable-line no-console process.exit(1) } -export default async function run() { +export default async function run () { const cwd = process.cwd() const cli = new Cli({ argv: process.argv, diff --git a/src/formatter/builder.js b/src/formatter/builder.js index 179aa5a0a..36c320fcf 100644 --- a/src/formatter/builder.js +++ b/src/formatter/builder.js @@ -13,7 +13,7 @@ import UsageFormatter from './usage_formatter' import UsageJsonFormatter from './usage_json_formatter' export default class FormatterBuilder { - static build(type, options) { + static build (type, options) { const Formatter = FormatterBuilder.getConstructorByType(type, options) const extendedOptions = { colorFns: getColorFns(options.colorsEnabled), @@ -23,7 +23,7 @@ export default class FormatterBuilder { return new Formatter(extendedOptions) } - static getConstructorByType(type, options) { + static getConstructorByType (type, options) { switch (type) { case 'event-protocol': return EventProtocolFormatter @@ -48,7 +48,7 @@ export default class FormatterBuilder { } } - static getStepDefinitionSnippetBuilder({ + static getStepDefinitionSnippetBuilder ({ cwd, snippetInterface, snippetSyntax, @@ -68,7 +68,7 @@ export default class FormatterBuilder { }) } - static loadCustomFormatter(customFormatterPath, { cwd }) { + static loadCustomFormatter (customFormatterPath, { cwd }) { const fullCustomFormatterPath = path.resolve(cwd, customFormatterPath) const CustomFormatter = require(fullCustomFormatterPath) if (typeof CustomFormatter === 'function') { diff --git a/src/formatter/event_protocol_formatter.js b/src/formatter/event_protocol_formatter.js index 170601513..210db060e 100644 --- a/src/formatter/event_protocol_formatter.js +++ b/src/formatter/event_protocol_formatter.js @@ -20,7 +20,7 @@ const EVENT_NAMES = [ ] export default class EventProtocolFormatter extends Formatter { - constructor(options) { + constructor (options) { super(options) EVENT_NAMES.forEach(eventName => { options.eventBroadcaster.on(eventName, data => @@ -34,7 +34,7 @@ export default class EventProtocolFormatter extends Formatter { this.pathRegexp = new RegExp(escapeStringRegexp(pathToRemove), 'g') } - logEvent(eventName, data) { + logEvent (eventName, data) { const text = JSON.stringify( { type: eventName, ...data }, ::this.formatJsonData @@ -42,7 +42,7 @@ export default class EventProtocolFormatter extends Formatter { this.log(text + '\n') } - formatJsonData(key, value) { + formatJsonData (key, value) { if (value instanceof Error) { return value.stack.replace(this.pathRegexp, '') } else { diff --git a/src/formatter/get_color_fns.js b/src/formatter/get_color_fns.js index 6a6291d85..db0b9a3e4 100644 --- a/src/formatter/get_color_fns.js +++ b/src/formatter/get_color_fns.js @@ -1,7 +1,7 @@ import colors from 'colors/safe' import Status from '../status' -export default function getColorFns(enabled) { +export default function getColorFns (enabled) { colors.enabled = enabled colors.setTheme({ [Status.AMBIGUOUS]: 'red', diff --git a/src/formatter/helpers/error_helpers.js b/src/formatter/helpers/error_helpers.js index 4ab7f0130..1d881f637 100644 --- a/src/formatter/helpers/error_helpers.js +++ b/src/formatter/helpers/error_helpers.js @@ -1,6 +1,6 @@ import { format } from 'assertion-error-formatter' -export function formatError(error, colorFns) { +export function formatError (error, colorFns) { return format(error, { colorFns: { diffAdded: colorFns.red, diff --git a/src/formatter/helpers/event_data_collector.js b/src/formatter/helpers/event_data_collector.js index aa30f1172..d19cb1f12 100644 --- a/src/formatter/helpers/event_data_collector.js +++ b/src/formatter/helpers/event_data_collector.js @@ -2,7 +2,7 @@ import { getStepLineToKeywordMap } from './gherkin_document_parser' import { getStepLineToPickledStepMap } from './pickle_parser' export default class EventDataCollector { - constructor(eventBroadcaster) { + constructor (eventBroadcaster) { eventBroadcaster .on('gherkin-document', ::this.storeGherkinDocument) .on('pickle-accepted', ::this.storePickle) @@ -15,11 +15,11 @@ export default class EventDataCollector { this.testCaseMap = {} // uri:line to {sourceLocation, steps, result} } - getTestCaseKey({ uri, line }) { + getTestCaseKey ({ uri, line }) { return `${uri}:${line}` } - getTestCaseData(sourceLocation) { + getTestCaseData (sourceLocation) { return { gherkinDocument: this.gherkinDocumentMap[sourceLocation.uri], pickle: this.pickleMap[this.getTestCaseKey(sourceLocation)], @@ -27,7 +27,7 @@ export default class EventDataCollector { } } - getTestStepData({ testCase: { sourceLocation }, index }) { + getTestStepData ({ testCase: { sourceLocation }, index }) { const { gherkinDocument, pickle, testCase } = this.getTestCaseData( sourceLocation ) @@ -40,20 +40,20 @@ export default class EventDataCollector { return result } - storeGherkinDocument({ document, uri }) { + storeGherkinDocument ({ document, uri }) { this.gherkinDocumentMap[uri] = document } - storePickle({ pickle, uri }) { + storePickle ({ pickle, uri }) { this.pickleMap[`${uri}:${pickle.locations[0].line}`] = pickle } - storeTestCase({ sourceLocation, steps }) { + storeTestCase ({ sourceLocation, steps }) { const key = this.getTestCaseKey(sourceLocation) this.testCaseMap[key] = { sourceLocation, steps } } - storeTestStepAttachment({ index, testCase, data, media }) { + storeTestStepAttachment ({ index, testCase, data, media }) { const key = this.getTestCaseKey(testCase.sourceLocation) const step = this.testCaseMap[key].steps[index] if (!step.attachments) { @@ -62,12 +62,12 @@ export default class EventDataCollector { step.attachments.push({ data, media }) } - storeTestStepResult({ index, testCase, result }) { + storeTestStepResult ({ index, testCase, result }) { const key = this.getTestCaseKey(testCase.sourceLocation) this.testCaseMap[key].steps[index].result = result } - storeTestCaseResult({ sourceLocation, result }) { + storeTestCaseResult ({ sourceLocation, result }) { const key = this.getTestCaseKey(sourceLocation) this.testCaseMap[key].result = result } diff --git a/src/formatter/helpers/gherkin_document_parser.js b/src/formatter/helpers/gherkin_document_parser.js index b6dc5e1d9..d3fe9a861 100644 --- a/src/formatter/helpers/gherkin_document_parser.js +++ b/src/formatter/helpers/gherkin_document_parser.js @@ -1,6 +1,6 @@ import _ from 'lodash' -export function getStepLineToKeywordMap(gherkinDocument) { +export function getStepLineToKeywordMap (gherkinDocument) { return _.chain(gherkinDocument.feature.children) .map('steps') .flatten() @@ -9,7 +9,7 @@ export function getStepLineToKeywordMap(gherkinDocument) { .value() } -export function getScenarioLineToDescriptionMap(gherkinDocument) { +export function getScenarioLineToDescriptionMap (gherkinDocument) { return _.chain(gherkinDocument.feature.children) .map(element => [element.location.line, element.description]) .fromPairs() diff --git a/src/formatter/helpers/issue_helpers.js b/src/formatter/helpers/issue_helpers.js index f2a7fdd66..a882442c6 100644 --- a/src/formatter/helpers/issue_helpers.js +++ b/src/formatter/helpers/issue_helpers.js @@ -28,7 +28,7 @@ const IS_ISSUE = { [Status.UNDEFINED]: true } -function formatDataTable(arg) { +function formatDataTable (arg) { const rows = arg.rows.map(row => { return row.cells.map(cell => { return cell.value.replace(/\\/g, '\\\\').replace(/\n/g, '\\n') @@ -62,11 +62,11 @@ function formatDataTable(arg) { return table.toString() } -function formatDocString(arg) { +function formatDocString (arg) { return '"""\n' + arg.content + '\n"""' } -function formatStep({ +function formatStep ({ colorFns, isBeforeHook, keyword, @@ -117,11 +117,11 @@ function formatStep({ return text } -export function isIssue(status) { +export function isIssue (status) { return IS_ISSUE[status] } -export function formatIssue({ +export function formatIssue ({ colorFns, gherkinDocument, number, diff --git a/src/formatter/helpers/issue_helpers_spec.js b/src/formatter/helpers/issue_helpers_spec.js index 9c23dc9d0..d503c41fc 100644 --- a/src/formatter/helpers/issue_helpers_spec.js +++ b/src/formatter/helpers/issue_helpers_spec.js @@ -4,8 +4,8 @@ import { formatIssue } from './issue_helpers' import figures from 'figures' import Gherkin from 'gherkin' -describe('IssueHelpers', function() { - beforeEach(function() { +describe('IssueHelpers', function () { + beforeEach(function () { const gherkinDocument = new Gherkin.Parser().parse( 'Feature: my feature\n' + ' Scenario: my scenario\n' + @@ -43,9 +43,9 @@ describe('IssueHelpers', function() { this.skippedStepResult = { status: Status.SKIPPED } }) - describe('formatIssue', function() { - describe('returns the formatted scenario', function() { - beforeEach(function() { + describe('formatIssue', function () { + describe('returns the formatted scenario', function () { + beforeEach(function () { this.testCase.steps[0].result = this.passedStepResult this.testCase.steps[1] = { actionLocation: { line: 3, uri: 'steps.js' }, @@ -59,7 +59,7 @@ describe('IssueHelpers', function() { this.formattedIssue = formatIssue(this.options) }) - it('prints the scenario', function() { + it('prints the scenario', function () { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + @@ -70,8 +70,8 @@ describe('IssueHelpers', function() { }) }) - describe('with an ambiguous step', function() { - beforeEach(function() { + describe('with an ambiguous step', function () { + beforeEach(function () { this.testCase.steps[0].result = this.passedStepResult this.testCase.steps[1] = { actionLocation: { line: 3, uri: 'steps.js' }, @@ -88,7 +88,7 @@ describe('IssueHelpers', function() { this.formattedIssue = formatIssue(this.options) }) - it('returns the formatted scenario', function() { + it('returns the formatted scenario', function () { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + @@ -101,8 +101,8 @@ describe('IssueHelpers', function() { }) }) - describe('with an undefined step', function() { - beforeEach(function() { + describe('with an undefined step', function () { + beforeEach(function () { this.testCase.steps[0].result = this.passedStepResult this.testCase.steps[1] = { sourceLocation: { line: 4, uri: 'a.feature' }, @@ -112,7 +112,7 @@ describe('IssueHelpers', function() { this.formattedIssue = formatIssue(this.options) }) - it('returns the formatted scenario', function() { + it('returns the formatted scenario', function () { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + @@ -126,8 +126,8 @@ describe('IssueHelpers', function() { }) }) - describe('with a pending step', function() { - beforeEach(function() { + describe('with a pending step', function () { + beforeEach(function () { this.testCase.steps[0].result = this.passedStepResult this.testCase.steps[1] = { actionLocation: { line: 3, uri: 'steps.js' }, @@ -138,7 +138,7 @@ describe('IssueHelpers', function() { this.formattedIssue = formatIssue(this.options) }) - it('returns the formatted scenario', function() { + it('returns the formatted scenario', function () { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + @@ -149,8 +149,8 @@ describe('IssueHelpers', function() { }) }) - describe('step with data table', function() { - beforeEach(function() { + describe('step with data table', function () { + beforeEach(function () { const gherkinDocument = new Gherkin.Parser().parse( 'Feature: my feature\n' + ' Scenario: my scenario\n' + @@ -174,7 +174,7 @@ describe('IssueHelpers', function() { this.formattedIssue = formatIssue(this.options) }) - it('returns the formatted scenario', function() { + it('returns the formatted scenario', function () { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + @@ -188,8 +188,8 @@ describe('IssueHelpers', function() { }) }) - describe('step with doc string', function() { - beforeEach(function() { + describe('step with doc string', function () { + beforeEach(function () { const gherkinDocument = new Gherkin.Parser().parse( 'Feature: my feature\n' + ' Scenario: my scenario\n' + @@ -216,7 +216,7 @@ describe('IssueHelpers', function() { this.formattedIssue = formatIssue(this.options) }) - it('returns the formatted scenario', function() { + it('returns the formatted scenario', function () { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + diff --git a/src/formatter/helpers/keyword_type.js b/src/formatter/helpers/keyword_type.js index 2b1076d3e..1bb9dfd36 100644 --- a/src/formatter/helpers/keyword_type.js +++ b/src/formatter/helpers/keyword_type.js @@ -9,7 +9,7 @@ const types = { export default types -export function getStepKeywordType({ keyword, language, previousKeywordType }) { +export function getStepKeywordType ({ keyword, language, previousKeywordType }) { const dialect = Gherkin.DIALECTS[language] const type = _.find(['given', 'when', 'then', 'and', 'but'], key => { return _.includes(dialect[key], keyword) diff --git a/src/formatter/helpers/keyword_type_spec.js b/src/formatter/helpers/keyword_type_spec.js index c27c949ea..1a16ec8a2 100644 --- a/src/formatter/helpers/keyword_type_spec.js +++ b/src/formatter/helpers/keyword_type_spec.js @@ -1,67 +1,67 @@ import KeywordType, { getStepKeywordType } from './keyword_type' -describe('KeywordType', function() { - describe('constants', function() { - it('exposes the proper constants', function() { +describe('KeywordType', function () { + describe('constants', function () { + it('exposes the proper constants', function () { expect(KeywordType).to.include.keys(['EVENT', 'OUTCOME', 'PRECONDITION']) }) }) - describe('getStepKeywordType()', function() { - describe('keyword is Given', function() { - beforeEach(function() { + describe('getStepKeywordType()', function () { + describe('keyword is Given', function () { + beforeEach(function () { this.keywordType = getStepKeywordType({ keyword: 'Given ', language: 'en' }) }) - it('returns precondition', function() { + it('returns precondition', function () { expect(this.keywordType).to.eql(KeywordType.PRECONDITION) }) }) - describe('keyword is When', function() { - beforeEach(function() { + describe('keyword is When', function () { + beforeEach(function () { this.keywordType = getStepKeywordType({ keyword: 'When ', language: 'en' }) }) - it('returns event', function() { + it('returns event', function () { expect(this.keywordType).to.eql(KeywordType.EVENT) }) }) - describe('keyword is Then', function() { - beforeEach(function() { + describe('keyword is Then', function () { + beforeEach(function () { this.keywordType = getStepKeywordType({ keyword: 'Then ', language: 'en' }) }) - it('returns outcome', function() { + it('returns outcome', function () { expect(this.keywordType).to.eql(KeywordType.OUTCOME) }) }) - describe('keyword is And, no previous step', function() { - beforeEach(function() { + describe('keyword is And, no previous step', function () { + beforeEach(function () { this.keywordType = getStepKeywordType({ keyword: 'And ', language: 'en' }) }) - it('returns precondition', function() { + it('returns precondition', function () { expect(this.keywordType).to.eql(KeywordType.PRECONDITION) }) }) - describe('keyword is And, previous keyword type is event', function() { - beforeEach(function() { + describe('keyword is And, previous keyword type is event', function () { + beforeEach(function () { this.keywordType = getStepKeywordType({ keyword: 'And ', language: 'en', @@ -69,26 +69,26 @@ describe('KeywordType', function() { }) }) - it('returns event', function() { + it('returns event', function () { expect(this.keywordType).to.eql(KeywordType.EVENT) }) }) - describe('keyword is But, no previous step', function() { - beforeEach(function() { + describe('keyword is But, no previous step', function () { + beforeEach(function () { this.keywordType = getStepKeywordType({ keyword: 'But ', language: 'en' }) }) - it('returns precondition', function() { + it('returns precondition', function () { expect(this.keywordType).to.eql(KeywordType.PRECONDITION) }) }) - describe('keyword is But, previous keyword type is outcome', function() { - beforeEach(function() { + describe('keyword is But, previous keyword type is outcome', function () { + beforeEach(function () { this.keywordType = getStepKeywordType({ keyword: 'But ', language: 'en', @@ -96,13 +96,13 @@ describe('KeywordType', function() { }) }) - it('returns outcome', function() { + it('returns outcome', function () { expect(this.keywordType).to.eql(KeywordType.OUTCOME) }) }) - describe('keyword is unknown', function() { - beforeEach(function() { + describe('keyword is unknown', function () { + beforeEach(function () { this.keywordType = getStepKeywordType({ index: 0, language: 'en', @@ -110,7 +110,7 @@ describe('KeywordType', function() { }) }) - it('returns precondition', function() { + it('returns precondition', function () { expect(this.keywordType).to.eql(KeywordType.PRECONDITION) }) }) diff --git a/src/formatter/helpers/location_helpers.js b/src/formatter/helpers/location_helpers.js index a78a3e25e..b5ee98cfc 100644 --- a/src/formatter/helpers/location_helpers.js +++ b/src/formatter/helpers/location_helpers.js @@ -1,3 +1,3 @@ -export function formatLocation(obj) { +export function formatLocation (obj) { return `${obj.uri}:${obj.line}` } diff --git a/src/formatter/helpers/pickle_parser.js b/src/formatter/helpers/pickle_parser.js index 856abaf43..ee75185a1 100644 --- a/src/formatter/helpers/pickle_parser.js +++ b/src/formatter/helpers/pickle_parser.js @@ -1,6 +1,6 @@ import _ from 'lodash' -export function getScenarioDescription({ +export function getScenarioDescription ({ pickle, scenarioLineToDescriptionMap }) { @@ -11,7 +11,7 @@ export function getScenarioDescription({ .value() } -export function getStepKeyword({ pickleStep, stepLineToKeywordMap }) { +export function getStepKeyword ({ pickleStep, stepLineToKeywordMap }) { return _.chain(pickleStep.locations) .map(({ line }) => stepLineToKeywordMap[line]) .compact() @@ -19,7 +19,7 @@ export function getStepKeyword({ pickleStep, stepLineToKeywordMap }) { .value() } -export function getStepLineToPickledStepMap(pickle) { +export function getStepLineToPickledStepMap (pickle) { return _.chain(pickle.steps) .map(step => [_.last(step.locations).line, step]) .fromPairs() diff --git a/src/formatter/helpers/step_result_helpers.js b/src/formatter/helpers/step_result_helpers.js index 04f0b0273..b54a49e5b 100644 --- a/src/formatter/helpers/step_result_helpers.js +++ b/src/formatter/helpers/step_result_helpers.js @@ -2,19 +2,19 @@ import { formatError } from './error_helpers' import Status from '../../status' import indentString from 'indent-string' -function getAmbiguousStepResultMessage({ colorFns, testStep }) { +function getAmbiguousStepResultMessage ({ colorFns, testStep }) { return colorFns.ambiguous(testStep.result.exception) } -function getFailedStepResultMessage({ colorFns, testStep }) { +function getFailedStepResultMessage ({ colorFns, testStep }) { return formatError(testStep.result.exception, colorFns) } -function getPendingStepResultMessage({ colorFns }) { +function getPendingStepResultMessage ({ colorFns }) { return colorFns.pending('Pending') } -export function getStepMessage({ +export function getStepMessage ({ colorFns, keywordType, snippetBuilder, @@ -38,7 +38,7 @@ export function getStepMessage({ } } -function getUndefinedStepResultMessage({ +function getUndefinedStepResultMessage ({ colorFns, keywordType, snippetBuilder, diff --git a/src/formatter/helpers/summary_helpers.js b/src/formatter/helpers/summary_helpers.js index d7ced0b4c..73a6d1512 100644 --- a/src/formatter/helpers/summary_helpers.js +++ b/src/formatter/helpers/summary_helpers.js @@ -11,7 +11,7 @@ const STATUS_REPORT_ORDER = [ Status.PASSED ] -export function formatSummary({ colorFns, testCaseMap, testRun }) { +export function formatSummary ({ colorFns, testCaseMap, testRun }) { const testCaseResults = [] const testStepResults = [] _.each(testCaseMap, ({ result, steps }) => { @@ -36,7 +36,7 @@ export function formatSummary({ colorFns, testCaseMap, testRun }) { return [scenarioSummary, stepSummary, durationSummary].join('\n') } -function getCountSummary({ colorFns, objects, type }) { +function getCountSummary ({ colorFns, objects, type }) { const counts = _.chain(objects) .groupBy('status') .mapValues('length') @@ -55,7 +55,7 @@ function getCountSummary({ colorFns, objects, type }) { return text } -function getDuration(milliseconds) { +function getDuration (milliseconds) { const start = new Date(0) const end = new Date(milliseconds) const duration = new Duration(start, end) diff --git a/src/formatter/helpers/summary_helpers_spec.js b/src/formatter/helpers/summary_helpers_spec.js index 738994e49..925b6693f 100644 --- a/src/formatter/helpers/summary_helpers_spec.js +++ b/src/formatter/helpers/summary_helpers_spec.js @@ -2,9 +2,9 @@ import getColorFns from '../get_color_fns' import { formatSummary } from './summary_helpers' import Status from '../../status' -describe('SummaryHelpers', function() { - describe('formatSummary', function() { - beforeEach(function() { +describe('SummaryHelpers', function () { + describe('formatSummary', function () { + beforeEach(function () { this.testCaseMap = {} this.testRun = { result: { duration: 0 } } this.options = { @@ -14,20 +14,20 @@ describe('SummaryHelpers', function() { } }) - describe('with no test cases', function() { - beforeEach(function() { + describe('with no test cases', function () { + beforeEach(function () { this.result = formatSummary(this.options) }) - it('outputs step totals, scenario totals, and duration', function() { + it('outputs step totals, scenario totals, and duration', function () { expect(this.result).to.contain( '0 scenarios\n' + '0 steps\n' + '0m00.000s\n' ) }) }) - describe('with one passing scenario with one passing step', function() { - beforeEach(function() { + describe('with one passing scenario with one passing step', function () { + beforeEach(function () { this.testCaseMap['a.feature:1'] = { steps: [ { @@ -40,15 +40,15 @@ describe('SummaryHelpers', function() { this.result = formatSummary(this.options) }) - it('outputs the totals and number of each status', function() { + it('outputs the totals and number of each status', function () { expect(this.result).to.contain( '1 scenario (1 passed)\n' + '1 step (1 passed)\n' + '0m00.000s\n' ) }) }) - describe('with one passing scenario with one step and hook', function() { - beforeEach(function() { + describe('with one passing scenario with one step and hook', function () { + beforeEach(function () { this.testCaseMap['a.feature:1'] = { steps: [ { result: { status: Status.PASSED } }, @@ -62,15 +62,15 @@ describe('SummaryHelpers', function() { this.result = formatSummary(this.options) }) - it('filter out the hooks', function() { + it('filter out the hooks', function () { expect(this.result).to.contain( '1 scenario (1 passed)\n' + '1 step (1 passed)\n' + '0m00.000s\n' ) }) }) - describe('with one passing scenario with multiple passing steps', function() { - beforeEach(function() { + describe('with one passing scenario with multiple passing steps', function () { + beforeEach(function () { this.testCaseMap['a.feature:1'] = { steps: [ { @@ -87,15 +87,15 @@ describe('SummaryHelpers', function() { this.result = formatSummary(this.options) }) - it('outputs the totals and number of each status', function() { + it('outputs the totals and number of each status', function () { expect(this.result).to.contain( '1 scenario (1 passed)\n' + '2 steps (2 passed)\n' + '0m00.000s\n' ) }) }) - describe('with one of every kind of scenario', function() { - beforeEach(function() { + describe('with one of every kind of scenario', function () { + beforeEach(function () { this.testCaseMap['a.feature:1'] = { steps: [ { @@ -153,7 +153,7 @@ describe('SummaryHelpers', function() { this.result = formatSummary(this.options) }) - it('outputs the totals and number of each status', function() { + it('outputs the totals and number of each status', function () { expect(this.result).to.contain( '6 scenarios (1 failed, 1 ambiguous, 1 undefined, 1 pending, 1 skipped, 1 passed)\n' + '6 steps (1 failed, 1 ambiguous, 1 undefined, 1 pending, 1 skipped, 1 passed)\n' + @@ -162,39 +162,39 @@ describe('SummaryHelpers', function() { }) }) - describe('with a duration of 123 milliseconds', function() { - beforeEach(function() { + describe('with a duration of 123 milliseconds', function () { + beforeEach(function () { this.testRun.result.duration = 123 this.result = formatSummary(this.options) }) - it('outputs the duration as 0m00.123s', function() { + it('outputs the duration as 0m00.123s', function () { expect(this.result).to.contain( '0 scenarios\n' + '0 steps\n' + '0m00.123s\n' ) }) }) - describe('with a duration of 12.3 seconds', function() { - beforeEach(function() { + describe('with a duration of 12.3 seconds', function () { + beforeEach(function () { this.testRun.result.duration = 123 * 100 this.result = formatSummary(this.options) }) - it('outputs the duration as 0m12.300s', function() { + it('outputs the duration as 0m12.300s', function () { expect(this.result).to.contain( '0 scenarios\n' + '0 steps\n' + '0m12.300s\n' ) }) }) - describe('with a duration of 120.3 seconds', function() { - beforeEach(function() { + describe('with a duration of 120.3 seconds', function () { + beforeEach(function () { this.testRun.result.duration = 123 * 1000 this.result = formatSummary(this.options) }) - it('outputs the duration as 2m03.000s', function() { + it('outputs the duration as 2m03.000s', function () { expect(this.result).to.contain( '0 scenarios\n' + '0 steps\n' + '2m03.000s\n' ) diff --git a/src/formatter/helpers/usage_helpers/index.js b/src/formatter/helpers/usage_helpers/index.js index e36d17824..b0d8cb350 100644 --- a/src/formatter/helpers/usage_helpers/index.js +++ b/src/formatter/helpers/usage_helpers/index.js @@ -2,7 +2,7 @@ import _ from 'lodash' import { formatLocation } from '../location_helpers' import { getStepLineToPickledStepMap } from '../pickle_parser' -function buildEmptyMapping(stepDefinitions) { +function buildEmptyMapping (stepDefinitions) { const mapping = {} stepDefinitions.forEach(stepDefinition => { const location = formatLocation(stepDefinition) @@ -16,7 +16,7 @@ function buildEmptyMapping(stepDefinitions) { return mapping } -function buildMapping({ stepDefinitions, eventDataCollector }) { +function buildMapping ({ stepDefinitions, eventDataCollector }) { const mapping = buildEmptyMapping(stepDefinitions) _.each(eventDataCollector.testCaseMap, testCase => { const { pickle } = eventDataCollector.getTestCaseData( @@ -44,7 +44,7 @@ function buildMapping({ stepDefinitions, eventDataCollector }) { return mapping } -function invertNumber(key) { +function invertNumber (key) { return obj => { const value = obj[key] if (isFinite(value)) { @@ -54,7 +54,7 @@ function invertNumber(key) { } } -function buildResult(mapping) { +function buildResult (mapping) { return _.chain(mapping) .map(({ line, matches, pattern, uri }) => { const sortedMatches = _.sortBy(matches, [ @@ -72,7 +72,7 @@ function buildResult(mapping) { .value() } -export function getUsage({ stepDefinitions, eventDataCollector }) { +export function getUsage ({ stepDefinitions, eventDataCollector }) { const mapping = buildMapping({ stepDefinitions, eventDataCollector }) return buildResult(mapping) } diff --git a/src/formatter/helpers/usage_helpers/index_spec.js b/src/formatter/helpers/usage_helpers/index_spec.js index 744dfe205..4882b6537 100644 --- a/src/formatter/helpers/usage_helpers/index_spec.js +++ b/src/formatter/helpers/usage_helpers/index_spec.js @@ -3,9 +3,9 @@ import EventEmitter from 'events' import Gherkin from 'gherkin' import EventDataCollector from '../event_data_collector' -describe('Usage Helpers', function() { - describe('getUsage', function() { - beforeEach(function() { +describe('Usage Helpers', function () { + describe('getUsage', function () { + beforeEach(function () { this.eventBroadcaster = new EventEmitter() this.eventDataCollector = new EventDataCollector(this.eventBroadcaster) this.stepDefinitions = [] @@ -16,19 +16,19 @@ describe('Usage Helpers', function() { }) }) - describe('no step definitions', function() { - describe('without steps', function() { - beforeEach(function() { + describe('no step definitions', function () { + describe('without steps', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-run-finished') }) - it('returns an empty array', function() { + it('returns an empty array', function () { expect(this.getResult()).to.eql([]) }) }) - describe('with a step', function() { - beforeEach(function() { + describe('with a step', function () { + beforeEach(function () { const events = Gherkin.generateEvents( 'Feature: a\nScenario: b\nWhen abc\nThen ab', 'a.feature' @@ -64,7 +64,7 @@ describe('Usage Helpers', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('returns an empty array', function() { + it('returns an empty array', function () { expect(this.getResult()).to.eql([]) }) }) diff --git a/src/formatter/index.js b/src/formatter/index.js index fd823848d..9e248d200 100644 --- a/src/formatter/index.js +++ b/src/formatter/index.js @@ -1,7 +1,7 @@ import _ from 'lodash' export default class Formatter { - constructor(options) { + constructor (options) { _.assign( this, _.pick(options, [ diff --git a/src/formatter/json_formatter.js b/src/formatter/json_formatter.js index 28d5c8c0c..9b4052eee 100644 --- a/src/formatter/json_formatter.js +++ b/src/formatter/json_formatter.js @@ -17,16 +17,16 @@ const { } = PickleParser export default class JsonFormatter extends Formatter { - constructor(options) { + constructor (options) { super(options) options.eventBroadcaster.on('test-run-finished', ::this.onTestRunFinished) } - convertNameToId(obj) { + convertNameToId (obj) { return obj.name.replace(/ /g, '-').toLowerCase() } - formatDataTable(dataTable) { + formatDataTable (dataTable) { return { rows: dataTable.rows.map(row => { return { cells: _.map(row.cells, 'value') } @@ -34,14 +34,14 @@ export default class JsonFormatter extends Formatter { } } - formatDocString(docString) { + formatDocString (docString) { return { content: docString.content, line: docString.location.line } } - formatStepArguments(stepArguments) { + formatStepArguments (stepArguments) { const iterator = buildStepArgumentIterator({ dataTable: this.formatDataTable.bind(this), docString: this.formatDocString.bind(this) @@ -49,7 +49,7 @@ export default class JsonFormatter extends Formatter { return _.map(stepArguments, iterator) } - onTestRunFinished() { + onTestRunFinished () { const groupedTestCases = {} _.each(this.eventDataCollector.testCaseMap, testCase => { const { sourceLocation: { uri } } = testCase @@ -92,7 +92,7 @@ export default class JsonFormatter extends Formatter { this.log(JSON.stringify(features, null, 2)) } - getFeatureData(feature, uri) { + getFeatureData (feature, uri) { return { description: feature.description, keyword: feature.keyword, @@ -104,7 +104,7 @@ export default class JsonFormatter extends Formatter { } } - getScenarioData({ featureId, pickle, scenarioLineToDescriptionMap }) { + getScenarioData ({ featureId, pickle, scenarioLineToDescriptionMap }) { const description = getScenarioDescription({ pickle, scenarioLineToDescriptionMap @@ -120,7 +120,7 @@ export default class JsonFormatter extends Formatter { } } - getStepData({ + getStepData ({ isBeforeHook, stepLineToKeywordMap, stepLineToPickledStepMap, @@ -162,7 +162,7 @@ export default class JsonFormatter extends Formatter { return data } - getTags(obj) { + getTags (obj) { return _.map(obj.tags, tagData => { return { name: tagData.name, line: tagData.location.line } }) diff --git a/src/formatter/json_formatter_spec.js b/src/formatter/json_formatter_spec.js index 2f7cd06f0..5eb0d594b 100644 --- a/src/formatter/json_formatter_spec.js +++ b/src/formatter/json_formatter_spec.js @@ -4,8 +4,8 @@ import EventEmitter from 'events' import Gherkin from 'gherkin' import { EventDataCollector } from './helpers' -describe('JsonFormatter', function() { - beforeEach(function() { +describe('JsonFormatter', function () { + beforeEach(function () { this.eventBroadcaster = new EventEmitter() this.output = '' const logFn = data => { @@ -18,18 +18,18 @@ describe('JsonFormatter', function() { }) }) - describe('no features', function() { - beforeEach(function() { + describe('no features', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs an empty array', function() { + it('outputs an empty array', function () { expect(JSON.parse(this.output)).to.eql([]) }) }) - describe('one scenario with one step', function() { - beforeEach(function() { + describe('one scenario with one step', function () { + beforeEach(function () { const events = Gherkin.generateEvents( '@tag1 @tag2\n' + 'Feature: my feature\n' + @@ -52,8 +52,8 @@ describe('JsonFormatter', function() { this.testCase = { sourceLocation: { uri: 'a.feature', line: 4 } } }) - describe('passed', function() { - beforeEach(function() { + describe('passed', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -74,7 +74,7 @@ describe('JsonFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the feature', function() { + it('outputs the feature', function () { expect(JSON.parse(this.output)).to.eql([ { description: 'my feature description', @@ -112,8 +112,8 @@ describe('JsonFormatter', function() { }) }) - describe('failed', function() { - beforeEach(function() { + describe('failed', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -134,7 +134,7 @@ describe('JsonFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('includes the error message', function() { + it('includes the error message', function () { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].result).to.eql({ status: 'failed', @@ -144,8 +144,8 @@ describe('JsonFormatter', function() { }) }) - describe('with a step definition', function() { - beforeEach(function() { + describe('with a step definition', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -167,7 +167,7 @@ describe('JsonFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step with a match attribute', function() { + it('outputs the step with a match attribute', function () { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].match).to.eql({ location: 'steps.js:10' @@ -175,8 +175,8 @@ describe('JsonFormatter', function() { }) }) - describe('with hooks', function() { - beforeEach(function() { + describe('with hooks', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -199,25 +199,25 @@ describe('JsonFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the before hook with special properties', function() { + it('outputs the before hook with special properties', function () { const features = JSON.parse(this.output) const beforeHook = features[0].elements[0].steps[0] expect(beforeHook).to.not.have.ownProperty('line') expect(beforeHook.keyword).to.eql('Before') - expect(beforeHook.hidden).to.be.true + expect(beforeHook.hidden).to.eql(true) }) - it('outputs the after hook with special properties', function() { + it('outputs the after hook with special properties', function () { const features = JSON.parse(this.output) const beforeHook = features[0].elements[0].steps[2] expect(beforeHook).to.not.have.ownProperty('line') expect(beforeHook.keyword).to.eql('After') - expect(beforeHook.hidden).to.be.true + expect(beforeHook.hidden).to.eql(true) }) }) - describe('with attachments', function() { - beforeEach(function() { + describe('with attachments', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -250,7 +250,7 @@ describe('JsonFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step with embeddings', function() { + it('outputs the step with embeddings', function () { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].embeddings).to.eql([ { data: 'first data', mime_type: 'first media type' }, @@ -260,8 +260,8 @@ describe('JsonFormatter', function() { }) }) - describe('one scenario with one step with a doc string', function() { - beforeEach(function() { + describe('one scenario with one step with a doc string', function () { + beforeEach(function () { const events = Gherkin.generateEvents( 'Feature: my feature\n' + ' Scenario: my scenario\n' + @@ -303,7 +303,7 @@ describe('JsonFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the doc string as a step argument', function() { + it('outputs the doc string as a step argument', function () { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].arguments).to.eql([ { @@ -314,8 +314,8 @@ describe('JsonFormatter', function() { }) }) - describe('one scenario with one step with a data table string', function() { - beforeEach(function() { + describe('one scenario with one step with a data table string', function () { + beforeEach(function () { const events = Gherkin.generateEvents( 'Feature: my feature\n' + ' Scenario: my scenario\n' + @@ -357,7 +357,7 @@ describe('JsonFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the data table as a step argument', function() { + it('outputs the data table as a step argument', function () { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].arguments).to.eql([ { diff --git a/src/formatter/progress_bar_formatter.js b/src/formatter/progress_bar_formatter.js index 521fe706a..af10621c3 100644 --- a/src/formatter/progress_bar_formatter.js +++ b/src/formatter/progress_bar_formatter.js @@ -4,7 +4,7 @@ import ProgressBar from 'progress' // Inspired by https://github.com/thekompanee/fuubar and https://github.com/martinciu/fuubar-cucumber export default class ProgressBarFormatter extends Formatter { - constructor(options) { + constructor (options) { super(options) options.eventBroadcaster .on('pickle-accepted', ::this.incrementStepCount) @@ -16,11 +16,11 @@ export default class ProgressBarFormatter extends Formatter { this.issueCount = 0 } - incrementStepCount({ pickle }) { + incrementStepCount ({ pickle }) { this.numberOfSteps += pickle.steps.length } - initializeProgressBar() { + initializeProgressBar () { this.progressBar = new ProgressBar(':current/:total steps [:bar] ', { clear: true, incomplete: ' ', @@ -30,14 +30,14 @@ export default class ProgressBarFormatter extends Formatter { }) } - logProgress({ index, testCase: { sourceLocation } }) { + logProgress ({ index, testCase: { sourceLocation } }) { const { testCase } = this.eventDataCollector.getTestCaseData(sourceLocation) if (testCase.steps[index].sourceLocation) { this.progressBar.tick() } } - logErrorIfNeeded({ sourceLocation, result }) { + logErrorIfNeeded ({ sourceLocation, result }) { if (isIssue(result.status)) { this.issueCount += 1 const { @@ -58,7 +58,7 @@ export default class ProgressBarFormatter extends Formatter { } } - logSummary(testRun) { + logSummary (testRun) { this.log( formatSummary({ colorFns: this.colorFns, diff --git a/src/formatter/progress_bar_formatter_spec.js b/src/formatter/progress_bar_formatter_spec.js index 00bbba876..b578950fd 100644 --- a/src/formatter/progress_bar_formatter_spec.js +++ b/src/formatter/progress_bar_formatter_spec.js @@ -5,8 +5,8 @@ import { EventEmitter } from 'events' import Gherkin from 'gherkin' import { EventDataCollector } from './helpers' -describe('ProgressBarFormatter', function() { - beforeEach(function() { +describe('ProgressBarFormatter', function () { + beforeEach(function () { this.eventBroadcaster = new EventEmitter() this.output = '' const logFn = data => { @@ -24,8 +24,8 @@ describe('ProgressBarFormatter', function() { }) }) - describe('pickle-accepted, test-case-started', function() { - beforeEach(function() { + describe('pickle-accepted, test-case-started', function () { + beforeEach(function () { this.eventBroadcaster.emit('pickle-accepted', { pickle: { locations: [{ line: 2 }], steps: [1, 2, 3] }, uri: 'path/to/feature' @@ -37,13 +37,13 @@ describe('ProgressBarFormatter', function() { this.eventBroadcaster.emit('test-case-started') }) - it('initializes a progress bar with the total number of steps', function() { + it('initializes a progress bar with the total number of steps', function () { expect(this.progressBarFormatter.progressBar.total).to.eql(5) }) }) - describe('test-step-finished', function() { - beforeEach(function() { + describe('test-step-finished', function () { + beforeEach(function () { this.progressBarFormatter.progressBar = { interrupt: sinon.stub(), tick: sinon.stub() @@ -60,8 +60,8 @@ describe('ProgressBarFormatter', function() { }) }) - describe('step is a hook', function() { - beforeEach(function() { + describe('step is a hook', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: { @@ -71,14 +71,13 @@ describe('ProgressBarFormatter', function() { }) }) - it('does not increase the progress bar percentage', function() { - expect(this.progressBarFormatter.progressBar.tick).not.to.have.been - .called + it('does not increase the progress bar percentage', function () { + expect(this.progressBarFormatter.progressBar.tick).to.have.callCount(0) }) }) - describe('step is a normal step', function() { - beforeEach(function() { + describe('step is a normal step', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-step-finished', { index: 1, testCase: { @@ -88,15 +87,14 @@ describe('ProgressBarFormatter', function() { }) }) - it('increases the progress bar percentage', function() { - expect(this.progressBarFormatter.progressBar.tick).to.have.been - .calledOnce + it('increases the progress bar percentage', function () { + expect(this.progressBarFormatter.progressBar.tick).to.have.callCount(1) }) }) }) - describe('test-case-finished', function() { - beforeEach(function() { + describe('test-case-finished', function () { + beforeEach(function () { this.progressBarFormatter.progressBar = { interrupt: sinon.stub(), tick: sinon.stub() @@ -118,8 +116,8 @@ describe('ProgressBarFormatter', function() { this.testCase = { sourceLocation: { uri: 'a.feature', line: 2 } } }) - describe('ambiguous', function() { - beforeEach(function() { + describe('ambiguous', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -145,14 +143,13 @@ describe('ProgressBarFormatter', function() { }) }) - it('prints the error', function() { - expect(this.progressBarFormatter.progressBar.interrupt).to.have.been - .calledOnce + it('prints the error', function () { + expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(1) }) }) - describe('failed', function() { - beforeEach(function() { + describe('failed', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -173,14 +170,13 @@ describe('ProgressBarFormatter', function() { }) }) - it('prints the error', function() { - expect(this.progressBarFormatter.progressBar.interrupt).to.have.been - .calledOnce + it('prints the error', function () { + expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(1) }) }) - describe('passed', function() { - beforeEach(function() { + describe('passed', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -201,14 +197,13 @@ describe('ProgressBarFormatter', function() { }) }) - it('does not print anything', function() { - expect(this.progressBarFormatter.progressBar.interrupt).not.to.have.been - .called + it('does not print anything', function () { + expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(0) }) }) - describe('pending', function() { - beforeEach(function() { + describe('pending', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -229,14 +224,13 @@ describe('ProgressBarFormatter', function() { }) }) - it('prints the warning', function() { - expect(this.progressBarFormatter.progressBar.interrupt).to.have.been - .calledOnce + it('prints the warning', function () { + expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(1) }) }) - describe('skipped', function() { - beforeEach(function() { + describe('skipped', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -257,14 +251,13 @@ describe('ProgressBarFormatter', function() { }) }) - it('does not print anything', function() { - expect(this.progressBarFormatter.progressBar.interrupt).not.to.have.been - .called + it('does not print anything', function () { + expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(0) }) }) - describe('undefined', function() { - beforeEach(function() { + describe('undefined', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -284,21 +277,20 @@ describe('ProgressBarFormatter', function() { }) }) - it('prints the warning', function() { - expect(this.progressBarFormatter.progressBar.interrupt).to.have.been - .calledOnce + it('prints the warning', function () { + expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(0) }) }) }) - describe('test-run-finished', function() { - beforeEach(function() { + describe('test-run-finished', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-run-finished', { result: { duration: 0 } }) }) - it('outputs step totals, scenario totals, and duration', function() { + it('outputs step totals, scenario totals, and duration', function () { expect(this.output).to.contain( '0 scenarios\n' + '0 steps\n' + '0m00.000s\n' ) diff --git a/src/formatter/progress_formatter.js b/src/formatter/progress_formatter.js index c2d096d69..a38ddd1ac 100644 --- a/src/formatter/progress_formatter.js +++ b/src/formatter/progress_formatter.js @@ -11,7 +11,7 @@ const STATUS_CHARACTER_MAPPING = { } export default class ProgressFormatter extends SummaryFormatter { - constructor(options) { + constructor (options) { options.eventBroadcaster.on('test-run-finished', () => { this.log('\n\n') }) @@ -19,7 +19,7 @@ export default class ProgressFormatter extends SummaryFormatter { options.eventBroadcaster.on('test-step-finished', ::this.logProgress) } - logProgress({ result }) { + logProgress ({ result }) { const { status } = result const character = this.colorFns[status](STATUS_CHARACTER_MAPPING[status]) this.log(character) diff --git a/src/formatter/progress_formatter_spec.js b/src/formatter/progress_formatter_spec.js index 44b0af080..e66ad5137 100644 --- a/src/formatter/progress_formatter_spec.js +++ b/src/formatter/progress_formatter_spec.js @@ -4,8 +4,8 @@ import Status from '../status' import { EventEmitter } from 'events' import { EventDataCollector } from './helpers' -describe('ProgressFormatter', function() { - beforeEach(function() { +describe('ProgressFormatter', function () { + beforeEach(function () { this.eventBroadcaster = new EventEmitter() this.output = '' const colorFns = getColorFns(false) @@ -20,8 +20,8 @@ describe('ProgressFormatter', function() { }) }) - describe('test step finished', function() { - beforeEach(function() { + describe('test step finished', function () { + beforeEach(function () { this.testCase = { sourceLocation: { uri: 'path/to/feature', line: 1 } } this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, @@ -29,8 +29,8 @@ describe('ProgressFormatter', function() { }) }) - describe('ambiguous', function() { - beforeEach(function() { + describe('ambiguous', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.AMBIGUOUS }, @@ -38,13 +38,13 @@ describe('ProgressFormatter', function() { }) }) - it('outputs A', function() { + it('outputs A', function () { expect(this.output).to.eql('A') }) }) - describe('failed', function() { - beforeEach(function() { + describe('failed', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.FAILED }, @@ -52,13 +52,13 @@ describe('ProgressFormatter', function() { }) }) - it('outputs F', function() { + it('outputs F', function () { expect(this.output).to.eql('F') }) }) - describe('passed', function() { - beforeEach(function() { + describe('passed', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.PASSED }, @@ -66,13 +66,13 @@ describe('ProgressFormatter', function() { }) }) - it('outputs .', function() { + it('outputs .', function () { expect(this.output).to.eql('.') }) }) - describe('pending', function() { - beforeEach(function() { + describe('pending', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.PENDING }, @@ -80,13 +80,13 @@ describe('ProgressFormatter', function() { }) }) - it('outputs P', function() { + it('outputs P', function () { expect(this.output).to.eql('P') }) }) - describe('skipped', function() { - beforeEach(function() { + describe('skipped', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.SKIPPED }, @@ -94,13 +94,13 @@ describe('ProgressFormatter', function() { }) }) - it('outputs -', function() { + it('outputs -', function () { expect(this.output).to.eql('-') }) }) - describe('undefined', function() { - beforeEach(function() { + describe('undefined', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.UNDEFINED }, @@ -108,20 +108,20 @@ describe('ProgressFormatter', function() { }) }) - it('outputs U', function() { + it('outputs U', function () { expect(this.output).to.eql('U') }) }) }) - describe('test run finished', function() { - beforeEach(function() { + describe('test run finished', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-run-finished', { result: { duration: 0 } }) }) - it('outputs two newlines before the summary', function() { + it('outputs two newlines before the summary', function () { expect(this.output).to.eql('\n\n0 scenarios\n0 steps\n0m00.000s\n') }) }) diff --git a/src/formatter/rerun_formatter.js b/src/formatter/rerun_formatter.js index 5d609c032..8096ad5a5 100644 --- a/src/formatter/rerun_formatter.js +++ b/src/formatter/rerun_formatter.js @@ -5,7 +5,7 @@ import Status from '../status' const DEFAULT_SEPARATOR = '\n' export default class RerunFormatter extends Formatter { - constructor(options) { + constructor (options) { super(options) options.eventBroadcaster .on('test-case-finished', ::this.storeFailedTestCases) @@ -14,7 +14,7 @@ export default class RerunFormatter extends Formatter { this.separator = _.get(options, 'rerun.separator', DEFAULT_SEPARATOR) } - storeFailedTestCases({ sourceLocation: { line, uri }, result: { status } }) { + storeFailedTestCases ({ sourceLocation: { line, uri }, result: { status } }) { if (status !== Status.PASSED) { if (!this.mapping[uri]) { this.mapping[uri] = [] @@ -23,7 +23,7 @@ export default class RerunFormatter extends Formatter { } } - logFailedTestCases() { + logFailedTestCases () { const text = _.chain(this.mapping) .map((lines, uri) => uri + ':' + lines.join(':')) .join(this.separator) diff --git a/src/formatter/rerun_formatter_spec.js b/src/formatter/rerun_formatter_spec.js index 464ce3d3e..e19ea016f 100644 --- a/src/formatter/rerun_formatter_spec.js +++ b/src/formatter/rerun_formatter_spec.js @@ -4,7 +4,7 @@ import RerunFormatter from './rerun_formatter' import Status from '../status' import { EventEmitter } from 'events' -function prepareFormatter(options = {}) { +function prepareFormatter (options = {}) { this.output = '' const logFn = data => { this.output += data @@ -19,22 +19,22 @@ function prepareFormatter(options = {}) { }) } -describe('RerunFormatter', function() { +describe('RerunFormatter', function () { beforeEach(prepareFormatter) - describe('with no scenarios', function() { - beforeEach(function() { + describe('with no scenarios', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs nothing', function() { + it('outputs nothing', function () { expect(this.output).to.eql('') }) }) _.each([Status.PASSED], status => { - describe('with one ' + status + ' scenario', function() { - beforeEach(function() { + describe('with one ' + status + ' scenario', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature1Path, line: 1 }, result: { status } @@ -42,7 +42,7 @@ describe('RerunFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs nothing', function() { + it('outputs nothing', function () { expect(this.output).to.eql('') }) }) @@ -57,8 +57,8 @@ describe('RerunFormatter', function() { Status.UNDEFINED ], status => { - describe('with one ' + status + ' scenario', function() { - beforeEach(function() { + describe('with one ' + status + ' scenario', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature1Path, line: 1 }, result: { status } @@ -66,15 +66,15 @@ describe('RerunFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the reference needed to run the scenario again', function() { + it('outputs the reference needed to run the scenario again', function () { expect(this.output).to.eql(`${this.feature1Path}:1`) }) }) } ) - describe('with two failing scenarios in the same file', function() { - beforeEach(function() { + describe('with two failing scenarios in the same file', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature1Path, line: 1 }, result: { status: Status.FAILED } @@ -86,7 +86,7 @@ describe('RerunFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the reference needed to run the scenarios again', function() { + it('outputs the reference needed to run the scenarios again', function () { expect(this.output).to.eql(`${this.feature1Path}:1:2`) }) }) @@ -98,9 +98,9 @@ describe('RerunFormatter', function() { { separator: { opt: ' ', expected: ' ' }, label: 'space' } ], ({ separator, label }) => { - describe('using ' + label + ' separator', function() { - describe('with two failing scenarios in different files', function() { - beforeEach(function() { + describe('using ' + label + ' separator', function () { + describe('with two failing scenarios in different files', function () { + beforeEach(function () { prepareFormatter.apply(this, [ { rerun: { separator: separator.opt } } ]) @@ -116,7 +116,7 @@ describe('RerunFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the references needed to run the scenarios again', function() { + it('outputs the references needed to run the scenarios again', function () { expect(this.output).to.eql( `${this.feature1Path}:1` + separator.expected + diff --git a/src/formatter/snippets_formatter.js b/src/formatter/snippets_formatter.js index 804305682..2d34e9f89 100644 --- a/src/formatter/snippets_formatter.js +++ b/src/formatter/snippets_formatter.js @@ -3,7 +3,7 @@ import Status from '../status' import { KeywordType, getStepKeywordType } from './helpers' export default class SnippetsFormatter extends Formatter { - constructor(options) { + constructor (options) { super(options) options.eventBroadcaster.on( 'test-step-finished', @@ -11,7 +11,7 @@ export default class SnippetsFormatter extends Formatter { ) } - logUndefinedTestStepSnippet({ testCase: { sourceLocation }, index, result }) { + logUndefinedTestStepSnippet ({ testCase: { sourceLocation }, index, result }) { if (result.status === Status.UNDEFINED) { const { gherkinDocument, @@ -36,7 +36,7 @@ export default class SnippetsFormatter extends Formatter { } } - getPreviousKeywordType({ gherkinDocument, testCase, index }) { + getPreviousKeywordType ({ gherkinDocument, testCase, index }) { let previousKeywordType = KeywordType.PRECONDITION for (let i = 0; i < index; i += 1) { const { gherkinKeyword } = this.eventDataCollector.getTestStepData({ diff --git a/src/formatter/step_definition_snippet_builder/index.js b/src/formatter/step_definition_snippet_builder/index.js index 66acdd624..b1cbd1bf1 100644 --- a/src/formatter/step_definition_snippet_builder/index.js +++ b/src/formatter/step_definition_snippet_builder/index.js @@ -3,14 +3,14 @@ import { KeywordType } from '../helpers' import { buildStepArgumentIterator } from '../../step_arguments' export default class StepDefinitionSnippetBuilder { - constructor({ snippetSyntax, parameterTypeRegistry }) { + constructor ({ snippetSyntax, parameterTypeRegistry }) { this.snippetSyntax = snippetSyntax this.cucumberExpressionGenerator = new CucumberExpressionGenerator( parameterTypeRegistry ) } - build({ keywordType, pickleStep }) { + build ({ keywordType, pickleStep }) { const comment = 'Write code here that turns the phrase above into concrete actions' const functionName = this.getFunctionName(keywordType) @@ -27,7 +27,7 @@ export default class StepDefinitionSnippetBuilder { }) } - getFunctionName(keywordType) { + getFunctionName (keywordType) { switch (keywordType) { case KeywordType.EVENT: return 'When' @@ -38,7 +38,7 @@ export default class StepDefinitionSnippetBuilder { } } - getStepParameterNames(step) { + getStepParameterNames (step) { const iterator = buildStepArgumentIterator({ dataTable: () => 'dataTable', docString: () => 'docString' diff --git a/src/formatter/step_definition_snippet_builder/index_spec.js b/src/formatter/step_definition_snippet_builder/index_spec.js index b9ac6c158..ef964e004 100644 --- a/src/formatter/step_definition_snippet_builder/index_spec.js +++ b/src/formatter/step_definition_snippet_builder/index_spec.js @@ -2,8 +2,8 @@ import { KeywordType } from '../helpers' import StepDefinitionSnippetBuilder from './' import TransformLookupBuilder from '../../support_code_library_builder/parameter_type_registry_builder' -describe('StepDefinitionSnippetBuilder', function() { - beforeEach(function() { +describe('StepDefinitionSnippetBuilder', function () { + beforeEach(function () { this.snippetSyntax = createMock(['build']) this.transformsLookup = TransformLookupBuilder.build() this.snippetBuilder = new StepDefinitionSnippetBuilder({ @@ -12,8 +12,8 @@ describe('StepDefinitionSnippetBuilder', function() { }) }) - describe('build()', function() { - beforeEach(function() { + describe('build()', function () { + beforeEach(function () { this.input = { keywordType: KeywordType.PRECONDITION, pickleStep: { @@ -23,78 +23,78 @@ describe('StepDefinitionSnippetBuilder', function() { } }) - describe('step is an precondition step', function() { - beforeEach(function() { + describe('step is an precondition step', function () { + beforeEach(function () { this.input.keywordType = KeywordType.PRECONDITION this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('uses Given as the function name', function() { + it('uses Given as the function name', function () { expect(this.arg.functionName).to.eql('Given') }) }) - describe('step is an event step', function() { - beforeEach(function() { + describe('step is an event step', function () { + beforeEach(function () { this.input.keywordType = KeywordType.EVENT this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('uses When as the function name', function() { + it('uses When as the function name', function () { expect(this.arg.functionName).to.eql('When') }) }) - describe('step is an outcome step', function() { - beforeEach(function() { + describe('step is an outcome step', function () { + beforeEach(function () { this.input.keywordType = KeywordType.OUTCOME this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('uses Then as the function name', function() { + it('uses Then as the function name', function () { expect(this.arg.functionName).to.eql('Then') }) }) - describe('step has simple name', function() { - beforeEach(function() { + describe('step has simple name', function () { + beforeEach(function () { this.input.pickleStep.text = 'abc' this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('adds the proper generated expression', function() { + it('adds the proper generated expression', function () { let generatedExpression = this.arg.generatedExpressions[0] expect(generatedExpression.source).to.eql('abc') expect(generatedExpression.parameterNames).to.eql([]) }) }) - describe('step name has a quoted string', function() { - beforeEach(function() { + describe('step name has a quoted string', function () { + beforeEach(function () { this.input.pickleStep.text = 'abc "def" ghi' this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('adds the proper generated expression', function() { + it('adds the proper generated expression', function () { let generatedExpression = this.arg.generatedExpressions[0] expect(generatedExpression.source).to.eql('abc {string} ghi') expect(generatedExpression.parameterNames).to.eql(['string']) }) }) - describe('step name has multiple quoted strings', function() { - beforeEach(function() { + describe('step name has multiple quoted strings', function () { + beforeEach(function () { this.input.pickleStep.text = 'abc "def" ghi "jkl" mno' this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('adds the proper generated expression', function() { + it('adds the proper generated expression', function () { let generatedExpression = this.arg.generatedExpressions[0] expect(generatedExpression.source).to.eql( 'abc {string} ghi {string} mno' @@ -103,51 +103,51 @@ describe('StepDefinitionSnippetBuilder', function() { }) }) - describe('step name has a standalone number', function() { - beforeEach(function() { + describe('step name has a standalone number', function () { + beforeEach(function () { this.input.pickleStep.text = 'abc 123 def' this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('adds the proper generated expression', function() { + it('adds the proper generated expression', function () { let generatedExpression = this.arg.generatedExpressions[0] expect(generatedExpression.source).to.eql('abc {int} def') expect(generatedExpression.parameterNames).to.eql(['int']) }) }) - describe('step has no arguments', function() { - beforeEach(function() { + describe('step has no arguments', function () { + beforeEach(function () { this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('passes no step parameter names', function() { + it('passes no step parameter names', function () { expect(this.arg.stepParameterNames).to.eql([]) }) }) - describe('step has a data table argument', function() { - beforeEach(function() { + describe('step has a data table argument', function () { + beforeEach(function () { this.input.pickleStep.arguments = [{ rows: [] }] this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('passes dataTable as a step parameter name', function() { + it('passes dataTable as a step parameter name', function () { expect(this.arg.stepParameterNames).to.eql(['dataTable']) }) }) - describe('step has a doc string argument', function() { - beforeEach(function() { + describe('step has a doc string argument', function () { + beforeEach(function () { this.input.pickleStep.arguments = [{ content: '' }] this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('passes docString as a step parameter name', function() { + it('passes docString as a step parameter name', function () { expect(this.arg.stepParameterNames).to.eql(['docString']) }) }) diff --git a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js index b8e3eebb1..23fc1fc37 100644 --- a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +++ b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js @@ -1,11 +1,11 @@ const CALLBACK_NAME = 'callback' export default class JavaScriptSnippetSyntax { - constructor(snippetInterface) { + constructor (snippetInterface) { this.snippetInterface = snippetInterface } - build({ comment, generatedExpressions, functionName, stepParameterNames }) { + build ({ comment, generatedExpressions, functionName, stepParameterNames }) { let functionKeyword = 'function ' if (this.snippetInterface === 'generator') { functionKeyword += '*' diff --git a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js index 7ad490f00..034333739 100644 --- a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js +++ b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js @@ -1,13 +1,13 @@ import JavascriptSnippetSyntax from './javascript_snippet_syntax' -describe('JavascriptSnippetSyntax', function() { - describe('build()', function() { - describe('callback interface', function() { - beforeEach(function() { +describe('JavascriptSnippetSyntax', function () { + describe('build()', function () { + describe('callback interface', function () { + beforeEach(function () { this.syntax = new JavascriptSnippetSyntax('callback') }) - it('returns the proper snippet', function() { + it('returns the proper snippet', function () { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', @@ -28,12 +28,12 @@ describe('JavascriptSnippetSyntax', function() { }) }) - describe('generator interface', function() { - beforeEach(function() { + describe('generator interface', function () { + beforeEach(function () { this.syntax = new JavascriptSnippetSyntax('generator') }) - it('returns the proper snippet', function() { + it('returns the proper snippet', function () { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', @@ -54,12 +54,12 @@ describe('JavascriptSnippetSyntax', function() { }) }) - describe('promise interface', function() { - beforeEach(function() { + describe('promise interface', function () { + beforeEach(function () { this.syntax = new JavascriptSnippetSyntax('promise') }) - it('returns the proper snippet', function() { + it('returns the proper snippet', function () { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', @@ -80,12 +80,12 @@ describe('JavascriptSnippetSyntax', function() { }) }) - describe('synchronous interface', function() { - beforeEach(function() { + describe('synchronous interface', function () { + beforeEach(function () { this.syntax = new JavascriptSnippetSyntax('synchronous') }) - it('returns the proper snippet', function() { + it('returns the proper snippet', function () { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', @@ -106,12 +106,12 @@ describe('JavascriptSnippetSyntax', function() { }) }) - describe('pattern contains single quote', function() { - beforeEach(function() { + describe('pattern contains single quote', function () { + beforeEach(function () { this.syntax = new JavascriptSnippetSyntax('synchronous') }) - it('returns the proper snippet', function() { + it('returns the proper snippet', function () { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', @@ -132,12 +132,12 @@ describe('JavascriptSnippetSyntax', function() { }) }) - describe('multiple patterns', function() { - beforeEach(function() { + describe('multiple patterns', function () { + beforeEach(function () { this.syntax = new JavascriptSnippetSyntax('synchronous') }) - it('returns the snippet with the other choices commented out', function() { + it('returns the snippet with the other choices commented out', function () { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', diff --git a/src/formatter/summary_formatter.js b/src/formatter/summary_formatter.js index 1699e8fac..5125d502e 100644 --- a/src/formatter/summary_formatter.js +++ b/src/formatter/summary_formatter.js @@ -4,23 +4,23 @@ import Formatter from './' import Status from '../status' export default class SummaryFormatter extends Formatter { - constructor(options) { + constructor (options) { super(options) options.eventBroadcaster.on('test-run-finished', ::this.logSummary) } - isTestCaseFailure(testCase) { + isTestCaseFailure (testCase) { return _.includes([Status.AMBIGUOUS, Status.FAILED], testCase.result.status) } - isTestCaseWarning(testCase) { + isTestCaseWarning (testCase) { return _.includes( [Status.PENDING, Status.UNDEFINED], testCase.result.status ) } - logSummary(testRun) { + logSummary (testRun) { const failures = [] const warnings = [] _.each(this.eventDataCollector.testCaseMap, testCase => { @@ -45,7 +45,7 @@ export default class SummaryFormatter extends Formatter { ) } - logIssues({ issues, title }) { + logIssues ({ issues, title }) { this.log(title + ':\n\n') issues.forEach((testCase, index) => { const { diff --git a/src/formatter/summary_formatter_spec.js b/src/formatter/summary_formatter_spec.js index d2977e21a..2e934a6aa 100644 --- a/src/formatter/summary_formatter_spec.js +++ b/src/formatter/summary_formatter_spec.js @@ -6,8 +6,8 @@ import { EventEmitter } from 'events' import Gherkin from 'gherkin' import { EventDataCollector } from './helpers' -describe('SummaryFormatter', function() { - beforeEach(function() { +describe('SummaryFormatter', function () { + beforeEach(function () { this.output = '' const logFn = data => { this.output += data @@ -22,8 +22,8 @@ describe('SummaryFormatter', function() { }) }) - describe('issues', function() { - beforeEach(function() { + describe('issues', function () { + beforeEach(function () { const events = Gherkin.generateEvents( 'Feature: a\nScenario: b\nGiven a step', 'a.feature' @@ -41,8 +41,8 @@ describe('SummaryFormatter', function() { this.testCase = { sourceLocation: { uri: 'a.feature', line: 2 } } }) - describe('with a failing scenario', function() { - beforeEach(function() { + describe('with a failing scenario', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -66,7 +66,7 @@ describe('SummaryFormatter', function() { }) }) - it('logs the issue', function() { + it('logs the issue', function () { expect(this.output).to.eql( 'Failures:\n' + '\n' + @@ -81,8 +81,8 @@ describe('SummaryFormatter', function() { }) }) - describe('with an ambiguous step', function() { - beforeEach(function() { + describe('with an ambiguous step', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -111,7 +111,7 @@ describe('SummaryFormatter', function() { }) }) - it('logs the issue', function() { + it('logs the issue', function () { expect(this.output).to.eql( 'Failures:\n' + '\n' + @@ -128,8 +128,8 @@ describe('SummaryFormatter', function() { }) }) - describe('with an undefined step', function() { - beforeEach(function() { + describe('with an undefined step', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -152,7 +152,7 @@ describe('SummaryFormatter', function() { }) }) - it('logs the issue', function() { + it('logs the issue', function () { expect(this.output).to.eql( 'Warnings:\n' + '\n' + @@ -170,8 +170,8 @@ describe('SummaryFormatter', function() { }) }) - describe('with a pending step', function() { - beforeEach(function() { + describe('with a pending step', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -195,7 +195,7 @@ describe('SummaryFormatter', function() { }) }) - it('logs the issue', function() { + it('logs the issue', function () { expect(this.output).to.eql( 'Warnings:\n' + '\n' + @@ -210,39 +210,39 @@ describe('SummaryFormatter', function() { }) }) - describe('summary', function() { - describe('with a duration of 123 milliseconds', function() { - beforeEach(function() { + describe('summary', function () { + describe('with a duration of 123 milliseconds', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-run-finished', { result: { duration: 123 } }) }) - it('outputs scenario totals, step totals, and duration', function() { + it('outputs scenario totals, step totals, and duration', function () { expect(this.output).to.contain('0 scenarios\n0 steps\n0m00.123s\n') }) }) - describe('with a duration of 12.3 seconds', function() { - beforeEach(function() { + describe('with a duration of 12.3 seconds', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-run-finished', { result: { duration: 123 * 100 } }) }) - it('outputs scenario totals, step totals, and duration', function() { + it('outputs scenario totals, step totals, and duration', function () { expect(this.output).to.contain('0 scenarios\n0 steps\n0m12.300s\n') }) }) - describe('with a duration of 120.3 seconds', function() { - beforeEach(function() { + describe('with a duration of 120.3 seconds', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-run-finished', { result: { duration: 123 * 1000 } }) }) - it('outputs scenario totals, step totals, and duration', function() { + it('outputs scenario totals, step totals, and duration', function () { expect(this.output).to.contain('0 scenarios\n0 steps\n2m03.000s\n') }) }) diff --git a/src/formatter/usage_formatter.js b/src/formatter/usage_formatter.js index 99341053a..427de5300 100644 --- a/src/formatter/usage_formatter.js +++ b/src/formatter/usage_formatter.js @@ -4,12 +4,12 @@ import Formatter from './' import Table from 'cli-table' export default class UsageFormatter extends Formatter { - constructor(options) { + constructor (options) { super(options) options.eventBroadcaster.on('test-run-finished', ::this.logUsage) } - logUsage() { + logUsage () { const usage = getUsage({ stepDefinitions: this.supportCodeLibrary.stepDefinitions, eventDataCollector: this.eventDataCollector diff --git a/src/formatter/usage_formatter_spec.js b/src/formatter/usage_formatter_spec.js index 2de3ec72d..c3b82005e 100644 --- a/src/formatter/usage_formatter_spec.js +++ b/src/formatter/usage_formatter_spec.js @@ -3,9 +3,9 @@ import EventEmitter from 'events' import Gherkin from 'gherkin' import { EventDataCollector } from './helpers' -describe('UsageFormatter', function() { - describe('handleFeaturesResult', function() { - beforeEach(function() { +describe('UsageFormatter', function () { + describe('handleFeaturesResult', function () { + beforeEach(function () { this.eventBroadcaster = new EventEmitter() this.output = '' const logFn = data => { @@ -14,7 +14,7 @@ describe('UsageFormatter', function() { this.supportCodeLibrary = { stepDefinitions: [] } - new UsageFormatter({ + this.usageFormatter = new UsageFormatter({ eventBroadcaster: this.eventBroadcaster, eventDataCollector: new EventDataCollector(this.eventBroadcaster), log: logFn, @@ -22,18 +22,18 @@ describe('UsageFormatter', function() { }) }) - describe('no step definitions', function() { - beforeEach(function() { + describe('no step definitions', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs "No step definitions"', function() { + it('outputs "No step definitions"', function () { expect(this.output).to.eql('No step definitions') }) }) - describe('with one step definition', function() { - beforeEach(function() { + describe('with one step definition', function () { + beforeEach(function () { this.stepDefinition = { line: 1, pattern: '/^abc?$/', @@ -42,12 +42,12 @@ describe('UsageFormatter', function() { this.supportCodeLibrary.stepDefinitions = [this.stepDefinition] }) - describe('unused', function() { - beforeEach(function() { + describe('unused', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step definition as unused', function() { + it('outputs the step definition as unused', function () { expect(this.output).to.eql( '┌────────────────┬──────────┬────────────┐\n' + '│ Pattern / Text │ Duration │ Location │\n' + @@ -58,8 +58,8 @@ describe('UsageFormatter', function() { }) }) - describe('used', function() { - beforeEach(function() { + describe('used', function () { + beforeEach(function () { const events = Gherkin.generateEvents( 'Feature: a\nScenario: b\nWhen abc\nThen ab', 'a.feature' @@ -90,8 +90,8 @@ describe('UsageFormatter', function() { }) }) - describe('in dry run', function() { - beforeEach(function() { + describe('in dry run', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, @@ -105,7 +105,7 @@ describe('UsageFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step definition without durations', function() { + it('outputs the step definition without durations', function () { expect(this.output).to.eql( '┌────────────────┬──────────┬─────────────┐\n' + '│ Pattern / Text │ Duration │ Location │\n' + @@ -118,8 +118,8 @@ describe('UsageFormatter', function() { }) }) - describe('not in dry run', function() { - beforeEach(function() { + describe('not in dry run', function () { + beforeEach(function () { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, @@ -133,7 +133,7 @@ describe('UsageFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step definition with durations in desending order', function() { + it('outputs the step definition with durations in desending order', function () { expect(this.output).to.eql( '┌────────────────┬──────────┬─────────────┐\n' + '│ Pattern / Text │ Duration │ Location │\n' + @@ -148,8 +148,8 @@ describe('UsageFormatter', function() { }) }) - describe('with multiple definition', function() { - beforeEach(function() { + describe('with multiple definition', function () { + beforeEach(function () { this.supportCodeLibrary.stepDefinitions = [ { line: 1, @@ -208,7 +208,7 @@ describe('UsageFormatter', function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step definitions ordered by mean duration descending with unused steps at the end', function() { + it('outputs the step definitions ordered by mean duration descending with unused steps at the end', function () { expect(this.output).to.eql( '┌────────────────┬──────────┬─────────────┐\n' + '│ Pattern / Text │ Duration │ Location │\n' + diff --git a/src/formatter/usage_json_formatter.js b/src/formatter/usage_json_formatter.js index 81a8c3b00..12df25b00 100644 --- a/src/formatter/usage_json_formatter.js +++ b/src/formatter/usage_json_formatter.js @@ -2,12 +2,12 @@ import { getUsage } from './helpers' import Formatter from './' export default class UsageJsonFormatter extends Formatter { - constructor(options) { + constructor (options) { super(options) options.eventBroadcaster.on('test-run-finished', ::this.logUsage) } - logUsage() { + logUsage () { const usage = getUsage({ stepDefinitions: this.supportCodeLibrary.stepDefinitions, eventDataCollector: this.eventDataCollector diff --git a/src/formatter/usage_json_formatter_spec.js b/src/formatter/usage_json_formatter_spec.js index c7a45bd37..f5586dee4 100644 --- a/src/formatter/usage_json_formatter_spec.js +++ b/src/formatter/usage_json_formatter_spec.js @@ -3,9 +3,9 @@ import EventEmitter from 'events' import Gherkin from 'gherkin' import { EventDataCollector } from './helpers' -describe('UsageJsonFormatter', function() { - describe('handleFeaturesResult', function() { - beforeEach(function() { +describe('UsageJsonFormatter', function () { + describe('handleFeaturesResult', function () { + beforeEach(function () { const eventBroadcaster = new EventEmitter() this.output = '' const logFn = data => { @@ -30,7 +30,7 @@ describe('UsageJsonFormatter', function() { } ] } - new UsageJsonFormatter({ + this.usageJsonFormatter = new UsageJsonFormatter({ eventBroadcaster, eventDataCollector: new EventDataCollector(eventBroadcaster), log: logFn, @@ -77,7 +77,7 @@ describe('UsageJsonFormatter', function() { eventBroadcaster.emit('test-run-finished') }) - it('outputs the usage in json format', function() { + it('outputs the usage in json format', function () { const parsedOutput = JSON.parse(this.output) expect(parsedOutput).to.eql([ { diff --git a/src/models/data_table.js b/src/models/data_table.js index 2245e862d..5efb7f42e 100644 --- a/src/models/data_table.js +++ b/src/models/data_table.js @@ -1,30 +1,30 @@ import _ from 'lodash' export default class DataTable { - constructor(gherkinData) { + constructor (gherkinData) { this.rawTable = gherkinData.rows.map(row => row.cells.map(cell => cell.value) ) } - hashes() { + hashes () { const copy = this.raw() const keys = copy[0] const valuesArray = copy.slice(1) return valuesArray.map(values => _.zipObject(keys, values)) } - raw() { + raw () { return this.rawTable.slice(0) } - rows() { + rows () { const copy = this.raw() copy.shift() return copy } - rowsHash() { + rowsHash () { const rows = this.raw() const everyRowHasTwoColumns = _.every(rows, row => row.length === 2) if (!everyRowHasTwoColumns) { diff --git a/src/models/data_table_spec.js b/src/models/data_table_spec.js index 173932882..0c6743117 100644 --- a/src/models/data_table_spec.js +++ b/src/models/data_table_spec.js @@ -1,8 +1,8 @@ import DataTable from './data_table' -describe('DataTable', function() { - describe('table with headers', function() { - beforeEach(function() { +describe('DataTable', function () { + describe('table with headers', function () { + beforeEach(function () { this.dataTable = new DataTable({ rows: [ { @@ -18,8 +18,8 @@ describe('DataTable', function() { }) }) - describe('rows', function() { - it('returns a 2-D array without the header', function() { + describe('rows', function () { + it('returns a 2-D array without the header', function () { expect(this.dataTable.rows()).to.eql([ ['row 1 col 1', 'row 1 col 2'], ['row 2 col 1', 'row 2 col 2'] @@ -27,8 +27,8 @@ describe('DataTable', function() { }) }) - describe('hashes', function() { - it('returns an array of object where the keys are the headers', function() { + describe('hashes', function () { + it('returns an array of object where the keys are the headers', function () { expect(this.dataTable.hashes()).to.eql([ { 'header 1': 'row 1 col 1', 'header 2': 'row 1 col 2' }, { 'header 1': 'row 2 col 1', 'header 2': 'row 2 col 2' } @@ -37,8 +37,8 @@ describe('DataTable', function() { }) }) - describe('table without headers', function() { - beforeEach(function() { + describe('table without headers', function () { + beforeEach(function () { this.dataTable = new DataTable({ rows: [ { @@ -51,8 +51,8 @@ describe('DataTable', function() { }) }) - describe('raw', function() { - it('returns a 2-D array', function() { + describe('raw', function () { + it('returns a 2-D array', function () { expect(this.dataTable.raw()).to.eql([ ['row 1 col 1', 'row 1 col 2'], ['row 2 col 1', 'row 2 col 2'] @@ -60,8 +60,8 @@ describe('DataTable', function() { }) }) - describe('rowsHash', function() { - it('returns an object where the keys are the first column', function() { + describe('rowsHash', function () { + it('returns an object where the keys are the first column', function () { expect(this.dataTable.rowsHash()).to.eql({ 'row 1 col 1': 'row 1 col 2', 'row 2 col 1': 'row 2 col 2' diff --git a/src/models/step_definition.js b/src/models/step_definition.js index 7fb0643db..3fc105fc7 100644 --- a/src/models/step_definition.js +++ b/src/models/step_definition.js @@ -3,7 +3,7 @@ import DataTable from './data_table' import { buildStepArgumentIterator } from '../step_arguments' export default class StepDefinition { - constructor({ code, line, options, pattern, uri }) { + constructor ({ code, line, options, pattern, uri }) { this.code = code this.line = line this.options = options @@ -11,7 +11,7 @@ export default class StepDefinition { this.uri = uri } - buildInvalidCodeLengthMessage(syncOrPromiseLength, callbackLength) { + buildInvalidCodeLengthMessage (syncOrPromiseLength, callbackLength) { return ( 'function has ' + this.code.length + @@ -25,14 +25,14 @@ export default class StepDefinition { ) } - getInvalidCodeLengthMessage(parameters) { + getInvalidCodeLengthMessage (parameters) { return this.buildInvalidCodeLengthMessage( parameters.length, parameters.length + 1 ) } - getInvocationParameters({ step, parameterTypeRegistry, world }) { + getInvocationParameters ({ step, parameterTypeRegistry, world }) { const cucumberExpression = this.getCucumberExpression(parameterTypeRegistry) const stepNameParameters = cucumberExpression .match(step.text) @@ -45,7 +45,7 @@ export default class StepDefinition { return stepNameParameters.concat(stepArgumentParameters) } - getCucumberExpression(parameterTypeRegistry) { + getCucumberExpression (parameterTypeRegistry) { if (typeof this.pattern === 'string') { return new CucumberExpression(this.pattern, parameterTypeRegistry) } else { @@ -53,11 +53,11 @@ export default class StepDefinition { } } - getValidCodeLengths(parameters) { + getValidCodeLengths (parameters) { return [parameters.length, parameters.length + 1] } - matchesStepName({ stepName, parameterTypeRegistry }) { + matchesStepName ({ stepName, parameterTypeRegistry }) { const cucumberExpression = this.getCucumberExpression(parameterTypeRegistry) return Boolean(cucumberExpression.match(stepName)) } diff --git a/src/models/test_case_hook_definition.js b/src/models/test_case_hook_definition.js index 2d3ca9d2a..059a9eb41 100644 --- a/src/models/test_case_hook_definition.js +++ b/src/models/test_case_hook_definition.js @@ -2,26 +2,26 @@ import PickleFilter from '../pickle_filter' import StepDefinition from './step_definition' export default class TestCaseHookDefinition extends StepDefinition { - constructor(data) { + constructor (data) { super(data) this.pickleFilter = new PickleFilter({ tagExpression: this.options.tags }) } - appliesToTestCase({ pickle, uri }) { + appliesToTestCase ({ pickle, uri }) { return this.pickleFilter.matches({ pickle, uri }) } - getInvalidCodeLengthMessage() { + getInvalidCodeLengthMessage () { return this.buildInvalidCodeLengthMessage('0 or 1', '2') } - getInvocationParameters({ hookParameter }) { + getInvocationParameters ({ hookParameter }) { return [hookParameter] } - getValidCodeLengths() { + getValidCodeLengths () { return [0, 1, 2] } } diff --git a/src/models/test_case_hook_definition_spec.js b/src/models/test_case_hook_definition_spec.js index 231bc01ab..4357a3950 100644 --- a/src/models/test_case_hook_definition_spec.js +++ b/src/models/test_case_hook_definition_spec.js @@ -1,8 +1,8 @@ import TestCaseHookDefinition from './test_case_hook_definition' -describe('TestCaseHookDefinition', function() { - describe('appliesToTestCase', function() { - beforeEach(function() { +describe('TestCaseHookDefinition', function () { + describe('appliesToTestCase', function () { + beforeEach(function () { this.input = { pickle: { tags: [] @@ -11,43 +11,40 @@ describe('TestCaseHookDefinition', function() { } }) - describe('no tags', function() { - beforeEach(function() { + describe('no tags', function () { + beforeEach(function () { this.testCaseHookDefinition = new TestCaseHookDefinition({ options: {} }) }) - it('returns true', function() { - expect(this.testCaseHookDefinition.appliesToTestCase(this.input)).to.be - .true + it('returns true', function () { + expect(this.testCaseHookDefinition.appliesToTestCase(this.input)).to.eql(true) }) }) - describe('tags match', function() { - beforeEach(function() { + describe('tags match', function () { + beforeEach(function () { this.input.pickle.tags = [{ name: '@tagA' }] this.testCaseHookDefinition = new TestCaseHookDefinition({ options: { tags: '@tagA' } }) }) - it('returns true', function() { - expect(this.testCaseHookDefinition.appliesToTestCase(this.input)).to.be - .true + it('returns true', function () { + expect(this.testCaseHookDefinition.appliesToTestCase(this.input)).to.eql(true) }) }) - describe('tags do not match', function() { - beforeEach(function() { + describe('tags do not match', function () { + beforeEach(function () { this.testCaseHookDefinition = new TestCaseHookDefinition({ options: { tags: '@tagA' } }) }) - it('returns false', function() { - expect(this.testCaseHookDefinition.appliesToTestCase(this.input)).to.be - .false + it('returns false', function () { + expect(this.testCaseHookDefinition.appliesToTestCase(this.input)).to.eql(false) }) }) }) diff --git a/src/models/test_run_hook_definition.js b/src/models/test_run_hook_definition.js index d3a80c840..e6df8c184 100644 --- a/src/models/test_run_hook_definition.js +++ b/src/models/test_run_hook_definition.js @@ -1,15 +1,15 @@ import StepDefinition from './step_definition' export default class TestRunHookDefinition extends StepDefinition { - getInvalidCodeLengthMessage() { + getInvalidCodeLengthMessage () { return this.buildInvalidCodeLengthMessage('0', '1') } - getInvocationParameters() { + getInvocationParameters () { return [] } - getValidCodeLengths() { + getValidCodeLengths () { return [0, 1] } } diff --git a/src/pickle_filter.js b/src/pickle_filter.js index 2cfa1550d..8c8dbed51 100644 --- a/src/pickle_filter.js +++ b/src/pickle_filter.js @@ -6,7 +6,7 @@ const FEATURE_LINENUM_REGEXP = /^(.*?)((?::[\d]+)+)?$/ const tagExpressionParser = new TagExpressionParser() export default class PickleFilter { - constructor({ featurePaths, names, tagExpression }) { + constructor ({ featurePaths, names, tagExpression }) { this.featureUriToLinesMapping = this.getFeatureUriToLinesMapping( featurePaths || [] ) @@ -16,7 +16,7 @@ export default class PickleFilter { } } - getFeatureUriToLinesMapping(featurePaths) { + getFeatureUriToLinesMapping (featurePaths) { const mapping = {} featurePaths.forEach(featurePath => { const match = FEATURE_LINENUM_REGEXP.exec(featurePath) @@ -30,7 +30,7 @@ export default class PickleFilter { linesExpression .slice(1) .split(':') - .forEach(function(line) { + .forEach(function (line) { mapping[uri].push(parseInt(line)) }) } @@ -39,7 +39,7 @@ export default class PickleFilter { return mapping } - matches({ pickle, uri }) { + matches ({ pickle, uri }) { return ( this.matchesAnyLine({ pickle, uri }) && this.matchesAnyName(pickle) && @@ -47,7 +47,7 @@ export default class PickleFilter { ) } - matchesAnyLine({ pickle, uri }) { + matchesAnyLine ({ pickle, uri }) { const lines = this.featureUriToLinesMapping[path.resolve(uri)] if (lines) { return _.size(_.intersection(lines, _.map(pickle.locations, 'line'))) > 0 @@ -56,16 +56,16 @@ export default class PickleFilter { } } - matchesAnyName(pickle) { + matchesAnyName (pickle) { if (this.names.length === 0) { return true } - return _.some(this.names, function(name) { + return _.some(this.names, function (name) { return pickle.name.match(name) }) } - matchesAllTagExpressions(pickle) { + matchesAllTagExpressions (pickle) { if (!this.tagExpressionNode) { return true } diff --git a/src/pickle_filter_spec.js b/src/pickle_filter_spec.js index fbc313ccf..a79b46be4 100644 --- a/src/pickle_filter_spec.js +++ b/src/pickle_filter_spec.js @@ -1,8 +1,8 @@ import PickleFilter from './pickle_filter' -describe('PickleFilter', function() { - describe('matches', function() { - beforeEach(function() { +describe('PickleFilter', function () { + describe('matches', function () { + beforeEach(function () { this.input = { pickle: { locations: [], @@ -13,8 +13,8 @@ describe('PickleFilter', function() { } }) - describe('no filters', function() { - beforeEach(function() { + describe('no filters', function () { + beforeEach(function () { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], @@ -22,13 +22,13 @@ describe('PickleFilter', function() { }) }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('line filters', function() { - beforeEach(function() { + describe('line filters', function () { + beforeEach(function () { this.pickleFilter = new PickleFilter({ featurePaths: ['features/a.feature', 'features/b.feature:1:2'], names: [], @@ -36,72 +36,72 @@ describe('PickleFilter', function() { }) }) - describe('scenario in feature without line specified', function() { - beforeEach(function() { + describe('scenario in feature without line specified', function () { + beforeEach(function () { this.input.uri = 'features/a.feature' }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario in feature with line specified', function() { - beforeEach(function() { + describe('scenario in feature with line specified', function () { + beforeEach(function () { this.input.uri = 'features/b.feature' }) - describe('scenario line matches', function() { - beforeEach(function() { + describe('scenario line matches', function () { + beforeEach(function () { this.input.pickle.locations = [{ line: 1 }] }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario line does not match', function() { - beforeEach(function() { + describe('scenario line does not match', function () { + beforeEach(function () { this.input.pickle.locations = [{ line: 3 }] }) - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) - describe('scenario line using current directory path representation', function() { - beforeEach(function() { + describe('scenario line using current directory path representation', function () { + beforeEach(function () { this.input.uri = './features/b.feature' }) - describe('scenario line matches', function() { - beforeEach(function() { + describe('scenario line matches', function () { + beforeEach(function () { this.input.pickle.locations = [{ line: 1 }] }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario line does not match', function() { - beforeEach(function() { + describe('scenario line does not match', function () { + beforeEach(function () { this.input.pickle.locations = [{ line: 3 }] }) - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) }) - describe('name filters', function() { - describe('should match name A', function() { - beforeEach(function() { + describe('name filters', function () { + describe('should match name A', function () { + beforeEach(function () { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: ['nameA'], @@ -109,29 +109,29 @@ describe('PickleFilter', function() { }) }) - describe('scenario name matches A', function() { - beforeEach(function() { + describe('scenario name matches A', function () { + beforeEach(function () { this.input.pickle.name = 'nameA descriptionA' }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario name does not match A', function() { - beforeEach(function() { + describe('scenario name does not match A', function () { + beforeEach(function () { this.input.pickle.name = 'nameB descriptionB' }) - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) - describe('should match name A or B', function() { - beforeEach(function() { + describe('should match name A or B', function () { + beforeEach(function () { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: ['nameA', 'nameB'], @@ -139,41 +139,41 @@ describe('PickleFilter', function() { }) }) - describe('scenario name matches A', function() { - beforeEach(function() { + describe('scenario name matches A', function () { + beforeEach(function () { this.input.pickle.name = 'nameA descriptionA' }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario name matches B', function() { - beforeEach(function() { + describe('scenario name matches B', function () { + beforeEach(function () { this.input.pickle.name = 'nameB descriptionB' }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario name does not match A or B', function() { - beforeEach(function() { + describe('scenario name does not match A or B', function () { + beforeEach(function () { this.input.pickle.name = 'nameC descriptionC' }) - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) }) - describe('tag filters', function() { - describe('should have tag A', function() { - beforeEach(function() { + describe('tag filters', function () { + describe('should have tag A', function () { + beforeEach(function () { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], @@ -181,25 +181,25 @@ describe('PickleFilter', function() { }) }) - describe('scenario has tag A', function() { - beforeEach(function() { + describe('scenario has tag A', function () { + beforeEach(function () { this.input.pickle.tags = [{ name: '@tagA' }] }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario does not have tag A', function() { - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + describe('scenario does not have tag A', function () { + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) - describe('should not have tag A', function() { - beforeEach(function() { + describe('should not have tag A', function () { + beforeEach(function () { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], @@ -207,25 +207,25 @@ describe('PickleFilter', function() { }) }) - describe('scenario has tag A', function() { - beforeEach(function() { + describe('scenario has tag A', function () { + beforeEach(function () { this.input.pickle.tags = [{ name: '@tagA' }] }) - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) - describe('scenario does not have tag A', function() { - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + describe('scenario does not have tag A', function () { + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) }) - describe('should have tag A and B', function() { - beforeEach(function() { + describe('should have tag A and B', function () { + beforeEach(function () { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], @@ -233,45 +233,45 @@ describe('PickleFilter', function() { }) }) - describe('scenario has tag A and B', function() { - beforeEach(function() { + describe('scenario has tag A and B', function () { + beforeEach(function () { this.input.pickle.tags = [{ name: '@tagA' }, { name: '@tagB' }] }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario has tag A, but not B', function() { - beforeEach(function() { + describe('scenario has tag A, but not B', function () { + beforeEach(function () { this.input.pickle.tags = [{ name: '@tagA' }] }) - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) - describe('scenario has tag B, but not A', function() { - beforeEach(function() { + describe('scenario has tag B, but not A', function () { + beforeEach(function () { this.input.pickle.tags = [{ name: '@tagB' }] }) - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) - describe('scenario does have tag A or B', function() { - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + describe('scenario does have tag A or B', function () { + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) - describe('should have tag A or B', function() { - beforeEach(function() { + describe('should have tag A or B', function () { + beforeEach(function () { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], @@ -279,51 +279,51 @@ describe('PickleFilter', function() { }) }) - describe('scenario has tag A and B', function() { - beforeEach(function() { + describe('scenario has tag A and B', function () { + beforeEach(function () { this.input.pickle.tags = [{ name: '@tagA' }, { name: '@tagB' }] }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario has tag A, but not B', function() { - beforeEach(function() { + describe('scenario has tag A, but not B', function () { + beforeEach(function () { this.input.pickle.tags = [{ name: '@tagA' }] }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario has tag B, but not A', function() { - beforeEach(function() { + describe('scenario has tag B, but not A', function () { + beforeEach(function () { this.input.pickle.tags = [{ name: '@tagB' }] }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario does have tag A or B', function() { - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + describe('scenario does have tag A or B', function () { + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) }) - describe('line, name, and tag filters', function() { - beforeEach(function() { + describe('line, name, and tag filters', function () { + beforeEach(function () { this.input.uri = 'features/b.feature' }) - describe('scenario matches all filters', function() { - beforeEach(function() { + describe('scenario matches all filters', function () { + beforeEach(function () { this.pickleFilter = new PickleFilter({ featurePaths: ['features/b.feature:1:2'], names: ['nameA'], @@ -334,13 +334,13 @@ describe('PickleFilter', function() { this.input.pickle.tags = [{ name: '@tagA' }] }) - it('returns true', function() { - expect(this.pickleFilter.matches(this.input)).to.be.true + it('returns true', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario matches some filters', function() { - beforeEach(function() { + describe('scenario matches some filters', function () { + beforeEach(function () { this.pickleFilter = new PickleFilter({ featurePaths: ['features/b.feature:1:2'], names: ['nameA'], @@ -349,13 +349,13 @@ describe('PickleFilter', function() { this.input.pickle.locations = [{ line: 1 }] }) - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) - describe('scenario matches no filters', function() { - beforeEach(function() { + describe('scenario matches no filters', function () { + beforeEach(function () { this.pickleFilter = new PickleFilter({ featurePaths: ['features/b.feature:1:2'], names: ['nameA'], @@ -364,8 +364,8 @@ describe('PickleFilter', function() { this.input.pickle.locations = [{ line: 1 }] }) - it('returns false', function() { - expect(this.pickleFilter.matches(this.input)).to.be.false + it('returns false', function () { + expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) diff --git a/src/runtime/attachment_manager/index.js b/src/runtime/attachment_manager/index.js index 31b24a9d4..fcf1cdffa 100644 --- a/src/runtime/attachment_manager/index.js +++ b/src/runtime/attachment_manager/index.js @@ -2,11 +2,11 @@ import isStream from 'is-stream' import Promise from 'bluebird' export default class AttachmentManager { - constructor(onAttachment) { + constructor (onAttachment) { this.onAttachment = onAttachment } - create(data, mediaType, callback) { + create (data, mediaType, callback) { if (Buffer.isBuffer(data)) { if (!mediaType) { throw Error('Buffer attachments must specify a media type') @@ -29,14 +29,14 @@ export default class AttachmentManager { } } - createBufferAttachment(data, mediaType) { + createBufferAttachment (data, mediaType) { this.createStringAttachment(data.toString('base64'), { encoding: 'base64', type: mediaType }) } - createStreamAttachment(data, mediaType, callback) { + createStreamAttachment (data, mediaType, callback) { const promise = new Promise((resolve, reject) => { const buffers = [] data.on('data', chunk => { @@ -55,7 +55,7 @@ export default class AttachmentManager { } } - createStringAttachment(data, media) { + createStringAttachment (data, media) { this.onAttachment({ data, media }) } } diff --git a/src/runtime/attachment_manager/index_spec.js b/src/runtime/attachment_manager/index_spec.js index ab14e4064..8ddbe61d2 100644 --- a/src/runtime/attachment_manager/index_spec.js +++ b/src/runtime/attachment_manager/index_spec.js @@ -1,25 +1,25 @@ import AttachmentManager from './' import stream from 'stream' -describe('AttachmentManager', function() { - describe('create()', function() { - beforeEach(function() { +describe('AttachmentManager', function () { + describe('create()', function () { + beforeEach(function () { this.onAttachment = sinon.stub() this.attachmentManager = new AttachmentManager(this.onAttachment) }) - describe('buffer', function() { - describe('with mime type', function() { - beforeEach(function() { - this.attachmentManager.create(new Buffer('my string'), 'text/special') + describe('buffer', function () { + describe('with mime type', function () { + beforeEach(function () { + this.attachmentManager.create(Buffer.from('my string'), 'text/special') }) - it('adds the data and media', function() { - expect(this.onAttachment).to.have.been.calledOnce + it('adds the data and media', function () { + expect(this.onAttachment).to.have.callCount(1) const attachment = this.onAttachment.firstCall.args[0] const encodedData = attachment.data expect(encodedData).to.eql('bXkgc3RyaW5n') - const decodedData = new Buffer(encodedData, 'base64').toString() + const decodedData = Buffer.from(encodedData, 'base64').toString() expect(decodedData).to.eql('my string') expect(attachment.media).to.eql({ encoding: 'base64', @@ -28,41 +28,41 @@ describe('AttachmentManager', function() { }) }) - describe('without media type', function() { - it('throws', function() { + describe('without media type', function () { + it('throws', function () { expect(() => { - this.attachmentManager.create(new Buffer('my string')) + this.attachmentManager.create(Buffer.from('my string')) }).to.throw('Buffer attachments must specify a media type') }) }) }) - describe('readable stream', function() { - describe('with mime type', function() { - describe('with callback', function() { - beforeEach(function(done) { + describe('readable stream', function () { + describe('with mime type', function () { + describe('with callback', function () { + beforeEach(function (done) { const readableStream = new stream.PassThrough() this.result = this.attachmentManager.create( readableStream, 'text/special', done ) - setTimeout(function() { + setTimeout(function () { readableStream.write('my string') readableStream.end() }, 25) }) - it('does not return a promise', function() { - expect(this.result).to.be.undefined + it('does not return a promise', function () { + expect(this.result).to.eql(undefined) }) - it('adds the data and media', function() { - expect(this.onAttachment).to.have.been.calledOnce + it('adds the data and media', function () { + expect(this.onAttachment).to.have.callCount(1) const attachment = this.onAttachment.firstCall.args[0] const encodedData = attachment.data expect(encodedData).to.eql('bXkgc3RyaW5n') - const decodedData = new Buffer(encodedData, 'base64').toString() + const decodedData = Buffer.from(encodedData, 'base64').toString() expect(decodedData).to.eql('my string') expect(attachment.media).to.eql({ encoding: 'base64', @@ -71,30 +71,30 @@ describe('AttachmentManager', function() { }) }) - describe('without callback', function() { - beforeEach(function() { + describe('without callback', function () { + beforeEach(function () { const readableStream = new stream.PassThrough() this.result = this.attachmentManager.create( readableStream, 'text/special' ) - setTimeout(function() { + setTimeout(function () { readableStream.write('my string') readableStream.end() }, 25) return this.result }) - it('returns a promise', function() { + it('returns a promise', function () { expect(this.result.then).to.be.a('function') }) - it('adds the data and media', function() { - expect(this.onAttachment).to.have.been.calledOnce + it('adds the data and media', function () { + expect(this.onAttachment).to.have.callCount(1) const attachment = this.onAttachment.firstCall.args[0] const encodedData = attachment.data expect(encodedData).to.eql('bXkgc3RyaW5n') - const decodedData = new Buffer(encodedData, 'base64').toString() + const decodedData = Buffer.from(encodedData, 'base64').toString() expect(decodedData).to.eql('my string') expect(attachment.media).to.eql({ encoding: 'base64', @@ -104,8 +104,8 @@ describe('AttachmentManager', function() { }) }) - describe('without media type', function() { - it('throws', function() { + describe('without media type', function () { + it('throws', function () { expect(() => { const readableStream = new stream.PassThrough() this.attachmentManager.create(readableStream) @@ -114,27 +114,27 @@ describe('AttachmentManager', function() { }) }) - describe('string', function() { - describe('with media type', function() { - beforeEach(function() { + describe('string', function () { + describe('with media type', function () { + beforeEach(function () { this.attachmentManager.create('my string', 'text/special') }) - it('adds the data and media', function() { - expect(this.onAttachment).to.have.been.calledOnce + it('adds the data and media', function () { + expect(this.onAttachment).to.have.callCount(1) const attachment = this.onAttachment.firstCall.args[0] expect(attachment.data).to.eql('my string') expect(attachment.media).to.eql({ type: 'text/special' }) }) }) - describe('without mime type', function() { - beforeEach(function() { + describe('without mime type', function () { + beforeEach(function () { this.attachmentManager.create('my string') }) - it('adds the data with the default mime type', function() { - expect(this.onAttachment).to.have.been.calledOnce + it('adds the data with the default mime type', function () { + expect(this.onAttachment).to.have.callCount(1) const attachment = this.onAttachment.firstCall.args[0] expect(attachment.data).to.eql('my string') expect(attachment.media).to.eql({ type: 'text/plain' }) @@ -142,8 +142,8 @@ describe('AttachmentManager', function() { }) }) - describe('unsupported data type', function() { - it('throws', function() { + describe('unsupported data type', function () { + it('throws', function () { expect(() => { this.attachmentManager.create({}, 'object/special') }).to.throw( diff --git a/src/runtime/helpers.js b/src/runtime/helpers.js index 1ca84e22a..dae9ff965 100644 --- a/src/runtime/helpers.js +++ b/src/runtime/helpers.js @@ -2,7 +2,7 @@ import { formatLocation } from '../formatter/helpers/location_helpers' import Table from 'cli-table' import indentString from 'indent-string' -export function getAmbiguousStepException(stepDefinitions) { +export function getAmbiguousStepException (stepDefinitions) { const table = new Table({ chars: { bottom: '', diff --git a/src/runtime/helpers_spec.js b/src/runtime/helpers_spec.js index f91e1d96c..01b407f8a 100644 --- a/src/runtime/helpers_spec.js +++ b/src/runtime/helpers_spec.js @@ -1,8 +1,8 @@ import { getAmbiguousStepException } from './helpers' -describe('Helpers', function() { - describe('getAmbiguousStepException', function() { - beforeEach(function() { +describe('Helpers', function () { + describe('getAmbiguousStepException', function () { + beforeEach(function () { this.result = getAmbiguousStepException([ { line: 3, pattern: 'pattern1', uri: 'steps1.js' }, { @@ -13,7 +13,7 @@ describe('Helpers', function() { ]) }) - it('returns a nicely formatted error', function() { + it('returns a nicely formatted error', function () { expect(this.result).to.eql( 'Multiple step definitions match:\n' + ' pattern1 - steps1.js:3\n' + diff --git a/src/runtime/index.js b/src/runtime/index.js index 82b96e86e..dbbaa4c47 100644 --- a/src/runtime/index.js +++ b/src/runtime/index.js @@ -9,7 +9,7 @@ import VError from 'verror' export default class Runtime { // options - {dryRun, failFast, filterStacktraces, strict} - constructor({ eventBroadcaster, options, supportCodeLibrary, testCases }) { + constructor ({ eventBroadcaster, options, supportCodeLibrary, testCases }) { this.eventBroadcaster = eventBroadcaster this.options = options || {} this.stackTraceFilter = new StackTraceFilter() @@ -21,7 +21,7 @@ export default class Runtime { } } - async runTestRunHooks(key, name) { + async runTestRunHooks (key, name) { await Promise.each(this.supportCodeLibrary[key], async hookDefinition => { const { error } = await UserCodeRunner.run({ argsArray: [], @@ -41,7 +41,7 @@ export default class Runtime { }) } - async runTestCase(testCase) { + async runTestCase (testCase) { const skip = this.options.dryRun || (this.options.failFast && !this.result.success) const testCaseRunner = new TestCaseRunner({ @@ -60,7 +60,7 @@ export default class Runtime { } } - async start() { + async start () { if (this.options.filterStacktraces) { this.stackTraceFilter.filter() } @@ -75,7 +75,7 @@ export default class Runtime { return this.result.success } - shouldCauseFailure(status) { + shouldCauseFailure (status) { return ( _.includes([Status.AMBIGUOUS, Status.FAILED, Status.UNDEFINED], status) || (status === Status.PENDING && this.options.strict) diff --git a/src/runtime/stack_trace_filter.js b/src/runtime/stack_trace_filter.js index 284f5e7b3..9453a2758 100644 --- a/src/runtime/stack_trace_filter.js +++ b/src/runtime/stack_trace_filter.js @@ -3,12 +3,15 @@ import stackChain from 'stack-chain' import path from 'path' export default class StackTraceFilter { - constructor() { + constructor () { this.cucumberPath = path.join(__dirname, '..', '..') } - filter() { + filter () { this.currentFilter = stackChain.filter.attach((error, frames) => { + if (error) { + throw error + } if (this.isErrorInCucumber(frames)) { return frames } @@ -21,24 +24,24 @@ export default class StackTraceFilter { }) } - isErrorInCucumber(frames) { + isErrorInCucumber (frames) { const filteredFrames = _.reject(frames, ::this.isFrameInNode) return ( filteredFrames.length > 0 && this.isFrameInCucumber(filteredFrames[0]) ) } - isFrameInCucumber(frame) { + isFrameInCucumber (frame) { const fileName = frame.getFileName() || '' return _.startsWith(fileName, this.cucumberPath) } - isFrameInNode(frame) { + isFrameInNode (frame) { const fileName = frame.getFileName() || '' return !_.includes(fileName, path.sep) } - unfilter() { + unfilter () { stackChain.filter.deattach(this.currentFilter) } } diff --git a/src/runtime/step_runner.js b/src/runtime/step_runner.js index cb750c96a..37b47f139 100644 --- a/src/runtime/step_runner.js +++ b/src/runtime/step_runner.js @@ -6,7 +6,7 @@ import Promise from 'bluebird' const { beginTiming, endTiming } = Time -async function run({ +async function run ({ defaultTimeout, hookParameter, parameterTypeRegistry, diff --git a/src/runtime/test_case_runner.js b/src/runtime/test_case_runner.js index b0a7313cc..036533258 100644 --- a/src/runtime/test_case_runner.js +++ b/src/runtime/test_case_runner.js @@ -6,7 +6,7 @@ import Status from '../status' import StepRunner from './step_runner' export default class TestCaseRunner { - constructor({ + constructor ({ eventBroadcaster, skip, testCase, @@ -41,7 +41,7 @@ export default class TestCaseRunner { } } - emit(name, data) { + emit (name, data) { let eventData = { ...data } if (_.startsWith(name, 'test-case')) { eventData.sourceLocation = this.testCaseSourceLocation @@ -51,7 +51,7 @@ export default class TestCaseRunner { this.eventBroadcaster.emit(name, eventData) } - emitPrepared() { + emitPrepared () { const steps = [] this.beforeHookDefinitions.forEach(definition => { const actionLocation = { uri: definition.uri, line: definition.line } @@ -78,7 +78,7 @@ export default class TestCaseRunner { this.emit('test-case-prepared', { steps }) } - getAfterHookDefinitions() { + getAfterHookDefinitions () { return this.supportCodeLibrary.afterTestCaseHookDefinitions.filter( hookDefinition => { return hookDefinition.appliesToTestCase(this.testCase) @@ -86,7 +86,7 @@ export default class TestCaseRunner { ) } - getBeforeHookDefinitions() { + getBeforeHookDefinitions () { return this.supportCodeLibrary.beforeTestCaseHookDefinitions.filter( hookDefinition => { return hookDefinition.appliesToTestCase(this.testCase) @@ -94,7 +94,7 @@ export default class TestCaseRunner { ) } - getStepDefinitions(step) { + getStepDefinitions (step) { return this.supportCodeLibrary.stepDefinitions.filter(stepDefinition => { return stepDefinition.matchesStepName({ stepName: step.text, @@ -103,7 +103,7 @@ export default class TestCaseRunner { }) } - invokeStep(step, stepDefinition, hookParameter) { + invokeStep (step, stepDefinition, hookParameter) { return StepRunner.run({ defaultTimeout: this.supportCodeLibrary.defaultTimeout, hookParameter, @@ -114,11 +114,11 @@ export default class TestCaseRunner { }) } - isSkippingSteps() { + isSkippingSteps () { return this.result.status !== Status.PASSED } - shouldUpdateStatus(testStepResult) { + shouldUpdateStatus (testStepResult) { switch (testStepResult.status) { case Status.FAILED: case Status.AMBIGUOUS: @@ -134,7 +134,7 @@ export default class TestCaseRunner { } } - async aroundTestStep(runStepFn) { + async aroundTestStep (runStepFn) { this.emit('test-step-started', { index: this.testStepIndex }) const testStepResult = await runStepFn() if (testStepResult.duration) { @@ -153,7 +153,7 @@ export default class TestCaseRunner { this.testStepIndex += 1 } - async run() { + async run () { this.emitPrepared() this.emit('test-case-started', {}) await this.runHooks(this.beforeHookDefinitions, { @@ -170,15 +170,15 @@ export default class TestCaseRunner { return this.result } - async runHook(hookDefinition, hookParameter) { + async runHook (hookDefinition, hookParameter) { if (this.skip) { return { status: Status.SKIPPED } } else { - return await this.invokeStep(null, hookDefinition, hookParameter) + return this.invokeStep(null, hookDefinition, hookParameter) } } - async runHooks(hookDefinitions, hookParameter) { + async runHooks (hookDefinitions, hookParameter) { await Promise.each(hookDefinitions, async hookDefinition => { await this.aroundTestStep(() => { return this.runHook(hookDefinition, hookParameter) @@ -186,7 +186,7 @@ export default class TestCaseRunner { }) } - async runStep(step) { + async runStep (step) { const stepDefinitions = this.getStepDefinitions(step) if (stepDefinitions.length === 0) { return { status: Status.UNDEFINED } @@ -198,11 +198,11 @@ export default class TestCaseRunner { } else if (this.isSkippingSteps()) { return { status: Status.SKIPPED } } else { - return await this.invokeStep(step, stepDefinitions[0]) + return this.invokeStep(step, stepDefinitions[0]) } } - async runSteps() { + async runSteps () { await Promise.each(this.testCase.pickle.steps, async step => { await this.aroundTestStep(() => { return this.runStep(step) diff --git a/src/runtime/test_case_runner_spec.js b/src/runtime/test_case_runner_spec.js index 6f655fc2b..d767ef52a 100644 --- a/src/runtime/test_case_runner_spec.js +++ b/src/runtime/test_case_runner_spec.js @@ -4,8 +4,8 @@ import Status from '../status' import StepRunner from './step_runner' import { EventEmitter } from 'events' -describe('TestCaseRunner', function() { - beforeEach(function() { +describe('TestCaseRunner', function () { + beforeEach(function () { this.onTestCasePrepared = sinon.stub() this.onTestCaseStarted = sinon.stub() this.onTestStepStarted = sinon.stub() @@ -30,18 +30,18 @@ describe('TestCaseRunner', function() { defaultTimeout: 5000, stepDefinitions: [], parameterTypeRegistry: {}, - World() {} + World () {} } sinon.stub(StepRunner, 'run') }) - afterEach(function() { + afterEach(function () { StepRunner.run.restore() }) - describe('run()', function() { - describe('with no steps or hooks', function() { - beforeEach(async function() { + describe('run()', function () { + describe('with no steps or hooks', function () { + beforeEach(async function () { const scenarioRunner = new TestCaseRunner({ eventBroadcaster: this.eventBroadcaster, skip: false, @@ -51,23 +51,23 @@ describe('TestCaseRunner', function() { await scenarioRunner.run() }) - it('emits test-case-prepared', function() { - expect(this.onTestCasePrepared).to.have.been.calledOnce + it('emits test-case-prepared', function () { + expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [], sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-case-started', function() { - expect(this.onTestCaseStarted).to.have.been.calledOnce + it('emits test-case-started', function () { + expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-case-finished', function() { - expect(this.onTestCaseFinished).to.have.been.calledOnce + it('emits test-case-finished', function () { + expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.PASSED }, sourceLocation: { line: 1, uri: 'path/to/feature' } @@ -75,8 +75,8 @@ describe('TestCaseRunner', function() { }) }) - describe('with a passing step', function() { - beforeEach(async function() { + describe('with a passing step', function () { + beforeEach(async function () { this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } this.stepResult = { duration: 1, @@ -99,8 +99,8 @@ describe('TestCaseRunner', function() { await scenarioRunner.run() }) - it('emits test-case-prepared', function() { - expect(this.onTestCasePrepared).to.have.been.calledOnce + it('emits test-case-prepared', function () { + expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ { @@ -112,23 +112,23 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-started', function() { - expect(this.onTestCaseStarted).to.have.been.calledOnce + it('emits test-case-started', function () { + expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function() { - expect(this.onTestStepStarted).to.have.been.calledOnce + it('emits test-step-started', function () { + expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } }) }) - it('emits test-step-finished', function() { - expect(this.onTestStepFinished).to.have.been.calledOnce + it('emits test-step-finished', function () { + expect(this.onTestStepFinished).to.have.callCount(1) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, @@ -136,8 +136,8 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-finished', function() { - expect(this.onTestCaseFinished).to.have.been.calledOnce + it('emits test-case-finished', function () { + expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 1, status: Status.PASSED }, sourceLocation: { line: 1, uri: 'path/to/feature' } @@ -145,8 +145,8 @@ describe('TestCaseRunner', function() { }) }) - describe('with a failing step', function() { - beforeEach(async function() { + describe('with a failing step', function () { + beforeEach(async function () { this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } this.error = new Error('a') this.stepResult = { @@ -171,8 +171,8 @@ describe('TestCaseRunner', function() { await scenarioRunner.run() }) - it('emits test-case-prepared', function() { - expect(this.onTestCasePrepared).to.have.been.calledOnce + it('emits test-case-prepared', function () { + expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ { @@ -184,23 +184,23 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-started', function() { - expect(this.onTestCaseStarted).to.have.been.calledOnce + it('emits test-case-started', function () { + expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function() { - expect(this.onTestStepStarted).to.have.been.calledOnce + it('emits test-step-started', function () { + expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } }) }) - it('emits test-step-finished', function() { - expect(this.onTestStepFinished).to.have.been.calledOnce + it('emits test-step-finished', function () { + expect(this.onTestStepFinished).to.have.callCount(1) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, @@ -212,8 +212,8 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-finished', function() { - expect(this.onTestCaseFinished).to.have.been.calledOnce + it('emits test-case-finished', function () { + expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 1, @@ -225,8 +225,8 @@ describe('TestCaseRunner', function() { }) }) - describe('with an ambiguous step', function() { - beforeEach(async function() { + describe('with an ambiguous step', function () { + beforeEach(async function () { this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } const stepDefinition1 = { pattern: 'pattern1', @@ -254,8 +254,8 @@ describe('TestCaseRunner', function() { await scenarioRunner.run() }) - it('emits test-case-prepared', function() { - expect(this.onTestCasePrepared).to.have.been.calledOnce + it('emits test-case-prepared', function () { + expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ { @@ -266,23 +266,23 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-started', function() { - expect(this.onTestCaseStarted).to.have.been.calledOnce + it('emits test-case-started', function () { + expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function() { - expect(this.onTestStepStarted).to.have.been.calledOnce + it('emits test-step-started', function () { + expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } }) }) - it('emits test-step-finished', function() { - expect(this.onTestStepFinished).to.have.been.calledOnce + it('emits test-step-finished', function () { + expect(this.onTestStepFinished).to.have.callCount(1) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, @@ -296,8 +296,8 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-finished', function() { - expect(this.onTestCaseFinished).to.have.been.calledOnce + it('emits test-case-finished', function () { + expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, @@ -312,8 +312,8 @@ describe('TestCaseRunner', function() { }) }) - describe('with an undefined step', function() { - beforeEach(async function() { + describe('with an undefined step', function () { + beforeEach(async function () { this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } this.testCase.pickle.steps = [this.step] const scenarioRunner = new TestCaseRunner({ @@ -325,31 +325,31 @@ describe('TestCaseRunner', function() { await scenarioRunner.run() }) - it('emits test-case-prepared', function() { - expect(this.onTestCasePrepared).to.have.been.calledOnce + it('emits test-case-prepared', function () { + expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [{ sourceLocation: { line: 2, uri: 'path/to/feature' } }], sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-case-started', function() { - expect(this.onTestCaseStarted).to.have.been.calledOnce + it('emits test-case-started', function () { + expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function() { - expect(this.onTestStepStarted).to.have.been.calledOnce + it('emits test-step-started', function () { + expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } }) }) - it('emits test-step-finished', function() { - expect(this.onTestStepFinished).to.have.been.calledOnce + it('emits test-step-finished', function () { + expect(this.onTestStepFinished).to.have.callCount(1) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, @@ -357,8 +357,8 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-finished', function() { - expect(this.onTestCaseFinished).to.have.been.calledOnce + it('emits test-case-finished', function () { + expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.UNDEFINED }, sourceLocation: { line: 1, uri: 'path/to/feature' } @@ -366,8 +366,8 @@ describe('TestCaseRunner', function() { }) }) - describe('with a step when skipping', function() { - beforeEach(async function() { + describe('with a step when skipping', function () { + beforeEach(async function () { this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } const stepDefinition = { uri: 'path/to/steps', @@ -385,8 +385,8 @@ describe('TestCaseRunner', function() { await scenarioRunner.run() }) - it('emits test-case-prepared', function() { - expect(this.onTestCasePrepared).to.have.been.calledOnce + it('emits test-case-prepared', function () { + expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ { @@ -398,23 +398,23 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-started', function() { - expect(this.onTestCaseStarted).to.have.been.calledOnce + it('emits test-case-started', function () { + expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function() { - expect(this.onTestStepStarted).to.have.been.calledOnce + it('emits test-step-started', function () { + expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } }) }) - it('emits test-step-finished', function() { - expect(this.onTestStepFinished).to.have.been.calledOnce + it('emits test-step-finished', function () { + expect(this.onTestStepFinished).to.have.callCount(1) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, @@ -422,8 +422,8 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-finished', function() { - expect(this.onTestCaseFinished).to.have.been.calledOnce + it('emits test-case-finished', function () { + expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.SKIPPED }, sourceLocation: { line: 1, uri: 'path/to/feature' } @@ -431,10 +431,10 @@ describe('TestCaseRunner', function() { }) }) - describe('with a before hook and step when skipping', function() { - beforeEach(async function() { + describe('with a before hook and step when skipping', function () { + beforeEach(async function () { const testCaseHookDefinition = new TestCaseHookDefinition({ - code() { + code () { throw new Error('error') }, line: 4, @@ -461,8 +461,8 @@ describe('TestCaseRunner', function() { await scenarioRunner.run() }) - it('emits test-case-prepared', function() { - expect(this.onTestCasePrepared).to.have.been.calledOnce + it('emits test-case-prepared', function () { + expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ { actionLocation: { line: 4, uri: 'path/to/hooks' } }, @@ -475,15 +475,15 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-started', function() { - expect(this.onTestCaseStarted).to.have.been.calledOnce + it('emits test-case-started', function () { + expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function() { - expect(this.onTestStepStarted).to.have.been.calledTwice + it('emits test-step-started', function () { + expect(this.onTestStepStarted).to.have.calledCount(2) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } @@ -494,8 +494,8 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-step-finished', function() { - expect(this.onTestStepFinished).to.have.been.calledTwice + it('emits test-step-finished', function () { + expect(this.onTestStepFinished).to.have.calledCount(2) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, @@ -508,8 +508,8 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-finished', function() { - expect(this.onTestCaseFinished).to.have.been.calledOnce + it('emits test-case-finished', function () { + expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.SKIPPED }, sourceLocation: { line: 1, uri: 'path/to/feature' } @@ -517,10 +517,10 @@ describe('TestCaseRunner', function() { }) }) - describe('with an after hook when skipping', function() { - beforeEach(async function() { + describe('with an after hook when skipping', function () { + beforeEach(async function () { const testCaseHookDefinition = new TestCaseHookDefinition({ - code() { + code () { throw new Error('error') }, line: 4, @@ -547,8 +547,8 @@ describe('TestCaseRunner', function() { await scenarioRunner.run() }) - it('emits test-case-prepared', function() { - expect(this.onTestCasePrepared).to.have.been.calledOnce + it('emits test-case-prepared', function () { + expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ { @@ -561,15 +561,15 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-started', function() { - expect(this.onTestCaseStarted).to.have.been.calledOnce + it('emits test-case-started', function () { + expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function() { - expect(this.onTestStepStarted).to.have.been.calledTwice + it('emits test-step-started', function () { + expect(this.onTestStepStarted).to.have.calledCount(2) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } @@ -580,8 +580,8 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-step-finished', function() { - expect(this.onTestStepFinished).to.have.been.calledTwice + it('emits test-step-finished', function () { + expect(this.onTestStepFinished).to.have.calledCount(2) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, @@ -594,8 +594,8 @@ describe('TestCaseRunner', function() { }) }) - it('emits test-case-finished', function() { - expect(this.onTestCaseFinished).to.have.been.calledOnce + it('emits test-case-finished', function () { + expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.SKIPPED }, sourceLocation: { line: 1, uri: 'path/to/feature' } diff --git a/src/status.js b/src/status.js index e37370bd6..b8fa1f7c1 100644 --- a/src/status.js +++ b/src/status.js @@ -11,7 +11,7 @@ const statuses = { export default statuses -export function getStatusMapping(initialValue) { +export function getStatusMapping (initialValue) { return _.chain(statuses) .map(status => [status, initialValue]) .fromPairs() diff --git a/src/status_spec.js b/src/status_spec.js index 2fd539d15..808dd845f 100644 --- a/src/status_spec.js +++ b/src/status_spec.js @@ -1,8 +1,8 @@ import Status, { getStatusMapping } from './status' -describe('Status', function() { - describe('constants', function() { - it('exposes the proper constants', function() { +describe('Status', function () { + describe('constants', function () { + it('exposes the proper constants', function () { expect(Status).to.include.keys([ 'AMBIGUOUS', 'FAILED', @@ -14,8 +14,8 @@ describe('Status', function() { }) }) - describe('getStatusMapping', function() { - it('returns a mapping of the statuses with the given initial value', function() { + describe('getStatusMapping', function () { + it('returns a mapping of the statuses with the given initial value', function () { const result = getStatusMapping(0) expect(result).to.eql({ [Status.AMBIGUOUS]: 0, diff --git a/src/step_arguments.js b/src/step_arguments.js index 5e8c9476e..2adf0ba16 100644 --- a/src/step_arguments.js +++ b/src/step_arguments.js @@ -1,7 +1,7 @@ import util from 'util' -export function buildStepArgumentIterator(mapping) { - return function(arg) { +export function buildStepArgumentIterator (mapping) { + return function (arg) { if (arg.hasOwnProperty('rows')) { return mapping.dataTable(arg) } else if (arg.hasOwnProperty('content')) { diff --git a/src/support_code_library_builder/define_helpers.js b/src/support_code_library_builder/define_helpers.js index ee998e986..07250abc8 100644 --- a/src/support_code_library_builder/define_helpers.js +++ b/src/support_code_library_builder/define_helpers.js @@ -9,7 +9,7 @@ import TestCaseHookDefinition from '../models/test_case_hook_definition' import TestRunHookDefinition from '../models/test_run_hook_definition' import validateArguments from './validate_arguments' -export function defineTestCaseHook(builder, collectionName) { +export function defineTestCaseHook (builder, collectionName) { return (options, code) => { if (typeof options === 'string') { options = { tags: options } @@ -33,7 +33,7 @@ export function defineTestCaseHook(builder, collectionName) { } } -export function defineTestRunHook(builder, collectionName) { +export function defineTestRunHook (builder, collectionName) { return (options, code) => { if (typeof options === 'string') { options = { tags: options } @@ -57,7 +57,7 @@ export function defineTestRunHook(builder, collectionName) { } } -export function defineStep(builder) { +export function defineStep (builder) { return (pattern, options, code) => { if (typeof options === 'function') { code = options @@ -84,7 +84,7 @@ const projectPath = path.join(__dirname, '..', '..') const projectSrcPath = path.join(projectPath, 'src') const projectLibPath = path.join(projectPath, 'lib') -function getDefinitionLineAndUri(cwd) { +function getDefinitionLineAndUri (cwd) { let line = 'unknown' let uri = 'unknown' const stackframes = StackTrace.getSync() @@ -105,7 +105,7 @@ function getDefinitionLineAndUri(cwd) { return { line, uri } } -export function defineParameterType(builder) { +export function defineParameterType (builder) { return ({ name, typeName, diff --git a/src/support_code_library_builder/finalize_helpers.js b/src/support_code_library_builder/finalize_helpers.js index 8490f7f21..99b7c3a15 100644 --- a/src/support_code_library_builder/finalize_helpers.js +++ b/src/support_code_library_builder/finalize_helpers.js @@ -3,7 +3,7 @@ import arity from 'util-arity' import isGenerator from 'is-generator' import path from 'path' -export function wrapDefinitions({ +export function wrapDefinitions ({ cwd, definitionFunctionWrapper, definitions diff --git a/src/support_code_library_builder/index.js b/src/support_code_library_builder/index.js index 3ee81bafb..5a437f525 100644 --- a/src/support_code_library_builder/index.js +++ b/src/support_code_library_builder/index.js @@ -10,7 +10,7 @@ import { import { wrapDefinitions } from './finalize_helpers' export class SupportCodeLibraryBuilder { - constructor() { + constructor () { this.methods = { defineParameterType: defineParameterType(this), After: defineTestCaseHook(this, 'afterTestCaseHookDefinitions'), @@ -34,7 +34,7 @@ export class SupportCodeLibraryBuilder { this.methods.Given = this.methods.When = this.methods.Then = this.methods.defineStep } - finalize() { + finalize () { wrapDefinitions({ cwd: this.cwd, definitionFunctionWrapper: this.options.definitionFunctionWrapper, @@ -54,7 +54,7 @@ export class SupportCodeLibraryBuilder { return this.options } - reset(cwd) { + reset (cwd) { this.cwd = cwd this.options = _.cloneDeep({ afterTestCaseHookDefinitions: [], @@ -65,7 +65,7 @@ export class SupportCodeLibraryBuilder { definitionFunctionWrapper: null, stepDefinitions: [], parameterTypeRegistry: TransformLookupBuilder.build(), - World({ attach, parameters }) { + World ({ attach, parameters }) { this.attach = attach this.parameters = parameters } diff --git a/src/support_code_library_builder/index_spec.js b/src/support_code_library_builder/index_spec.js index fc465ea46..4cc934f53 100644 --- a/src/support_code_library_builder/index_spec.js +++ b/src/support_code_library_builder/index_spec.js @@ -1,15 +1,15 @@ import { ParameterTypeRegistry } from 'cucumber-expressions' import supportCodeLibraryBuilder from './' -describe('supportCodeLibraryBuilder', function() { - describe('no support code fns', function() { - beforeEach(function() { +describe('supportCodeLibraryBuilder', function () { + describe('no support code fns', function () { + beforeEach(function () { this.attachFn = sinon.stub() supportCodeLibraryBuilder.reset('path/to/project') this.options = supportCodeLibraryBuilder.finalize() }) - it('returns the default options', function() { + it('returns the default options', function () { expect(this.options.afterTestRunHookDefinitions).to.eql([]) expect(this.options.afterTestCaseHookDefinitions).to.eql([]) expect(this.options.beforeTestRunHookDefinitions).to.eql([]) @@ -28,16 +28,16 @@ describe('supportCodeLibraryBuilder', function() { }) }) - describe('After', function() { - describe('function only', function() { - beforeEach(function() { - this.hook = function() {} + describe('After', function () { + describe('function only', function () { + beforeEach(function () { + this.hook = function () {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.After(this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function() { + it('adds a scenario hook definition', function () { expect(this.options.afterTestCaseHookDefinitions).to.have.lengthOf(1) expect(this.options.afterTestCaseHookDefinitions[0].code).to.eql( this.hook @@ -45,15 +45,15 @@ describe('supportCodeLibraryBuilder', function() { }) }) - describe('tag and function', function() { - beforeEach(function() { - this.hook = function() {} + describe('tag and function', function () { + beforeEach(function () { + this.hook = function () {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.After('@tagA', this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function() { + it('adds a scenario hook definition', function () { expect(this.options.afterTestCaseHookDefinitions).to.have.lengthOf(1) expect( this.options.afterTestCaseHookDefinitions[0].options.tags @@ -64,15 +64,15 @@ describe('supportCodeLibraryBuilder', function() { }) }) - describe('options and function', function() { - beforeEach(function() { - this.hook = function() {} + describe('options and function', function () { + beforeEach(function () { + this.hook = function () {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.After({ tags: '@tagA' }, this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function() { + it('adds a scenario hook definition', function () { expect(this.options.afterTestCaseHookDefinitions).to.have.lengthOf(1) expect( this.options.afterTestCaseHookDefinitions[0].options.tags @@ -83,17 +83,17 @@ describe('supportCodeLibraryBuilder', function() { }) }) - describe('multiple', function() { - beforeEach(function() { - this.hook1 = function hook1() {} - this.hook2 = function hook2() {} + describe('multiple', function () { + beforeEach(function () { + this.hook1 = function hook1 () {} + this.hook2 = function hook2 () {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.After(this.hook1) // eslint-disable-line babel/new-cap supportCodeLibraryBuilder.methods.After(this.hook2) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds the scenario hook definitions in the reverse order of definition', function() { + it('adds the scenario hook definitions in the reverse order of definition', function () { expect(this.options.afterTestCaseHookDefinitions).to.have.lengthOf(2) expect(this.options.afterTestCaseHookDefinitions[0].code).to.eql( this.hook2 @@ -105,16 +105,16 @@ describe('supportCodeLibraryBuilder', function() { }) }) - describe('this.Before', function() { - describe('function only', function() { - beforeEach(function() { - this.hook = function() {} + describe('this.Before', function () { + describe('function only', function () { + beforeEach(function () { + this.hook = function () {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.Before(this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function() { + it('adds a scenario hook definition', function () { expect(this.options.beforeTestCaseHookDefinitions).to.have.lengthOf(1) expect(this.options.beforeTestCaseHookDefinitions[0].code).to.eql( this.hook @@ -122,15 +122,15 @@ describe('supportCodeLibraryBuilder', function() { }) }) - describe('tag and function', function() { - beforeEach(function() { - this.hook = function() {} + describe('tag and function', function () { + beforeEach(function () { + this.hook = function () {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.Before('@tagA', this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function() { + it('adds a scenario hook definition', function () { expect(this.options.beforeTestCaseHookDefinitions).to.have.lengthOf(1) expect( this.options.beforeTestCaseHookDefinitions[0].options.tags @@ -141,15 +141,15 @@ describe('supportCodeLibraryBuilder', function() { }) }) - describe('options and function', function() { - beforeEach(function() { - this.hook = function() {} + describe('options and function', function () { + beforeEach(function () { + this.hook = function () {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.Before({ tags: '@tagA' }, this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function() { + it('adds a scenario hook definition', function () { expect(this.options.beforeTestCaseHookDefinitions).to.have.lengthOf(1) expect( this.options.beforeTestCaseHookDefinitions[0].options.tags @@ -160,17 +160,17 @@ describe('supportCodeLibraryBuilder', function() { }) }) - describe('multiple', function() { - beforeEach(function() { - this.hook1 = function hook1() {} - this.hook2 = function hook2() {} + describe('multiple', function () { + beforeEach(function () { + this.hook1 = function hook1 () {} + this.hook2 = function hook2 () {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.Before(this.hook1) // eslint-disable-line babel/new-cap supportCodeLibraryBuilder.methods.Before(this.hook2) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds the scenario hook definitions in the order of definition', function() { + it('adds the scenario hook definitions in the order of definition', function () { expect(this.options.beforeTestCaseHookDefinitions).to.have.lengthOf(2) expect(this.options.beforeTestCaseHookDefinitions[0].code).to.eql( this.hook1 diff --git a/src/support_code_library_builder/parameter_type_registry_builder.js b/src/support_code_library_builder/parameter_type_registry_builder.js index 1b07dde14..e7d902aef 100644 --- a/src/support_code_library_builder/parameter_type_registry_builder.js +++ b/src/support_code_library_builder/parameter_type_registry_builder.js @@ -1,6 +1,6 @@ import { ParameterTypeRegistry } from 'cucumber-expressions' -function build() { +function build () { return new ParameterTypeRegistry() } diff --git a/src/support_code_library_builder/validate_arguments.js b/src/support_code_library_builder/validate_arguments.js index 26e6437a0..886e1ce41 100644 --- a/src/support_code_library_builder/validate_arguments.js +++ b/src/support_code_library_builder/validate_arguments.js @@ -2,7 +2,7 @@ import _ from 'lodash' const optionsValidation = { expectedType: 'object or function', - predicate({ options }) { + predicate ({ options }) { return _.isPlainObject(options) } } @@ -10,14 +10,14 @@ const optionsValidation = { const optionsTimeoutValidation = { identifier: '"options.timeout"', expectedType: 'integer', - predicate({ options }) { + predicate ({ options }) { return !options.timeout || _.isInteger(options.timeout) } } const fnValidation = { expectedType: 'function', - predicate({ code }) { + predicate ({ code }) { return _.isFunction(code) } } @@ -33,7 +33,7 @@ const validations = { { identifier: '"options.tags"', expectedType: 'string', - predicate({ options }) { + predicate ({ options }) { return !options.tags || _.isString(options.tags) } }, @@ -44,7 +44,7 @@ const validations = { { identifier: 'first argument', expectedType: 'string or regular expression', - predicate({ pattern }) { + predicate ({ pattern }) { return _.isRegExp(pattern) || _.isString(pattern) } }, @@ -54,7 +54,7 @@ const validations = { ] } -export default function validateArguments({ args, fnName, location }) { +export default function validateArguments ({ args, fnName, location }) { validations[fnName].forEach(({ identifier, expectedType, predicate }) => { if (!predicate(args)) { throw new Error( diff --git a/src/time.js b/src/time.js index 2583d7f56..1c178b244 100644 --- a/src/time.js +++ b/src/time.js @@ -1,13 +1,13 @@ let previousTimestamp const methods = { - beginTiming() { + beginTiming () { previousTimestamp = getTimestamp() }, clearInterval: clearInterval.bind(global), clearTimeout: clearTimeout.bind(global), Date, - endTiming() { + endTiming () { return getTimestamp() - previousTimestamp }, setInterval: setInterval.bind(global), @@ -19,7 +19,7 @@ if (typeof setImmediate !== 'undefined') { methods.clearImmediate = clearImmediate.bind(global) } -function getTimestamp() { +function getTimestamp () { return new methods.Date().getTime() } diff --git a/src/uncaught_exception_manager.js b/src/uncaught_exception_manager.js index 84068314d..af8b12f62 100644 --- a/src/uncaught_exception_manager.js +++ b/src/uncaught_exception_manager.js @@ -1,5 +1,5 @@ export default class UncaughtExceptionManager { - static registerHandler(handler) { + static registerHandler (handler) { if (typeof window === 'undefined') { process.addListener('uncaughtException', handler) } else { @@ -7,7 +7,7 @@ export default class UncaughtExceptionManager { } } - static unregisterHandler(handler) { + static unregisterHandler (handler) { if (typeof window === 'undefined') { process.removeListener('uncaughtException', handler) } else { diff --git a/src/user_code_runner.js b/src/user_code_runner.js index 9a19b0add..3a151d562 100644 --- a/src/user_code_runner.js +++ b/src/user_code_runner.js @@ -4,9 +4,9 @@ import UncaughtExceptionManager from './uncaught_exception_manager' import util from 'util' export default class UserCodeRunner { - static async run({ argsArray, thisArg, fn, timeoutInMilliseconds }) { - const callbackPromise = new Promise(function(resolve, reject) { - argsArray.push(function(error, result) { + static async run ({ argsArray, thisArg, fn, timeoutInMilliseconds }) { + const callbackPromise = new Promise(function (resolve, reject) { + argsArray.push(function (error, result) { if (error) { reject(error) } else { @@ -44,7 +44,7 @@ export default class UserCodeRunner { } let exceptionHandler - const uncaughtExceptionPromise = new Promise(function(resolve, reject) { + const uncaughtExceptionPromise = new Promise(function (resolve, reject) { exceptionHandler = reject UncaughtExceptionManager.registerHandler(exceptionHandler) }) @@ -52,8 +52,8 @@ export default class UserCodeRunner { let timeoutId if (timeoutInMilliseconds >= 0) { - const timeoutPromise = new Promise(function(resolve, reject) { - timeoutId = Time.setTimeout(function() { + const timeoutPromise = new Promise(function (resolve, reject) { + timeoutId = Time.setTimeout(function () { const timeoutMessage = 'function timed out after ' + timeoutInMilliseconds + diff --git a/src/user_code_runner_spec.js b/src/user_code_runner_spec.js index 503aad832..d602844a0 100644 --- a/src/user_code_runner_spec.js +++ b/src/user_code_runner_spec.js @@ -1,9 +1,9 @@ import UserCodeRunner from './user_code_runner' import Promise from 'bluebird' -describe('UserCodeRunner', function() { - describe('run()', function() { - beforeEach(function() { +describe('UserCodeRunner', function () { + describe('run()', function () { + beforeEach(function () { this.options = { argsArray: [], thisArg: {}, @@ -11,239 +11,239 @@ describe('UserCodeRunner', function() { } }) - describe('function uses synchronous interface', function() { - describe('function throws serializable error', function() { - beforeEach(function() { - this.options.fn = function() { - throw 'error' + describe('function uses synchronous interface', function () { + describe('function throws serializable error', function () { + beforeEach(function () { + this.options.fn = function () { + throw 'error' // eslint-disable-line no-throw-literal } }) - it('returns the error', async function() { + it('returns the error', async function () { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('error') - expect(result).to.be.undefined + expect(result).to.eql(undefined) }) }) - describe('function throws non-serializable error', function() { - beforeEach(function() { - this.options.fn = function() { + describe('function throws non-serializable error', function () { + beforeEach(function () { + this.options.fn = function () { const error = {} error.error = error throw error } }) - it('returns the error', async function() { + it('returns the error', async function () { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('{ error: [Circular] }') - expect(result).to.be.undefined + expect(result).to.eql(undefined) }) }) - describe('function returns', function() { - beforeEach(function() { - this.options.fn = function() { + describe('function returns', function () { + beforeEach(function () { + this.options.fn = function () { return 'result' } }) - it('returns the return value of the function', async function() { + it('returns the return value of the function', async function () { const { error, result } = await UserCodeRunner.run(this.options) - expect(error).to.be.undefined + expect(error).to.eql(undefined) expect(result).to.eql('result') }) }) }) - describe('function uses callback interface', function() { - describe('function asynchronously throws', function() { + describe('function uses callback interface', function () { + describe('function asynchronously throws', function () { // Cannot unit test because mocha also sets an uncaught exception handler }) - describe('function calls back with serializable error', function() { - beforeEach(function() { - this.options.fn = function(callback) { - setTimeout(function() { - callback('error') + describe('function calls back with serializable error', function () { + beforeEach(function () { + this.options.fn = function (callback) { + setTimeout(function () { + callback('error') // eslint-disable-line standard/no-callback-literal }, 25) } }) - it('returns the error', async function() { + it('returns the error', async function () { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('error') - expect(result).to.be.undefined + expect(result).to.eql(undefined) }) }) - describe('function calls back with non-serializable rror', function() { - beforeEach(function() { - this.options.fn = function(callback) { + describe('function calls back with non-serializable rror', function () { + beforeEach(function () { + this.options.fn = function (callback) { const error = {} error.error = error - setTimeout(function() { + setTimeout(function () { callback(error) }, 25) } }) - it('returns the error', async function() { + it('returns the error', async function () { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('{ error: [Circular] }') - expect(result).to.be.undefined + expect(result).to.eql(undefined) }) }) - describe('function calls back with result', function() { - beforeEach(function() { - this.options.fn = function(callback) { - setTimeout(function() { + describe('function calls back with result', function () { + beforeEach(function () { + this.options.fn = function (callback) { + setTimeout(function () { callback(null, 'result') }, 25) } }) - it('returns the what the function calls back with', async function() { + it('returns the what the function calls back with', async function () { const { error, result } = await UserCodeRunner.run(this.options) - expect(error).to.be.undefined + expect(error).to.eql(undefined) expect(result).to.eql('result') }) }) - describe('function times out', function() { - beforeEach(function() { - this.options.fn = function(callback) { - setTimeout(function() { + describe('function times out', function () { + beforeEach(function () { + this.options.fn = function (callback) { + setTimeout(function () { callback(null, 'result') }, 200) } }) - it('returns timeout as an error', async function() { + it('returns timeout as an error', async function () { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceof(Error) expect(error.message).to.eql( 'function timed out after 100 milliseconds' ) - expect(result).to.be.undefined + expect(result).to.eql(undefined) }) }) - describe('timeout of -1', function() { - beforeEach(function() { - this.options.fn = function(callback) { - setTimeout(function() { + describe('timeout of -1', function () { + beforeEach(function () { + this.options.fn = function (callback) { + setTimeout(function () { callback(null, 'result') }, 200) } this.options.timeoutInMilliseconds = -1 }) - it('disables timeout protection', async function() { + it('disables timeout protection', async function () { const { error, result } = await UserCodeRunner.run(this.options) - expect(error).to.be.undefined + expect(error).to.eql(undefined) expect(result).to.eql('result') }) }) }) - describe('function uses promise interface', function() { - describe('function asynchronously throws', function() { + describe('function uses promise interface', function () { + describe('function asynchronously throws', function () { // Cannot unit test because mocha also sets an uncaught exception handler }) - describe('promise resolves', function() { - beforeEach(function() { - this.options.fn = function() { + describe('promise resolves', function () { + beforeEach(function () { + this.options.fn = function () { return Promise.resolve('result') } }) - it('returns what the promise resolves to', async function() { + it('returns what the promise resolves to', async function () { const { error, result } = await UserCodeRunner.run(this.options) - expect(error).to.be.undefined + expect(error).to.eql(undefined) expect(result).to.eql('result') }) }) - describe('promise rejects with reason', function() { - beforeEach(function() { - this.options.fn = function() { - return Promise.reject('error') + describe('promise rejects with reason', function () { + beforeEach(function () { + this.options.fn = function () { + return Promise.reject('error') // eslint-disable-line prefer-promise-reject-errors } }) - it('returns what the promise rejects as an error', async function() { + it('returns what the promise rejects as an error', async function () { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('error') - expect(result).to.be.undefined + expect(result).to.eql(undefined) }) }) - describe('promise rejects without reason', function() { - beforeEach(function() { - this.options.fn = function() { - return Promise.reject() + describe('promise rejects without reason', function () { + beforeEach(function () { + this.options.fn = function () { + return Promise.reject() // eslint-disable-line prefer-promise-reject-errors } }) - it('returns a helpful error message', async function() { + it('returns a helpful error message', async function () { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('Promise rejected without a reason') - expect(result).to.be.undefined + expect(result).to.eql(undefined) }) }) - describe('function times out', function() { - beforeEach(function() { - this.options.fn = function() { + describe('function times out', function () { + beforeEach(function () { + this.options.fn = function () { return Promise.resolve('result').delay(200) } }) - it('returns timeout as an error', async function() { + it('returns timeout as an error', async function () { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceof(Error) expect(error.message).to.eql( 'function timed out after 100 milliseconds' ) - expect(result).to.be.undefined + expect(result).to.eql(undefined) }) }) - describe('timeout of -1', function() { - beforeEach(function() { - this.options.fn = function() { + describe('timeout of -1', function () { + beforeEach(function () { + this.options.fn = function () { return Promise.resolve('result').delay(200) } this.options.timeoutInMilliseconds = -1 }) - it('disables timeout protection', async function() { + it('disables timeout protection', async function () { const { error, result } = await UserCodeRunner.run(this.options) - expect(error).to.be.undefined + expect(error).to.eql(undefined) expect(result).to.eql('result') }) }) }) - describe('function uses multiple asynchronous interfaces: callback and promise', function() { - beforeEach(function() { - this.options.fn = function(callback) { + describe('function uses multiple asynchronous interfaces: callback and promise', function () { + beforeEach(function () { + this.options.fn = function (callback) { callback() return Promise.resolve() } }) - it('returns an error that multiple interface are used', async function() { + it('returns an error that multiple interface are used', async function () { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceof(Error) expect(error.message).to.eql( @@ -251,7 +251,7 @@ describe('UserCodeRunner', function() { 'to use the callback interface: do not return a promise\n' + 'to use the promise interface: remove the last argument to the function' ) - expect(result).to.be.undefined + expect(result).to.eql(undefined) }) }) }) diff --git a/yarn.lock b/yarn.lock index a965b0b55..51849b330 100644 --- a/yarn.lock +++ b/yarn.lock @@ -27,22 +27,22 @@ acorn@^4.0.3: version "4.0.13" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787" -acorn@^5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.2.tgz#911cb53e036807cf0fa778dc5d370fbd864246d7" +acorn@^5.2.1: + version "5.3.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822" -ajv-keywords@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.0.tgz#a296e17f7bfae7c1ce4f7e0de53d29cb32162df0" +ajv-keywords@^1.0.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" -ajv@^4.9.1: +ajv@^4.7.0, ajv@^4.9.1: version "4.11.8" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" -ajv@^5.1.0, ajv@^5.2.0, ajv@^5.2.3: +ajv@^5.1.0: version "5.2.3" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.2.3.tgz#c06f598778c44c6b161abafe3466b81ad1814ed2" dependencies: @@ -63,9 +63,9 @@ amdefine@>=0.0.4: version "1.0.1" resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" -ansi-escapes@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" +ansi-escapes@^1.1.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" ansi-html@^0.0.7: version "0.0.7" @@ -163,6 +163,13 @@ array-unique@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" +array.prototype.find@^2.0.1: + version "2.0.4" + resolved "https://registry.yarnpkg.com/array.prototype.find/-/array.prototype.find-2.0.4.tgz#556a5c5362c08648323ddaeb9de9d14bc1864c90" + dependencies: + define-properties "^1.1.2" + es-abstract "^1.7.0" + arrify@^1.0.0, arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" @@ -264,7 +271,7 @@ babel-code-frame@7.0.0-beta.0: esutils "^2.0.2" js-tokens "^3.0.0" -babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: +babel-code-frame@^6.16.0, babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" dependencies: @@ -1088,7 +1095,7 @@ chai@^4.0.1: pathval "^1.0.0" type-detect "^4.0.0" -chalk@^1.1.3: +chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: @@ -1098,7 +1105,7 @@ chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.1.0: +chalk@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" dependencies: @@ -1136,11 +1143,11 @@ circular-json@^0.3.1: version "0.3.3" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" -cli-cursor@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" +cli-cursor@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" dependencies: - restore-cursor "^2.0.0" + restore-cursor "^1.0.1" cli-table@^0.3.1: version "0.3.1" @@ -1225,7 +1232,7 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.6.0: +concat-stream@^1.5.2: version "1.6.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" dependencies: @@ -1264,6 +1271,10 @@ constants-browserify@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" +contains-path@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a" + convert-source-map@^1.3.0, convert-source-map@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" @@ -1324,7 +1335,7 @@ cross-spawn@^4: lru-cache "^4.0.1" which "^1.2.9" -cross-spawn@^5.0.1, cross-spawn@^5.1.0: +cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" dependencies: @@ -1391,11 +1402,11 @@ date-now@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" -debug-log@^1.0.1: +debug-log@^1.0.0, debug-log@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f" -debug@2.6.9, debug@^2.2.0, debug@^2.6.3, debug@^2.6.8: +debug@2.6.9, debug@^2.1.1, debug@^2.2.0, debug@^2.6.3, debug@^2.6.8: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: @@ -1431,10 +1442,28 @@ default-require-extensions@^1.0.0: dependencies: strip-bom "^2.0.0" +define-properties@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" + dependencies: + foreach "^2.0.5" + object-keys "^1.0.8" + defined@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" +deglob@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/deglob/-/deglob-2.1.0.tgz#4d44abe16ef32c779b4972bd141a80325029a14a" + dependencies: + find-root "^1.0.0" + glob "^7.0.5" + ignore "^3.0.9" + pkg-config "^1.1.0" + run-parallel "^1.1.2" + uniq "^1.0.1" + del@^2.0.2: version "2.2.2" resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" @@ -1530,13 +1559,19 @@ docopt@^0.6.0: version "0.6.2" resolved "https://registry.yarnpkg.com/docopt/-/docopt-0.6.2.tgz#b28e9e2220da5ec49f7ea5bb24a47787405eeb11" -doctrine@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.0.tgz#c73d8d2909d22291e1a007a395804da8b665fe63" +doctrine@1.5.0, doctrine@^1.2.2: + version "1.5.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" dependencies: esutils "^2.0.2" isarray "^1.0.0" +doctrine@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" + dependencies: + esutils "^2.0.2" + domain-browser@~1.1.0: version "1.1.7" resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" @@ -1580,7 +1615,7 @@ encodeurl@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20" -error-ex@^1.2.0: +error-ex@^1.2.0, error-ex@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" dependencies: @@ -1592,6 +1627,24 @@ error-stack-parser@^2.0.1: dependencies: stackframe "^1.0.3" +es-abstract@^1.7.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.10.0.tgz#1ecb36c197842a00d8ee4c2dfd8646bb97d60864" + dependencies: + es-to-primitive "^1.1.1" + function-bind "^1.1.1" + has "^1.0.1" + is-callable "^1.1.3" + is-regex "^1.0.4" + +es-to-primitive@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d" + dependencies: + is-callable "^1.1.1" + is-date-object "^1.0.1" + is-symbol "^1.0.1" + es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14, es5-ext@~0.10.2: version "0.10.31" resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.31.tgz#7bb938c95a7f1b9f728092dc09c41edcc398eefe" @@ -1599,6 +1652,21 @@ es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14, es5-ext@~0.10.2: es6-iterator "~2.0.1" es6-symbol "~3.1.1" +es5-ext@^0.10.35: + version "0.10.38" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.38.tgz#fa7d40d65bbc9bb8a67e1d3f9cc656a00530eed3" + dependencies: + es6-iterator "~2.0.3" + es6-symbol "~3.1.1" + +es6-iterator@^2.0.1, es6-iterator@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + es6-iterator@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512" @@ -1607,13 +1675,43 @@ es6-iterator@~2.0.1: es5-ext "^0.10.14" es6-symbol "^3.1" -es6-symbol@^3.1, es6-symbol@~3.1.1: +es6-map@^0.1.3: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.5.tgz#9136e0503dcc06a301690f0bb14ff4e364e949f0" + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-set "~0.1.5" + es6-symbol "~3.1.1" + event-emitter "~0.3.5" + +es6-set@~0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1" + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-symbol "3.1.1" + event-emitter "~0.3.5" + +es6-symbol@3.1.1, es6-symbol@^3.1, es6-symbol@^3.1.1, es6-symbol@~3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" dependencies: d "1" es5-ext "~0.10.14" +es6-weak-map@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" + dependencies: + d "1" + es5-ext "^0.10.14" + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" + escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" @@ -1622,77 +1720,126 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" -eslint-config-prettier@^2.2.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.6.0.tgz#f21db0ebb438ad678fb98946097c4bb198befccc" +escope@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/escope/-/escope-3.6.0.tgz#e01975e812781a163a6dadfdd80398dc64c889c3" dependencies: - get-stdin "^5.0.1" + es6-map "^0.1.3" + es6-weak-map "^2.0.1" + esrecurse "^4.1.0" + estraverse "^4.1.1" -eslint-plugin-babel@^4.0.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-babel/-/eslint-plugin-babel-4.1.2.tgz#79202a0e35757dd92780919b2336f1fa2fe53c1e" +eslint-config-standard-jsx@4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/eslint-config-standard-jsx/-/eslint-config-standard-jsx-4.0.2.tgz#009e53c4ddb1e9ee70b4650ffe63a7f39f8836e1" -eslint-plugin-prettier@^2.1.2: - version "2.3.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.3.1.tgz#e7a746c67e716f335274b88295a9ead9f544e44d" +eslint-config-standard@10.2.1: + version "10.2.1" + resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-10.2.1.tgz#c061e4d066f379dc17cd562c64e819b4dd454591" + +eslint-import-resolver-node@^0.2.0: + version "0.2.3" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.2.3.tgz#5add8106e8c928db2cba232bcd9efa846e3da16c" dependencies: - fast-diff "^1.1.1" - jest-docblock "^21.0.0" + debug "^2.2.0" + object-assign "^4.0.1" + resolve "^1.1.6" -eslint-scope@^3.7.1: - version "3.7.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" +eslint-module-utils@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.1.1.tgz#abaec824177613b8a95b299639e1b6facf473449" dependencies: - esrecurse "^4.1.0" - estraverse "^4.1.1" + debug "^2.6.8" + pkg-dir "^1.0.0" -eslint@^4.1.1: - version "4.8.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.8.0.tgz#229ef0e354e0e61d837c7a80fdfba825e199815e" +eslint-plugin-import@~2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.2.0.tgz#72ba306fad305d67c4816348a4699a4229ac8b4e" dependencies: - ajv "^5.2.0" - babel-code-frame "^6.22.0" - chalk "^2.1.0" - concat-stream "^1.6.0" - cross-spawn "^5.1.0" - debug "^3.0.1" + builtin-modules "^1.1.1" + contains-path "^0.1.0" + debug "^2.2.0" + doctrine "1.5.0" + eslint-import-resolver-node "^0.2.0" + eslint-module-utils "^2.0.0" + has "^1.0.1" + lodash.cond "^4.3.0" + minimatch "^3.0.3" + pkg-up "^1.0.0" + +eslint-plugin-node@~4.2.2: + version "4.2.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-4.2.3.tgz#c04390ab8dbcbb6887174023d6f3a72769e63b97" + dependencies: + ignore "^3.0.11" + minimatch "^3.0.2" + object-assign "^4.0.1" + resolve "^1.1.7" + semver "5.3.0" + +eslint-plugin-promise@~3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.5.0.tgz#78fbb6ffe047201627569e85a6c5373af2a68fca" + +eslint-plugin-react@~6.10.0: + version "6.10.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.10.3.tgz#c5435beb06774e12c7db2f6abaddcbf900cd3f78" + dependencies: + array.prototype.find "^2.0.1" + doctrine "^1.2.2" + has "^1.0.1" + jsx-ast-utils "^1.3.4" + object.assign "^4.0.4" + +eslint-plugin-standard@~3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz#34d0c915b45edc6f010393c7eef3823b08565cf2" + +eslint@~3.19.0: + version "3.19.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc" + dependencies: + babel-code-frame "^6.16.0" + chalk "^1.1.3" + concat-stream "^1.5.2" + debug "^2.1.1" doctrine "^2.0.0" - eslint-scope "^3.7.1" - espree "^3.5.1" + escope "^3.6.0" + espree "^3.4.0" esquery "^1.0.0" estraverse "^4.2.0" esutils "^2.0.2" file-entry-cache "^2.0.0" - functional-red-black-tree "^1.0.1" - glob "^7.1.2" - globals "^9.17.0" - ignore "^3.3.3" + glob "^7.0.3" + globals "^9.14.0" + ignore "^3.2.0" imurmurhash "^0.1.4" - inquirer "^3.0.6" + inquirer "^0.12.0" + is-my-json-valid "^2.10.0" is-resolvable "^1.0.0" - js-yaml "^3.9.1" - json-stable-stringify "^1.0.1" + js-yaml "^3.5.1" + json-stable-stringify "^1.0.0" levn "^0.3.0" - lodash "^4.17.4" - minimatch "^3.0.2" - mkdirp "^0.5.1" + lodash "^4.0.0" + mkdirp "^0.5.0" natural-compare "^1.4.0" optionator "^0.8.2" - path-is-inside "^1.0.2" - pluralize "^7.0.0" - progress "^2.0.0" - require-uncached "^1.0.3" - semver "^5.3.0" - strip-ansi "^4.0.0" + path-is-inside "^1.0.1" + pluralize "^1.2.1" + progress "^1.1.8" + require-uncached "^1.0.2" + shelljs "^0.7.5" + strip-bom "^3.0.0" strip-json-comments "~2.0.1" - table "^4.0.1" + table "^3.7.8" text-table "~0.2.0" + user-home "^2.0.0" -espree@^3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.1.tgz#0c988b8ab46db53100a1954ae4ba995ddd27d87e" +espree@^3.4.0: + version "3.5.2" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca" dependencies: - acorn "^5.1.1" + acorn "^5.2.1" acorn-jsx "^3.0.0" esprima@^4.0.0: @@ -1724,6 +1871,13 @@ etag@~1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" +event-emitter@~0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" + dependencies: + d "1" + es5-ext "~0.10.14" + events@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" @@ -1747,6 +1901,10 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" +exit-hook@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" + expand-brackets@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" @@ -1763,14 +1921,6 @@ extend@~3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" -external-editor@^2.0.4: - version "2.0.5" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.0.5.tgz#52c249a3981b9ba187c7cacf5beb50bf1d91a6bc" - dependencies: - iconv-lite "^0.4.17" - jschardet "^1.4.2" - tmp "^0.0.33" - extglob@^0.3.1: version "0.3.2" resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" @@ -1785,20 +1935,23 @@ fast-deep-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" -fast-diff@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154" - fast-levenshtein@~2.0.4: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" -figures@2.0.0, figures@^2.0.0: +figures@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" dependencies: escape-string-regexp "^1.0.5" +figures@^1.3.5: + version "1.7.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" + dependencies: + escape-string-regexp "^1.0.5" + object-assign "^4.1.0" + file-entry-cache@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" @@ -1840,6 +1993,10 @@ find-cache-dir@^0.1.1: mkdirp "^0.5.1" pkg-dir "^1.0.0" +find-root@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4" + find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -1872,6 +2029,10 @@ for-own@^0.1.4: dependencies: for-in "^1.0.1" +foreach@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" + foreground-child@^1.5.3, foreground-child@^1.5.6: version "1.5.6" resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-1.5.6.tgz#4fd71ad2dfde96789b980a5c0a295937cb2f5ce9" @@ -1957,14 +2118,10 @@ fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: mkdirp ">=0.5 0" rimraf "2" -function-bind@^1.0.2: +function-bind@^1.0.2, function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - gauge@~2.7.3: version "2.7.4" resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" @@ -1978,6 +2135,16 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" +generate-function@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" + +generate-object-property@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + dependencies: + is-property "^1.0.0" + get-caller-file@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" @@ -2032,7 +2199,7 @@ globals@^10.0.0: version "10.1.0" resolved "https://registry.yarnpkg.com/globals/-/globals-10.1.0.tgz#4425a1881be0d336b4a823a82a7be725d5dd987c" -globals@^9.17.0, globals@^9.18.0: +globals@^9.14.0, globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" @@ -2101,11 +2268,15 @@ has-flag@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" +has-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" + has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" -has@^1.0.0: +has@^1.0.0, has@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" dependencies: @@ -2213,17 +2384,13 @@ https-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" -iconv-lite@^0.4.17: - version "0.4.19" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" - ieee754@^1.1.4: version "1.1.8" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" -ignore@^3.3.3: - version "3.3.5" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.5.tgz#c4e715455f6073a8d7e5dae72d2fc9d71663dba6" +ignore@^3.0.11, ignore@^3.0.9, ignore@^3.2.0: + version "3.3.7" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021" imurmurhash@^0.1.4: version "0.1.4" @@ -2262,23 +2429,22 @@ inline-source-map@~0.6.0: dependencies: source-map "~0.5.3" -inquirer@^3.0.6: - version "3.3.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" +inquirer@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.12.0.tgz#1ef2bfd63504df0bc75785fff8c2c41df12f077e" dependencies: - ansi-escapes "^3.0.0" - chalk "^2.0.0" - cli-cursor "^2.1.0" + ansi-escapes "^1.1.0" + ansi-regex "^2.0.0" + chalk "^1.0.0" + cli-cursor "^1.0.1" cli-width "^2.0.0" - external-editor "^2.0.4" - figures "^2.0.0" + figures "^1.3.5" lodash "^4.3.0" - mute-stream "0.0.7" - run-async "^2.2.0" - rx-lite "^4.0.8" - rx-lite-aggregates "^4.0.8" - string-width "^2.1.0" - strip-ansi "^4.0.0" + readline2 "^1.0.1" + run-async "^0.1.0" + rx-lite "^3.1.2" + string-width "^1.0.1" + strip-ansi "^3.0.0" through "^2.3.6" insert-module-globals@^7.0.0: @@ -2294,6 +2460,10 @@ insert-module-globals@^7.0.0: through2 "^2.0.0" xtend "^4.0.0" +interpret@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" + invariant@^2.2.0, invariant@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" @@ -2324,6 +2494,14 @@ is-builtin-module@^1.0.0: dependencies: builtin-modules "^1.0.0" +is-callable@^1.1.1, is-callable@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2" + +is-date-object@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" + is-dotfile@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" @@ -2368,6 +2546,15 @@ is-glob@^2.0.0, is-glob@^2.0.1: dependencies: is-extglob "^1.0.0" +is-my-json-valid@^2.10.0: + version "2.17.1" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.17.1.tgz#3da98914a70a22f0a8563ef1511a246c6fc55471" + dependencies: + generate-function "^2.0.0" + generate-object-property "^1.1.0" + jsonpointer "^4.0.0" + xtend "^4.0.0" + is-number@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" @@ -2391,8 +2578,8 @@ is-path-in-cwd@^1.0.0: is-path-inside "^1.0.0" is-path-inside@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.0.tgz#fc06e5a1683fbda13de667aff717bbc10a48f37f" + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" dependencies: path-is-inside "^1.0.1" @@ -2404,20 +2591,28 @@ is-primitive@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" -is-promise@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" +is-property@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" -is-resolvable@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62" +is-regex@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" dependencies: - tryit "^1.0.1" + has "^1.0.1" + +is-resolvable@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88" is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" +is-symbol@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" + is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" @@ -2495,15 +2690,11 @@ istanbul-reports@^1.1.1: dependencies: handlebars "^4.0.3" -jest-docblock@^21.0.0: - version "21.2.0" - resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" - js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" -js-yaml@^3.3.1, js-yaml@^3.6.1, js-yaml@^3.9.1: +js-yaml@^3.3.1, js-yaml@^3.5.1, js-yaml@^3.6.1: version "3.10.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" dependencies: @@ -2514,10 +2705,6 @@ jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" -jschardet@^1.4.2: - version "1.5.1" - resolved "https://registry.yarnpkg.com/jschardet/-/jschardet-1.5.1.tgz#c519f629f86b3a5bedba58a88d311309eec097f9" - jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" @@ -2526,6 +2713,10 @@ jsesc@~0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" +json-parse-better-errors@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.1.tgz#50183cd1b2d25275de069e9e71b467ac9eab973a" + json-schema-traverse@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" @@ -2534,7 +2725,7 @@ json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" -json-stable-stringify@^1.0.1: +json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" dependencies: @@ -2574,6 +2765,10 @@ jsonparse@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" +jsonpointer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" + jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" @@ -2583,6 +2778,10 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" +jsx-ast-utils@^1.3.4: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz#3867213e8dd79bf1e8f2300c0cfc1efb182c0df1" + just-extend@^1.1.22: version "1.1.22" resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-1.1.22.tgz#3330af756cab6a542700c64b2e4e4aa062d52fff" @@ -2659,6 +2858,15 @@ load-json-file@^2.0.0: pify "^2.0.0" strip-bom "^3.0.0" +load-json-file@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" + dependencies: + graceful-fs "^4.1.2" + parse-json "^4.0.0" + pify "^3.0.0" + strip-bom "^3.0.0" + locate-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" @@ -2666,6 +2874,10 @@ locate-path@^2.0.0: p-locate "^2.0.0" path-exists "^3.0.0" +lodash.cond@^4.3.0: + version "4.5.2" + resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5" + lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" @@ -2674,7 +2886,7 @@ lodash.memoize@~3.0.3: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" -lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: +lodash@^4.0.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -2791,7 +3003,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" -minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: +minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: @@ -2858,9 +3070,9 @@ mustache@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/mustache/-/mustache-2.3.0.tgz#4028f7778b17708a489930a6e52ac3bca0da41d0" -mute-stream@0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" +mute-stream@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" mz@^2.4.0: version "2.7.0" @@ -2994,6 +3206,19 @@ object-assign@^4.0.0, object-assign@^4.0.1, object-assign@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" +object-keys@^1.0.11, object-keys@^1.0.8: + version "1.0.11" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" + +object.assign@^4.0.4: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" + dependencies: + define-properties "^1.1.2" + function-bind "^1.1.1" + has-symbols "^1.0.0" + object-keys "^1.0.11" + object.omit@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" @@ -3013,11 +3238,9 @@ once@^1.3.0, once@^1.3.3: dependencies: wrappy "1" -onetime@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" - dependencies: - mimic-fn "^1.0.0" +onetime@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" optimist@^0.6.1: version "0.6.1" @@ -3127,6 +3350,13 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + parseurl@~1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" @@ -3149,7 +3379,7 @@ path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" -path-is-inside@^1.0.1, path-is-inside@^1.0.2: +path-is-inside@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" @@ -3211,6 +3441,10 @@ pify@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + pinkie-promise@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" @@ -3221,15 +3455,36 @@ pinkie@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" +pkg-conf@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/pkg-conf/-/pkg-conf-2.1.0.tgz#2126514ca6f2abfebd168596df18ba57867f0058" + dependencies: + find-up "^2.0.0" + load-json-file "^4.0.0" + +pkg-config@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pkg-config/-/pkg-config-1.1.1.tgz#557ef22d73da3c8837107766c52eadabde298fe4" + dependencies: + debug-log "^1.0.0" + find-root "^1.0.0" + xtend "^4.0.1" + pkg-dir@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4" dependencies: find-up "^1.0.0" -pluralize@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" +pkg-up@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-1.0.0.tgz#3e08fb461525c4421624a33b9f7e6d0af5b05a26" + dependencies: + find-up "^1.0.0" + +pluralize@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" prelude-ls@~1.1.2: version "1.1.2" @@ -3239,10 +3494,6 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -prettier@^1.5.2: - version "1.7.4" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.4.tgz#5e8624ae9363c80f95ec644584ecdf55d74f93fa" - private@^0.1.6, private@^0.1.7: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -3255,6 +3506,10 @@ process@~0.11.0: version "0.11.10" resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" +progress@^1.1.8: + version "1.1.8" + resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" + progress@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" @@ -3395,6 +3650,20 @@ readdirp@^2.0.0: readable-stream "^2.0.2" set-immediate-shim "^1.0.1" +readline2@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/readline2/-/readline2-1.0.1.tgz#41059608ffc154757b715d9989d199ffbf372e35" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + mute-stream "0.0.5" + +rechoir@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" + dependencies: + resolve "^1.1.6" + regenerate@^1.2.1: version "1.3.3" resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.3.tgz#0c336d3980553d755c39b586ae3b20aa49c82b7f" @@ -3519,7 +3788,7 @@ require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" -require-uncached@^1.0.3: +require-uncached@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" dependencies: @@ -3544,12 +3813,18 @@ resolve@^1.1.3, resolve@^1.1.4, resolve@^1.3.3: dependencies: path-parse "^1.0.5" -restore-cursor@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" +resolve@^1.1.6, resolve@^1.1.7: + version "1.5.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" dependencies: - onetime "^2.0.0" - signal-exit "^3.0.2" + path-parse "^1.0.5" + +restore-cursor@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" + dependencies: + exit-hook "^1.0.0" + onetime "^1.0.0" right-align@^0.1.1: version "0.1.3" @@ -3570,21 +3845,19 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^2.0.0" inherits "^2.0.1" -run-async@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" +run-async@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" dependencies: - is-promise "^2.1.0" + once "^1.3.0" -rx-lite-aggregates@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" - dependencies: - rx-lite "*" +run-parallel@^1.1.2: + version "1.1.6" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.6.tgz#29003c9a2163e01e2d2dfc90575f2c6c1d61a039" -rx-lite@*, rx-lite@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" +rx-lite@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.1" @@ -3598,6 +3871,10 @@ samsam@1.x, samsam@^1.1.3: version "5.4.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" +semver@5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + send@0.16.1: version "0.16.1" resolved "https://registry.yarnpkg.com/send/-/send-0.16.1.tgz#a70e1ca21d1382c11d0d9f6231deb281080d7ab3" @@ -3670,6 +3947,14 @@ shell-quote@^1.6.1: array-reduce "~0.0.0" jsonify "~0.0.0" +shelljs@^0.7.5: + version "0.7.8" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" + signal-exit@^3.0.0, signal-exit@^3.0.1, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" @@ -3697,11 +3982,9 @@ slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" -slice-ansi@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" - dependencies: - is-fullwidth-code-point "^2.0.0" +slice-ansi@0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" slide@^1.1.5: version "1.1.6" @@ -3815,6 +4098,29 @@ stacktrace-js@^2.0.0: stack-generator "^2.0.1" stacktrace-gps "^3.0.1" +standard-engine@~7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/standard-engine/-/standard-engine-7.0.0.tgz#ebb77b9c8fc2c8165ffa353bd91ba0dff41af690" + dependencies: + deglob "^2.1.0" + get-stdin "^5.0.1" + minimist "^1.1.0" + pkg-conf "^2.0.0" + +standard@^10.0.3: + version "10.0.3" + resolved "https://registry.yarnpkg.com/standard/-/standard-10.0.3.tgz#7869bcbf422bdeeaab689a1ffb1fea9677dd50ea" + dependencies: + eslint "~3.19.0" + eslint-config-standard "10.2.1" + eslint-config-standard-jsx "4.0.2" + eslint-plugin-import "~2.2.0" + eslint-plugin-node "~4.2.2" + eslint-plugin-promise "~3.5.0" + eslint-plugin-react "~6.10.0" + eslint-plugin-standard "~3.0.1" + standard-engine "~7.0.0" + "statuses@>= 1.3.1 < 2", statuses@~1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" @@ -3868,7 +4174,7 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: +string-width@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" dependencies: @@ -3947,16 +4253,16 @@ syntax-error@^1.1.1: dependencies: acorn "^4.0.3" -table@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36" +table@^3.7.8: + version "3.8.3" + resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" dependencies: - ajv "^5.2.3" - ajv-keywords "^2.1.0" - chalk "^2.1.0" - lodash "^4.17.4" - slice-ansi "1.0.0" - string-width "^2.1.1" + ajv "^4.7.0" + ajv-keywords "^1.0.0" + chalk "^1.1.1" + lodash "^4.0.0" + slice-ansi "0.0.4" + string-width "^2.0.0" tar-pack@^3.4.0: version "3.4.0" @@ -4061,10 +4367,6 @@ trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" -tryit@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" - tty-browserify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" @@ -4114,6 +4416,10 @@ umd@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/umd/-/umd-3.0.1.tgz#8ae556e11011f63c2596708a8837259f01b3d60e" +uniq@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff" + universalify@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7" @@ -4137,6 +4443,12 @@ user-home@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" +user-home@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f" + dependencies: + os-homedir "^1.0.0" + util-arity@^1.0.2: version "1.1.0" resolved "https://registry.yarnpkg.com/util-arity/-/util-arity-1.1.0.tgz#59d01af1fdb3fede0ac4e632b0ab5f6ce97c9330" @@ -4243,7 +4555,7 @@ write@^0.2.1: dependencies: mkdirp "^0.5.1" -xtend@^4.0.0, xtend@~4.0.1: +xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" From 9a255d3527891661ba906f4448181e3f7983fc45 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Mon, 22 Jan 2018 21:20:05 -0800 Subject: [PATCH 02/12] update --- example/index.js | 16 +++---- features/step_definitions/cli_steps.js | 22 +++++----- features/step_definitions/file_steps.js | 10 ++--- features/step_definitions/fixture_steps.js | 2 +- .../step_definitions/json_output_steps.js | 42 +++++++++---------- features/step_definitions/usage_json_steps.js | 4 +- .../support/event_protocol_output_helpers.js | 2 +- features/support/helpers.js | 2 +- features/support/hooks.js | 10 ++--- features/support/json_output_helpers.js | 12 +++--- features/support/world.js | 2 +- package.json | 5 ++- test/listener_helpers.js | 4 +- test/test_helper.js | 2 +- yarn.lock | 25 +++++++++-- 15 files changed, 89 insertions(+), 71 deletions(-) diff --git a/example/index.js b/example/index.js index a8599ef15..2e6fa4471 100644 --- a/example/index.js +++ b/example/index.js @@ -4,7 +4,7 @@ import ansiHTML from 'ansi-html' let featureEditor, stepDefinitionsEditor, $output -function runFeature() { +function runFeature () { $output.empty() $('a[href="#output-tab"]').tab('show') @@ -22,7 +22,7 @@ function runFeature() { }) Cucumber.supportCodeLibraryBuilder.reset('') - new Function(stepDefinitionsEditor.getValue())() + new Function(stepDefinitionsEditor.getValue())() // eslint-disable-line no-new-func let supportCodeLibrary = Cucumber.supportCodeLibraryBuilder.finalize() let formatterOptions = { @@ -30,7 +30,7 @@ function runFeature() { cwd: '/', eventBroadcaster, eventDataCollector, - log(data) { + log (data) { appendToOutput(ansiHTML(data)) }, supportCodeLibrary @@ -46,18 +46,18 @@ function runFeature() { return runtime.start() } -function appendToOutput(data) { +function appendToOutput (data) { $output.append(data) $output.scrollTop($output.prop('scrollHeight')) } -function displayError(error) { +function displayError (error) { let errorContainer = $('
') errorContainer.addClass('error').text(error.stack || error) appendToOutput(errorContainer) } -$(function() { +$(function () { featureEditor = ace.edit('feature') featureEditor.getSession().setMode('ace/mode/gherkin') @@ -68,9 +68,9 @@ $(function() { window.onerror = displayError - $('#run-feature').click(function() { + $('#run-feature').click(function () { runFeature() - .then(function(success) { + .then(function (success) { let exitStatus = success ? '0' : '1' let exitStatusContainer = $('
') exitStatusContainer diff --git a/features/step_definitions/cli_steps.js b/features/step_definitions/cli_steps.js index 020f26529..0981bbe25 100644 --- a/features/step_definitions/cli_steps.js +++ b/features/step_definitions/cli_steps.js @@ -6,7 +6,7 @@ import { normalizeText } from '../support/helpers' import stringArgv from 'string-argv' import Mustache from 'mustache' -When(/^I run cucumber.js(?: with `(|.+)`)?$/, { timeout: 10000 }, function( +When(/^I run cucumber.js(?: with `(|.+)`)?$/, { timeout: 10000 }, function ( args ) { args = Mustache.render(args || '', this) @@ -17,7 +17,7 @@ When(/^I run cucumber.js(?: with `(|.+)`)?$/, { timeout: 10000 }, function( When( /^I run cucumber.js \(installed (locally|globally)\)$/, { timeout: 10000 }, - function(location) { + function (location) { if (location === 'locally') { return this.run(this.localExecutablePath, []) } else { @@ -26,33 +26,33 @@ When( } ) -Then(/^it passes$/, function() {}) +Then(/^it passes$/, function () {}) -Then(/^it fails$/, function() { +Then(/^it fails$/, function () { const actualCode = this.lastRun.error ? this.lastRun.error.code : 0 expect(actualCode).not.to.eql(0) this.verifiedLastRunError = true }) -Then(/^it outputs the text:$/, function(text) { +Then(/^it outputs the text:$/, function (text) { const actualOutput = normalizeText(this.lastRun.output) const expectedOutput = normalizeText(text) expect(actualOutput).to.eql(expectedOutput) }) -Then(/^the output contains the text:$/, function(text) { +Then(/^the output contains the text:$/, function (text) { const actualOutput = normalizeText(this.lastRun.output) const expectedOutput = normalizeText(text) expect(actualOutput).to.include(expectedOutput) }) -Then('the output does not contain the text:', function(text) { +Then('the output does not contain the text:', function (text) { const actualOutput = normalizeText(this.lastRun.output) const expectedOutput = normalizeText(text) expect(actualOutput).not.to.include(expectedOutput) }) -Then(/^the error output contains the text snippets:$/, function(table) { +Then(/^the error output contains the text snippets:$/, function (table) { const actualOutput = normalizeText(this.lastRun.errorOutput) table.rows().forEach(row => { const expectedOutput = normalizeText(row[0]) @@ -60,20 +60,20 @@ Then(/^the error output contains the text snippets:$/, function(table) { }) }) -Then(/^the error output contains the text:$/, function(text) { +Then(/^the error output contains the text:$/, function (text) { const actualOutput = normalizeText(this.lastRun.errorOutput) const expectedOutput = normalizeText(text) expect(actualOutput).to.include(expectedOutput) }) -Then(/^I see the version of Cucumber$/, function() { +Then(/^I see the version of Cucumber$/, function () { const version = require('../../package.json').version const actualOutput = this.lastRun.output const expectedOutput = version + '\n' expect(actualOutput).to.eql(expectedOutput) }) -Then(/^I see the help text for Cucumber$/, function() { +Then(/^I see the help text for Cucumber$/, function () { const actualOutput = this.lastRun.output const expectedOutput = 'Usage: cucumber.js' expect(actualOutput).to.include(expectedOutput) diff --git a/features/step_definitions/file_steps.js b/features/step_definitions/file_steps.js index 363d1ff3d..9a9e4e85f 100644 --- a/features/step_definitions/file_steps.js +++ b/features/step_definitions/file_steps.js @@ -9,7 +9,7 @@ import fsExtra from 'fs-extra' import path from 'path' import Mustache from 'mustache' -Given(/^a file named "(.*)" with:$/, function(filePath, fileContent) { +Given(/^a file named "(.*)" with:$/, function (filePath, fileContent) { const absoluteFilePath = path.join(this.tmpDir, filePath) if (filePath === '@rerun.txt') { fileContent = fileContent.replace(/\//g, path.sep) @@ -17,22 +17,22 @@ Given(/^a file named "(.*)" with:$/, function(filePath, fileContent) { return promisify(fsExtra.outputFile)(absoluteFilePath, fileContent) }) -Given(/^an empty file named "(.*)"$/, function(filePath) { +Given(/^an empty file named "(.*)"$/, function (filePath) { const absoluteFilePath = path.join(this.tmpDir, filePath) return promisify(fsExtra.outputFile)(absoluteFilePath, '') }) -Given(/^a directory named "(.*)"$/, function(filePath) { +Given(/^a directory named "(.*)"$/, function (filePath) { const absoluteFilePath = path.join(this.tmpDir, filePath) return promisify(fsExtra.mkdirp)(absoluteFilePath) }) -Given(/^"([^"]*)" is an absolute path$/, function(filePath) { +Given(/^"([^"]*)" is an absolute path$/, function (filePath) { filePath = Mustache.render(filePath, this) expect(path.isAbsolute(filePath)).to.eql(true) }) -Then(/^the file "([^"]*)" has the text:$/, async function(filePath, text) { +Then(/^the file "([^"]*)" has the text:$/, async function (filePath, text) { filePath = Mustache.render(filePath, this) const absoluteFilePath = path.resolve(this.tmpDir, filePath) const content = await fs.readFile(absoluteFilePath, 'utf8') diff --git a/features/step_definitions/fixture_steps.js b/features/step_definitions/fixture_steps.js index 57d5ca0ed..62da9ee70 100644 --- a/features/step_definitions/fixture_steps.js +++ b/features/step_definitions/fixture_steps.js @@ -6,7 +6,7 @@ import { normalizeEventProtocolOutput } from '../support/event_protocol_output_h import fs from 'mz/fs' import path from 'path' -Then('the output matches the fixture {string}', async function(filePath) { +Then('the output matches the fixture {string}', async function (filePath) { const fixturePath = path.join(__dirname, '..', 'fixtures', filePath) const expected = await fs.readFile(fixturePath, 'utf8') const normalizedActual = normalizeEventProtocolOutput(this.lastRun.output) diff --git a/features/step_definitions/json_output_steps.js b/features/step_definitions/json_output_steps.js index 6816170b9..64e35bcc5 100644 --- a/features/step_definitions/json_output_steps.js +++ b/features/step_definitions/json_output_steps.js @@ -10,39 +10,39 @@ import { findStep } from '../support/json_output_helpers' -Then(/^it runs (\d+) scenarios$/, function(count) { +Then(/^it runs (\d+) scenarios$/, function (count) { expect(this.lastRun.jsonOutput[0].elements.length).to.eql(count) }) -Then(/^it runs the scenario "([^"]*)"$/, function(name) { +Then(/^it runs the scenario "([^"]*)"$/, function (name) { const actualNames = getScenarioNames(this.lastRun.jsonOutput) expect(actualNames).to.eql([name]) }) -Then(/^it runs the scenarios "([^"]*)" and "([^"]*)"$/, function(name1, name2) { +Then(/^it runs the scenarios "([^"]*)" and "([^"]*)"$/, function (name1, name2) { const actualNames = getScenarioNames(this.lastRun.jsonOutput) expect(actualNames).to.eql([name1, name2]) }) -Then(/^it runs the scenarios:$/, function(table) { +Then(/^it runs the scenarios:$/, function (table) { const expectedNames = table.rows().map(row => row[0]) const actualNames = getScenarioNames(this.lastRun.jsonOutput) expect(expectedNames).to.eql(actualNames) }) -Then(/^the scenario "([^"]*)" has the steps$/, function(name, table) { +Then(/^the scenario "([^"]*)" has the steps$/, function (name, table) { const scenario = findScenario({ features: this.lastRun.jsonOutput, scenarioPredicate: ['name', name] }) const expectedNames = table.rows().map(row => row[0]) - const actualNames = scenario.steps.map(function(step) { + const actualNames = scenario.steps.map(function (step) { return _.compact([step.keyword, step.name]).join('') }) expect(actualNames).to.eql(expectedNames) }) -Then(/^the step "([^"]*)" failed with:$/, function(name, errorMessage) { +Then(/^the step "([^"]*)" failed with:$/, function (name, errorMessage) { const step = findStep({ features: this.lastRun.jsonOutput, stepPredicate: ['name', name] @@ -51,7 +51,7 @@ Then(/^the step "([^"]*)" failed with:$/, function(name, errorMessage) { expect(step.result.error_message).to.include(errorMessage) }) -Then(/^all steps have status "([^"]*)"$/, function(status) { +Then(/^all steps have status "([^"]*)"$/, function (status) { const steps = getSteps(this.lastRun.jsonOutput) const stepStatues = _.chain(steps) .map(step => step.result.status) @@ -61,7 +61,7 @@ Then(/^all steps have status "([^"]*)"$/, function(status) { expect(stepStatues[0]).to.eql(status) }) -Then(/^the step "([^"]*)" has status "([^"]*)"$/, function(name, status) { +Then(/^the step "([^"]*)" has status "([^"]*)"$/, function (name, status) { const step = findStep({ features: this.lastRun.jsonOutput, stepPredicate: ['name', name] @@ -69,7 +69,7 @@ Then(/^the step "([^"]*)" has status "([^"]*)"$/, function(name, status) { expect(step.result.status).to.eql(status) }) -Then(/^the "([^"]*)" hook has status "([^"]*)"$/, function(keyword, status) { +Then(/^the "([^"]*)" hook has status "([^"]*)"$/, function (keyword, status) { const step = findStep({ features: this.lastRun.jsonOutput, stepPredicate: ['keyword', keyword] @@ -77,7 +77,7 @@ Then(/^the "([^"]*)" hook has status "([^"]*)"$/, function(keyword, status) { expect(step.result.status).to.eql(status) }) -Then('the step {string} has the attachment', function(name, table) { +Then('the step {string} has the attachment', function (name, table) { const step = findStep({ features: this.lastRun.jsonOutput, stepPredicate: ['name', name] @@ -90,7 +90,7 @@ Then('the step {string} has the attachment', function(name, table) { expect(step.embeddings[0]).to.eql(expectedAttachment) }) -Then('the {string} hook has the attachment', function(keyword, table) { +Then('the {string} hook has the attachment', function (keyword, table) { const hook = findStep({ features: this.lastRun.jsonOutput, stepPredicate: ['keyword', keyword] @@ -103,13 +103,13 @@ Then('the {string} hook has the attachment', function(keyword, table) { expect(hook.embeddings[0]).to.eql(expectedAttachment) }) -Then(/^the (first|second) scenario has the steps$/, function(cardinal, table) { +Then(/^the (first|second) scenario has the steps$/, function (cardinal, table) { const scenarioIndex = cardinal === 'first' ? 0 : 1 const scenario = findScenario({ features: this.lastRun.jsonOutput, scenarioPredicate: (element, index) => index === scenarioIndex }) - const stepNames = scenario.steps.map(function(step) { + const stepNames = scenario.steps.map(function (step) { return [step.name] }) expect(stepNames).to.eql(table.rows()) @@ -117,11 +117,11 @@ Then(/^the (first|second) scenario has the steps$/, function(cardinal, table) { Then( /^the (first|second) scenario has the step "([^"]*)" with the doc string$/, - function(cardinal, name, docString) { + function (cardinal, name, docString) { const scenarioIndex = cardinal === 'first' ? 0 : 1 const step = findStep({ features: this.lastRun.jsonOutput, - scenarioPredicate(element, index) { + scenarioPredicate (element, index) { return index === scenarioIndex }, stepPredicate: ['name', name] @@ -132,30 +132,30 @@ Then( Then( /^the (first|second) scenario has the step "([^"]*)" with the table$/, - function(cardinal, name, table) { + function (cardinal, name, table) { const scenarioIndex = cardinal === 'first' ? 0 : 1 const step = findStep({ features: this.lastRun.jsonOutput, - scenarioPredicate(element, index) { + scenarioPredicate (element, index) { return index === scenarioIndex }, stepPredicate: ['name', name] }) - const expected = table.raw().map(function(row) { + const expected = table.raw().map(function (row) { return { cells: row } }) expect(step.arguments[0].rows).to.eql(expected) } ) -Then(/^the (first|second) scenario has the name "([^"]*)"$/, function( +Then(/^the (first|second) scenario has the name "([^"]*)"$/, function ( cardinal, name ) { const scenarioIndex = cardinal === 'first' ? 0 : 1 const scenario = findScenario({ features: this.lastRun.jsonOutput, - scenarioPredicate(element, index) { + scenarioPredicate (element, index) { return index === scenarioIndex } }) diff --git a/features/step_definitions/usage_json_steps.js b/features/step_definitions/usage_json_steps.js index 729c1c20f..deaa5e3a1 100644 --- a/features/step_definitions/usage_json_steps.js +++ b/features/step_definitions/usage_json_steps.js @@ -5,13 +5,13 @@ import { Then } from '../../' import { expect } from 'chai' import path from 'path' -Then('it outputs the usage data:', function(table) { +Then('it outputs the usage data:', function (table) { const usageData = JSON.parse(this.lastRun.output) table.hashes().forEach(row => { const rowUsage = _.find(usageData, datum => { return datum.pattern === row['PATTERN'] }) - expect(rowUsage).to.exist + expect(rowUsage).to.be.an('object') expect(rowUsage.line).to.eql(parseInt(row['LINE'])) expect(rowUsage.matches).to.have.lengthOf(row['NUMBER OF MATCHES']) expect(rowUsage.uri).to.eql(path.normalize(row['URI'])) diff --git a/features/support/event_protocol_output_helpers.js b/features/support/event_protocol_output_helpers.js index bb38ffc22..9216fcc28 100644 --- a/features/support/event_protocol_output_helpers.js +++ b/features/support/event_protocol_output_helpers.js @@ -1,6 +1,6 @@ import path from 'path' -export function normalizeEventProtocolOutput(str) { +export function normalizeEventProtocolOutput (str) { return str .replace(/"duration":\d*/g, '"duration":0') .replace(/"uri":"([^"]*)"/g, (match, uri) => { diff --git a/features/support/helpers.js b/features/support/helpers.js index 1b592daa0..e336d28f9 100644 --- a/features/support/helpers.js +++ b/features/support/helpers.js @@ -1,7 +1,7 @@ import path from 'path' import figures from 'figures' -export function normalizeText(text) { +export function normalizeText (text) { return figures(text) .replace(/\033\[[0-9;]*m/g, '') .replace(/\r\n|\r/g, '\n') diff --git a/features/support/hooks.js b/features/support/hooks.js index 108a0c8cd..2e35c1418 100644 --- a/features/support/hooks.js +++ b/features/support/hooks.js @@ -10,15 +10,15 @@ const projectPath = path.join(__dirname, '..', '..') const projectNodeModulesPath = path.join(projectPath, 'node_modules') const moduleNames = fs.readdirSync(projectNodeModulesPath) -Before('@debug', function() { +Before('@debug', function () { this.debug = true }) -Before('@spawn', function() { +Before('@spawn', function () { this.spawn = true }) -Before(function() { +Before(function () { const tmpObject = tmp.dirSync({ unsafeCleanup: true }) this.tmpDir = fs.realpathSync(tmpObject.name) @@ -47,7 +47,7 @@ Before(function() { this.localExecutablePath = path.join(tmpDirCucumberPath, 'bin', 'cucumber.js') }) -Before('@global-install', function() { +Before('@global-install', function () { const tmpObject = tmp.dirSync({ unsafeCleanup: true }) const globalInstallNodeModulesPath = path.join(tmpObject.name, 'node_modules') @@ -86,7 +86,7 @@ Before('@global-install', function() { ) }) -After(function() { +After(function () { if (this.lastRun.error && !this.verifiedLastRunError) { throw new Error( 'Last run errored unexpectedly. Output:\n\n' + diff --git a/features/support/json_output_helpers.js b/features/support/json_output_helpers.js index 2c5159c52..c1d0d2a96 100644 --- a/features/support/json_output_helpers.js +++ b/features/support/json_output_helpers.js @@ -1,7 +1,7 @@ import _ from 'lodash' import util from 'util' -export function getScenarioNames(features) { +export function getScenarioNames (features) { return _.chain(features) .map('elements') .flatten() @@ -9,7 +9,7 @@ export function getScenarioNames(features) { .value() } -export function getSteps(features) { +export function getSteps (features) { return _.chain(features) .map('elements') .flatten() @@ -18,7 +18,7 @@ export function getSteps(features) { .value() } -export function findScenario({ features, scenarioPredicate }) { +export function findScenario ({ features, scenarioPredicate }) { const scenario = _.chain(features) .map('elements') .flatten() @@ -31,7 +31,7 @@ export function findScenario({ features, scenarioPredicate }) { } } -export function findStep({ features, stepPredicate, scenarioPredicate }) { +export function findStep ({ features, stepPredicate, scenarioPredicate }) { let steps if (scenarioPredicate) { steps = findScenario({ features, scenarioPredicate }).steps @@ -55,8 +55,8 @@ export function findStep({ features, stepPredicate, scenarioPredicate }) { } } -export function neutraliseVariableValues(report) { - report.forEach(function(item) { +export function neutraliseVariableValues (report) { + report.forEach(function (item) { ;(item.elements || []).forEach(element => { ;(element.steps || []).forEach(step => { if ('result' in step) { diff --git a/features/support/world.js b/features/support/world.js index 86798a28a..bce1f85e2 100644 --- a/features/support/world.js +++ b/features/support/world.js @@ -10,7 +10,7 @@ import VError from 'verror' import _ from 'lodash' class World { - async run(executablePath, inputArgs) { + async run (executablePath, inputArgs) { const args = ['node', executablePath] .concat(inputArgs, ['--backtrace', '--format', 'json:out.json']) .map(arg => { diff --git a/package.json b/package.json index a35f81d55..c244f18e0 100644 --- a/package.json +++ b/package.json @@ -188,6 +188,7 @@ "serve-static": "^1.10.0", "sinon": "^4.0.1", "sinon-chai": "^2.11.0", + "snazzy": "^7.0.0", "standard": "^10.0.3", "stream-to-string": "^1.1.0", "tmp": "^0.0.33" @@ -199,8 +200,8 @@ "build-release": "BABEL_ENV=browser browserify src/index.js -o dist/cucumber.js -t babelify --standalone Cucumber", "feature-test": "node ./bin/cucumber.js", "lint-dependencies": "dependency-lint", - "lint-code": "eslint \"{example,features,scripts,src,test}/**/*.js\"", - "lint-autofix": "eslint --fix \"{example,features,scripts,src,test}/**/*.js\"", + "lint-code": "standard --verbose \"{example,features,scripts,src,test}/**/*.js\" | snazzy", + "lint-autofix": "standard --fix --verbose \"{example,features,scripts,src,test}/**/*.js\" | snazzy", "lint": "yarn run lint-code && yarn run lint-dependencies", "prefeature-test": "yarn run build-local", "prepublish": "yarn run build-local", diff --git a/test/listener_helpers.js b/test/listener_helpers.js index d05ea11f1..2278d36ae 100644 --- a/test/listener_helpers.js +++ b/test/listener_helpers.js @@ -1,7 +1,7 @@ -export function expectToHearEvents(listener, expectedEvents) { +export function expectToHearEvents (listener, expectedEvents) { let previousStub = null let callNumberMapping = {} - expectedEvents.forEach(function([expectedName, expectedData]) { + expectedEvents.forEach(function ([expectedName, expectedData]) { const fnName = 'handle' + expectedName if (!callNumberMapping[fnName]) { callNumberMapping[fnName] = 0 diff --git a/test/test_helper.js b/test/test_helper.js index 665bd7dcb..baf1fa391 100644 --- a/test/test_helper.js +++ b/test/test_helper.js @@ -6,7 +6,7 @@ import sinonChai from 'sinon-chai' chai.use(sinonChai) -function createMock(input) { +function createMock (input) { if (_.isArray(input)) { input = _.zipObject(input) } diff --git a/yarn.lock b/yarn.lock index 51849b330..8b86d8133 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1095,7 +1095,7 @@ chai@^4.0.1: pathval "^1.0.0" type-detect "^4.0.0" -chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: +chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: @@ -1232,7 +1232,7 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.5.2: +concat-stream@^1.5.0, concat-stream@^1.5.2: version "1.6.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" dependencies: @@ -3013,7 +3013,7 @@ minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" -minimist@^1.1.0, minimist@^1.2.0: +minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -3990,6 +3990,17 @@ slide@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" +snazzy@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/snazzy/-/snazzy-7.0.0.tgz#95edaccc4a8d6f80f4ac5cc7b520e8f8f9ac2325" + dependencies: + chalk "^1.1.0" + inherits "^2.0.1" + minimist "^1.1.1" + readable-stream "^2.0.6" + standard-json "^1.0.0" + text-table "^0.2.0" + sntp@1.x.x: version "1.0.9" resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" @@ -4107,6 +4118,12 @@ standard-engine@~7.0.0: minimist "^1.1.0" pkg-conf "^2.0.0" +standard-json@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/standard-json/-/standard-json-1.0.2.tgz#82dea4a14c78cd9e35d38cde4b88ac6b62596a23" + dependencies: + concat-stream "^1.5.0" + standard@^10.0.3: version "10.0.3" resolved "https://registry.yarnpkg.com/standard/-/standard-10.0.3.tgz#7869bcbf422bdeeaab689a1ffb1fea9677dd50ea" @@ -4299,7 +4316,7 @@ text-encoding@0.6.4, text-encoding@^0.6.4: version "0.6.4" resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" -text-table@~0.2.0: +text-table@^0.2.0, text-table@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" From 5eada1b9d530160808aa5dcd8d21a7700baf4971 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Mon, 22 Jan 2018 21:36:32 -0800 Subject: [PATCH 03/12] update --- src/runtime/test_case_runner_spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/test_case_runner_spec.js b/src/runtime/test_case_runner_spec.js index d767ef52a..fa589b9c7 100644 --- a/src/runtime/test_case_runner_spec.js +++ b/src/runtime/test_case_runner_spec.js @@ -483,7 +483,7 @@ describe('TestCaseRunner', function () { }) it('emits test-step-started', function () { - expect(this.onTestStepStarted).to.have.calledCount(2) + expect(this.onTestStepStarted).to.have.callCount(2) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } @@ -495,7 +495,7 @@ describe('TestCaseRunner', function () { }) it('emits test-step-finished', function () { - expect(this.onTestStepFinished).to.have.calledCount(2) + expect(this.onTestStepFinished).to.have.callCount(2) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, @@ -569,7 +569,7 @@ describe('TestCaseRunner', function () { }) it('emits test-step-started', function () { - expect(this.onTestStepStarted).to.have.calledCount(2) + expect(this.onTestStepStarted).to.have.callCount(2) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } @@ -581,7 +581,7 @@ describe('TestCaseRunner', function () { }) it('emits test-step-finished', function () { - expect(this.onTestStepFinished).to.have.calledCount(2) + expect(this.onTestStepFinished).to.have.callCount(2) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, From 8f96be35b3a69fd05a4496936e735e03cceaa7e5 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Mon, 22 Jan 2018 21:38:54 -0800 Subject: [PATCH 04/12] update --- src/runtime/stack_trace_filter.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/runtime/stack_trace_filter.js b/src/runtime/stack_trace_filter.js index 9453a2758..78fdbc02d 100644 --- a/src/runtime/stack_trace_filter.js +++ b/src/runtime/stack_trace_filter.js @@ -8,10 +8,7 @@ export default class StackTraceFilter { } filter () { - this.currentFilter = stackChain.filter.attach((error, frames) => { - if (error) { - throw error - } + this.currentFilter = stackChain.filter.attach((_, frames) => { if (this.isErrorInCucumber(frames)) { return frames } From ce31852176f3aa4f369e9660ea36bf9b26c43d8c Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Tue, 23 Jan 2018 10:27:14 -0800 Subject: [PATCH 05/12] update --- .eslintrc.yml | 40 + example/index.js | 30 +- features/step_definitions/cli_steps.js | 27 +- features/step_definitions/file_steps.js | 10 +- features/step_definitions/fixture_steps.js | 2 +- .../step_definitions/json_output_steps.js | 50 +- features/step_definitions/usage_json_steps.js | 10 +- .../support/event_protocol_output_helpers.js | 9 +- features/support/helpers.js | 2 +- features/support/hooks.js | 17 +- features/support/json_output_helpers.js | 26 +- features/support/world.js | 2 +- package.json | 27 +- scripts/server.js | 14 +- src/cli/argv_parser.js | 18 +- src/cli/configuration_builder.js | 25 +- src/cli/configuration_builder_spec.js | 36 +- src/cli/helpers.js | 8 +- src/cli/helpers_spec.js | 40 +- src/cli/i18n.js | 16 +- src/cli/index.js | 14 +- src/cli/install_validator.js | 2 +- src/cli/option_splitter.js | 4 +- src/cli/option_splitter_spec.js | 4 +- src/cli/path_expander.js | 21 +- src/cli/path_expander_spec.js | 34 +- src/cli/profile_loader.js | 14 +- src/cli/profile_loader_spec.js | 48 +- src/cli/run.js | 4 +- src/formatter/builder.js | 15 +- src/formatter/event_protocol_formatter.js | 11 +- src/formatter/get_color_fns.js | 2 +- src/formatter/helpers/error_helpers.js | 2 +- src/formatter/helpers/event_data_collector.js | 20 +- .../helpers/gherkin_document_parser.js | 4 +- src/formatter/helpers/issue_helpers.js | 43 +- src/formatter/helpers/issue_helpers_spec.js | 42 +- src/formatter/helpers/keyword_type.js | 8 +- src/formatter/helpers/keyword_type_spec.js | 56 +- src/formatter/helpers/location_helpers.js | 2 +- src/formatter/helpers/pickle_parser.js | 6 +- src/formatter/helpers/step_result_helpers.js | 17 +- src/formatter/helpers/summary_helpers.js | 22 +- src/formatter/helpers/summary_helpers_spec.js | 54 +- src/formatter/helpers/usage_helpers/index.js | 10 +- .../helpers/usage_helpers/index_spec.js | 20 +- src/formatter/index.js | 2 +- src/formatter/json_formatter.js | 43 +- src/formatter/json_formatter_spec.js | 58 +- src/formatter/progress_bar_formatter.js | 12 +- src/formatter/progress_bar_formatter_spec.js | 96 +-- src/formatter/progress_formatter.js | 4 +- src/formatter/progress_formatter_spec.js | 50 +- src/formatter/rerun_formatter.js | 8 +- src/formatter/rerun_formatter_spec.js | 42 +- src/formatter/snippets_formatter.js | 8 +- .../step_definition_snippet_builder/index.js | 8 +- .../index_spec.js | 76 +- .../javascript_snippet_syntax.js | 24 +- .../javascript_snippet_syntax_spec.js | 40 +- src/formatter/summary_formatter.js | 12 +- src/formatter/summary_formatter_spec.js | 52 +- src/formatter/usage_formatter.js | 12 +- src/formatter/usage_formatter_spec.js | 44 +- src/formatter/usage_json_formatter.js | 4 +- src/formatter/usage_json_formatter_spec.js | 8 +- src/models/data_table.js | 10 +- src/models/data_table_spec.js | 26 +- src/models/step_definition.js | 29 +- src/models/test_case_hook_definition.js | 10 +- src/models/test_case_hook_definition_spec.js | 36 +- src/models/test_run_hook_definition.js | 6 +- src/pickle_filter.js | 21 +- src/pickle_filter_spec.js | 198 ++--- src/runtime/attachment_manager/index.js | 10 +- src/runtime/attachment_manager/index_spec.js | 69 +- src/runtime/helpers.js | 16 +- src/runtime/helpers_spec.js | 8 +- src/runtime/index.js | 10 +- src/runtime/stack_trace_filter.js | 17 +- src/runtime/step_runner.js | 2 +- src/runtime/test_case_runner.js | 69 +- src/runtime/test_case_runner_spec.js | 122 +-- src/status.js | 2 +- src/status_spec.js | 10 +- src/step_arguments.js | 7 +- .../define_helpers.js | 10 +- .../finalize_helpers.js | 15 +- src/support_code_library_builder/index.js | 10 +- .../index_spec.js | 80 +- .../parameter_type_registry_builder.js | 2 +- .../validate_arguments.js | 12 +- src/time.js | 6 +- src/uncaught_exception_manager.js | 4 +- src/user_code_runner.js | 17 +- src/user_code_runner_spec.js | 138 ++-- test/listener_helpers.js | 8 +- test/test_helper.js | 6 +- yarn.lock | 707 ++++++------------ 99 files changed, 1466 insertions(+), 1718 deletions(-) create mode 100644 .eslintrc.yml diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 000000000..df036cb1b --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,40 @@ +env: + browser: true + es6: true + node: true +extends: + - 'eslint:recommended' + - prettier +globals: + afterEach: false + beforeEach: false + createMock: false + describe: false + expect: false + it: false + sinon: false +parser: babel-eslint +parserOptions: + sourceType: module +plugins: + - babel + - prettier +rules: + babel/new-cap: error + complexity: error + eqeqeq: [error, always] + no-await-in-loop: error + no-negated-condition: error + no-nested-ternary: error + no-plusplus: error + no-return-await: error + no-shadow: error + no-unneeded-ternary: [error, {defaultAssignment: false}] + no-unused-expressions: error + no-var: error + object-shorthand: [error, always] + prettier/prettier: + - error + - trailingComma: none + singleQuote: true + semi: false diff --git a/example/index.js b/example/index.js index 2e6fa4471..57effff16 100644 --- a/example/index.js +++ b/example/index.js @@ -4,7 +4,7 @@ import ansiHTML from 'ansi-html' let featureEditor, stepDefinitionsEditor, $output -function runFeature () { +function runFeature() { $output.empty() $('a[href="#output-tab"]').tab('show') @@ -13,7 +13,7 @@ function runFeature () { eventBroadcaster ) - let featureSource = featureEditor.getValue() + const featureSource = featureEditor.getValue() const testCases = Cucumber.getTestCases({ eventBroadcaster, pickleFilter: new Cucumber.PickleFilter({}), @@ -23,21 +23,21 @@ function runFeature () { Cucumber.supportCodeLibraryBuilder.reset('') new Function(stepDefinitionsEditor.getValue())() // eslint-disable-line no-new-func - let supportCodeLibrary = Cucumber.supportCodeLibraryBuilder.finalize() + const supportCodeLibrary = Cucumber.supportCodeLibraryBuilder.finalize() - let formatterOptions = { + const formatterOptions = { colorsEnabled: true, cwd: '/', eventBroadcaster, eventDataCollector, - log (data) { + log(data) { appendToOutput(ansiHTML(data)) }, supportCodeLibrary } Cucumber.FormatterBuilder.build('progress', formatterOptions) - let runtime = new Cucumber.Runtime({ + const runtime = new Cucumber.Runtime({ eventBroadcaster, options: {}, testCases, @@ -46,18 +46,18 @@ function runFeature () { return runtime.start() } -function appendToOutput (data) { +function appendToOutput(data) { $output.append(data) $output.scrollTop($output.prop('scrollHeight')) } -function displayError (error) { - let errorContainer = $('
') +function displayError(error) { + const errorContainer = $('
') errorContainer.addClass('error').text(error.stack || error) appendToOutput(errorContainer) } -$(function () { +$(() => { featureEditor = ace.edit('feature') featureEditor.getSession().setMode('ace/mode/gherkin') @@ -68,14 +68,14 @@ $(function () { window.onerror = displayError - $('#run-feature').click(function () { + $('#run-feature').click(() => { runFeature() - .then(function (success) { - let exitStatus = success ? '0' : '1' - let exitStatusContainer = $('
') + .then(success => { + const exitStatus = success ? '0' : '1' + const exitStatusContainer = $('
') exitStatusContainer .addClass('exit-status') - .text('Exit Status: ' + exitStatus) + .text(`Exit Status: ${exitStatus}`) appendToOutput(exitStatusContainer) }) .catch(displayError) diff --git a/features/step_definitions/cli_steps.js b/features/step_definitions/cli_steps.js index 0981bbe25..c967243f8 100644 --- a/features/step_definitions/cli_steps.js +++ b/features/step_definitions/cli_steps.js @@ -6,7 +6,7 @@ import { normalizeText } from '../support/helpers' import stringArgv from 'string-argv' import Mustache from 'mustache' -When(/^I run cucumber.js(?: with `(|.+)`)?$/, { timeout: 10000 }, function ( +When(/^I run cucumber.js(?: with `(|.+)`)?$/, { timeout: 10000 }, function( args ) { args = Mustache.render(args || '', this) @@ -17,42 +17,41 @@ When(/^I run cucumber.js(?: with `(|.+)`)?$/, { timeout: 10000 }, function ( When( /^I run cucumber.js \(installed (locally|globally)\)$/, { timeout: 10000 }, - function (location) { + function(location) { if (location === 'locally') { return this.run(this.localExecutablePath, []) - } else { - return this.run(this.globalExecutablePath, []) } + return this.run(this.globalExecutablePath, []) } ) -Then(/^it passes$/, function () {}) +Then(/^it passes$/, () => {}) -Then(/^it fails$/, function () { +Then(/^it fails$/, function() { const actualCode = this.lastRun.error ? this.lastRun.error.code : 0 expect(actualCode).not.to.eql(0) this.verifiedLastRunError = true }) -Then(/^it outputs the text:$/, function (text) { +Then(/^it outputs the text:$/, function(text) { const actualOutput = normalizeText(this.lastRun.output) const expectedOutput = normalizeText(text) expect(actualOutput).to.eql(expectedOutput) }) -Then(/^the output contains the text:$/, function (text) { +Then(/^the output contains the text:$/, function(text) { const actualOutput = normalizeText(this.lastRun.output) const expectedOutput = normalizeText(text) expect(actualOutput).to.include(expectedOutput) }) -Then('the output does not contain the text:', function (text) { +Then('the output does not contain the text:', function(text) { const actualOutput = normalizeText(this.lastRun.output) const expectedOutput = normalizeText(text) expect(actualOutput).not.to.include(expectedOutput) }) -Then(/^the error output contains the text snippets:$/, function (table) { +Then(/^the error output contains the text snippets:$/, function(table) { const actualOutput = normalizeText(this.lastRun.errorOutput) table.rows().forEach(row => { const expectedOutput = normalizeText(row[0]) @@ -60,20 +59,20 @@ Then(/^the error output contains the text snippets:$/, function (table) { }) }) -Then(/^the error output contains the text:$/, function (text) { +Then(/^the error output contains the text:$/, function(text) { const actualOutput = normalizeText(this.lastRun.errorOutput) const expectedOutput = normalizeText(text) expect(actualOutput).to.include(expectedOutput) }) -Then(/^I see the version of Cucumber$/, function () { +Then(/^I see the version of Cucumber$/, function() { const version = require('../../package.json').version const actualOutput = this.lastRun.output - const expectedOutput = version + '\n' + const expectedOutput = `${version}\n` expect(actualOutput).to.eql(expectedOutput) }) -Then(/^I see the help text for Cucumber$/, function () { +Then(/^I see the help text for Cucumber$/, function() { const actualOutput = this.lastRun.output const expectedOutput = 'Usage: cucumber.js' expect(actualOutput).to.include(expectedOutput) diff --git a/features/step_definitions/file_steps.js b/features/step_definitions/file_steps.js index 9a9e4e85f..363d1ff3d 100644 --- a/features/step_definitions/file_steps.js +++ b/features/step_definitions/file_steps.js @@ -9,7 +9,7 @@ import fsExtra from 'fs-extra' import path from 'path' import Mustache from 'mustache' -Given(/^a file named "(.*)" with:$/, function (filePath, fileContent) { +Given(/^a file named "(.*)" with:$/, function(filePath, fileContent) { const absoluteFilePath = path.join(this.tmpDir, filePath) if (filePath === '@rerun.txt') { fileContent = fileContent.replace(/\//g, path.sep) @@ -17,22 +17,22 @@ Given(/^a file named "(.*)" with:$/, function (filePath, fileContent) { return promisify(fsExtra.outputFile)(absoluteFilePath, fileContent) }) -Given(/^an empty file named "(.*)"$/, function (filePath) { +Given(/^an empty file named "(.*)"$/, function(filePath) { const absoluteFilePath = path.join(this.tmpDir, filePath) return promisify(fsExtra.outputFile)(absoluteFilePath, '') }) -Given(/^a directory named "(.*)"$/, function (filePath) { +Given(/^a directory named "(.*)"$/, function(filePath) { const absoluteFilePath = path.join(this.tmpDir, filePath) return promisify(fsExtra.mkdirp)(absoluteFilePath) }) -Given(/^"([^"]*)" is an absolute path$/, function (filePath) { +Given(/^"([^"]*)" is an absolute path$/, function(filePath) { filePath = Mustache.render(filePath, this) expect(path.isAbsolute(filePath)).to.eql(true) }) -Then(/^the file "([^"]*)" has the text:$/, async function (filePath, text) { +Then(/^the file "([^"]*)" has the text:$/, async function(filePath, text) { filePath = Mustache.render(filePath, this) const absoluteFilePath = path.resolve(this.tmpDir, filePath) const content = await fs.readFile(absoluteFilePath, 'utf8') diff --git a/features/step_definitions/fixture_steps.js b/features/step_definitions/fixture_steps.js index 62da9ee70..57d5ca0ed 100644 --- a/features/step_definitions/fixture_steps.js +++ b/features/step_definitions/fixture_steps.js @@ -6,7 +6,7 @@ import { normalizeEventProtocolOutput } from '../support/event_protocol_output_h import fs from 'mz/fs' import path from 'path' -Then('the output matches the fixture {string}', async function (filePath) { +Then('the output matches the fixture {string}', async function(filePath) { const fixturePath = path.join(__dirname, '..', 'fixtures', filePath) const expected = await fs.readFile(fixturePath, 'utf8') const normalizedActual = normalizeEventProtocolOutput(this.lastRun.output) diff --git a/features/step_definitions/json_output_steps.js b/features/step_definitions/json_output_steps.js index 64e35bcc5..2cfa56c35 100644 --- a/features/step_definitions/json_output_steps.js +++ b/features/step_definitions/json_output_steps.js @@ -10,39 +10,39 @@ import { findStep } from '../support/json_output_helpers' -Then(/^it runs (\d+) scenarios$/, function (count) { +Then(/^it runs (\d+) scenarios$/, function(count) { expect(this.lastRun.jsonOutput[0].elements.length).to.eql(count) }) -Then(/^it runs the scenario "([^"]*)"$/, function (name) { +Then(/^it runs the scenario "([^"]*)"$/, function(name) { const actualNames = getScenarioNames(this.lastRun.jsonOutput) expect(actualNames).to.eql([name]) }) -Then(/^it runs the scenarios "([^"]*)" and "([^"]*)"$/, function (name1, name2) { +Then(/^it runs the scenarios "([^"]*)" and "([^"]*)"$/, function(name1, name2) { const actualNames = getScenarioNames(this.lastRun.jsonOutput) expect(actualNames).to.eql([name1, name2]) }) -Then(/^it runs the scenarios:$/, function (table) { +Then(/^it runs the scenarios:$/, function(table) { const expectedNames = table.rows().map(row => row[0]) const actualNames = getScenarioNames(this.lastRun.jsonOutput) expect(expectedNames).to.eql(actualNames) }) -Then(/^the scenario "([^"]*)" has the steps$/, function (name, table) { +Then(/^the scenario "([^"]*)" has the steps$/, function(name, table) { const scenario = findScenario({ features: this.lastRun.jsonOutput, scenarioPredicate: ['name', name] }) const expectedNames = table.rows().map(row => row[0]) - const actualNames = scenario.steps.map(function (step) { - return _.compact([step.keyword, step.name]).join('') - }) + const actualNames = scenario.steps.map(step => + _.compact([step.keyword, step.name]).join('') + ) expect(actualNames).to.eql(expectedNames) }) -Then(/^the step "([^"]*)" failed with:$/, function (name, errorMessage) { +Then(/^the step "([^"]*)" failed with:$/, function(name, errorMessage) { const step = findStep({ features: this.lastRun.jsonOutput, stepPredicate: ['name', name] @@ -51,7 +51,7 @@ Then(/^the step "([^"]*)" failed with:$/, function (name, errorMessage) { expect(step.result.error_message).to.include(errorMessage) }) -Then(/^all steps have status "([^"]*)"$/, function (status) { +Then(/^all steps have status "([^"]*)"$/, function(status) { const steps = getSteps(this.lastRun.jsonOutput) const stepStatues = _.chain(steps) .map(step => step.result.status) @@ -61,7 +61,7 @@ Then(/^all steps have status "([^"]*)"$/, function (status) { expect(stepStatues[0]).to.eql(status) }) -Then(/^the step "([^"]*)" has status "([^"]*)"$/, function (name, status) { +Then(/^the step "([^"]*)" has status "([^"]*)"$/, function(name, status) { const step = findStep({ features: this.lastRun.jsonOutput, stepPredicate: ['name', name] @@ -69,7 +69,7 @@ Then(/^the step "([^"]*)" has status "([^"]*)"$/, function (name, status) { expect(step.result.status).to.eql(status) }) -Then(/^the "([^"]*)" hook has status "([^"]*)"$/, function (keyword, status) { +Then(/^the "([^"]*)" hook has status "([^"]*)"$/, function(keyword, status) { const step = findStep({ features: this.lastRun.jsonOutput, stepPredicate: ['keyword', keyword] @@ -77,7 +77,7 @@ Then(/^the "([^"]*)" hook has status "([^"]*)"$/, function (keyword, status) { expect(step.result.status).to.eql(status) }) -Then('the step {string} has the attachment', function (name, table) { +Then('the step {string} has the attachment', function(name, table) { const step = findStep({ features: this.lastRun.jsonOutput, stepPredicate: ['name', name] @@ -90,7 +90,7 @@ Then('the step {string} has the attachment', function (name, table) { expect(step.embeddings[0]).to.eql(expectedAttachment) }) -Then('the {string} hook has the attachment', function (keyword, table) { +Then('the {string} hook has the attachment', function(keyword, table) { const hook = findStep({ features: this.lastRun.jsonOutput, stepPredicate: ['keyword', keyword] @@ -103,25 +103,23 @@ Then('the {string} hook has the attachment', function (keyword, table) { expect(hook.embeddings[0]).to.eql(expectedAttachment) }) -Then(/^the (first|second) scenario has the steps$/, function (cardinal, table) { +Then(/^the (first|second) scenario has the steps$/, function(cardinal, table) { const scenarioIndex = cardinal === 'first' ? 0 : 1 const scenario = findScenario({ features: this.lastRun.jsonOutput, scenarioPredicate: (element, index) => index === scenarioIndex }) - const stepNames = scenario.steps.map(function (step) { - return [step.name] - }) + const stepNames = scenario.steps.map(step => [step.name]) expect(stepNames).to.eql(table.rows()) }) Then( /^the (first|second) scenario has the step "([^"]*)" with the doc string$/, - function (cardinal, name, docString) { + function(cardinal, name, docString) { const scenarioIndex = cardinal === 'first' ? 0 : 1 const step = findStep({ features: this.lastRun.jsonOutput, - scenarioPredicate (element, index) { + scenarioPredicate(element, index) { return index === scenarioIndex }, stepPredicate: ['name', name] @@ -132,30 +130,28 @@ Then( Then( /^the (first|second) scenario has the step "([^"]*)" with the table$/, - function (cardinal, name, table) { + function(cardinal, name, table) { const scenarioIndex = cardinal === 'first' ? 0 : 1 const step = findStep({ features: this.lastRun.jsonOutput, - scenarioPredicate (element, index) { + scenarioPredicate(element, index) { return index === scenarioIndex }, stepPredicate: ['name', name] }) - const expected = table.raw().map(function (row) { - return { cells: row } - }) + const expected = table.raw().map(row => ({ cells: row })) expect(step.arguments[0].rows).to.eql(expected) } ) -Then(/^the (first|second) scenario has the name "([^"]*)"$/, function ( +Then(/^the (first|second) scenario has the name "([^"]*)"$/, function( cardinal, name ) { const scenarioIndex = cardinal === 'first' ? 0 : 1 const scenario = findScenario({ features: this.lastRun.jsonOutput, - scenarioPredicate (element, index) { + scenarioPredicate(element, index) { return index === scenarioIndex } }) diff --git a/features/step_definitions/usage_json_steps.js b/features/step_definitions/usage_json_steps.js index deaa5e3a1..7a80fcf03 100644 --- a/features/step_definitions/usage_json_steps.js +++ b/features/step_definitions/usage_json_steps.js @@ -5,15 +5,13 @@ import { Then } from '../../' import { expect } from 'chai' import path from 'path' -Then('it outputs the usage data:', function (table) { +Then('it outputs the usage data:', function(table) { const usageData = JSON.parse(this.lastRun.output) table.hashes().forEach(row => { - const rowUsage = _.find(usageData, datum => { - return datum.pattern === row['PATTERN'] - }) + const rowUsage = _.find(usageData, datum => datum.pattern === row.PATTERN) expect(rowUsage).to.be.an('object') - expect(rowUsage.line).to.eql(parseInt(row['LINE'])) + expect(rowUsage.line).to.eql(parseInt(row.LINE)) expect(rowUsage.matches).to.have.lengthOf(row['NUMBER OF MATCHES']) - expect(rowUsage.uri).to.eql(path.normalize(row['URI'])) + expect(rowUsage.uri).to.eql(path.normalize(row.URI)) }) }) diff --git a/features/support/event_protocol_output_helpers.js b/features/support/event_protocol_output_helpers.js index 9216fcc28..7abc571a1 100644 --- a/features/support/event_protocol_output_helpers.js +++ b/features/support/event_protocol_output_helpers.js @@ -1,9 +1,10 @@ import path from 'path' -export function normalizeEventProtocolOutput (str) { +export function normalizeEventProtocolOutput(str) { return str .replace(/"duration":\d*/g, '"duration":0') - .replace(/"uri":"([^"]*)"/g, (match, uri) => { - return `"uri":"${path.normalize(uri)}"` - }) + .replace( + /"uri":"([^"]*)"/g, + (match, uri) => `"uri":"${path.normalize(uri)}"` + ) } diff --git a/features/support/helpers.js b/features/support/helpers.js index e336d28f9..1b592daa0 100644 --- a/features/support/helpers.js +++ b/features/support/helpers.js @@ -1,7 +1,7 @@ import path from 'path' import figures from 'figures' -export function normalizeText (text) { +export function normalizeText(text) { return figures(text) .replace(/\033\[[0-9;]*m/g, '') .replace(/\r\n|\r/g, '\n') diff --git a/features/support/hooks.js b/features/support/hooks.js index 2e35c1418..227efbe53 100644 --- a/features/support/hooks.js +++ b/features/support/hooks.js @@ -10,15 +10,15 @@ const projectPath = path.join(__dirname, '..', '..') const projectNodeModulesPath = path.join(projectPath, 'node_modules') const moduleNames = fs.readdirSync(projectNodeModulesPath) -Before('@debug', function () { +Before('@debug', function() { this.debug = true }) -Before('@spawn', function () { +Before('@spawn', function() { this.spawn = true }) -Before(function () { +Before(function() { const tmpObject = tmp.dirSync({ unsafeCleanup: true }) this.tmpDir = fs.realpathSync(tmpObject.name) @@ -47,7 +47,7 @@ Before(function () { this.localExecutablePath = path.join(tmpDirCucumberPath, 'bin', 'cucumber.js') }) -Before('@global-install', function () { +Before('@global-install', function() { const tmpObject = tmp.dirSync({ unsafeCleanup: true }) const globalInstallNodeModulesPath = path.join(tmpObject.name, 'node_modules') @@ -86,14 +86,11 @@ Before('@global-install', function () { ) }) -After(function () { +After(function() { if (this.lastRun.error && !this.verifiedLastRunError) { throw new Error( - 'Last run errored unexpectedly. Output:\n\n' + - this.lastRun.output + - '\n\n' + - 'Error Output:\n\n' + - this.lastRun.errorOutput + `Last run errored unexpectedly. Output:\n\n${this.lastRun.output}\n\n` + + `Error Output:\n\n${this.lastRun.errorOutput}` ) } }) diff --git a/features/support/json_output_helpers.js b/features/support/json_output_helpers.js index c1d0d2a96..b093e4b37 100644 --- a/features/support/json_output_helpers.js +++ b/features/support/json_output_helpers.js @@ -1,7 +1,7 @@ import _ from 'lodash' import util from 'util' -export function getScenarioNames (features) { +export function getScenarioNames(features) { return _.chain(features) .map('elements') .flatten() @@ -9,7 +9,7 @@ export function getScenarioNames (features) { .value() } -export function getSteps (features) { +export function getSteps(features) { return _.chain(features) .map('elements') .flatten() @@ -18,7 +18,7 @@ export function getSteps (features) { .value() } -export function findScenario ({ features, scenarioPredicate }) { +export function findScenario({ features, scenarioPredicate }) { const scenario = _.chain(features) .map('elements') .flatten() @@ -26,12 +26,11 @@ export function findScenario ({ features, scenarioPredicate }) { .value() if (scenario) { return scenario - } else { - throw new Error('Could not find scenario matching predicate') } + throw new Error('Could not find scenario matching predicate') } -export function findStep ({ features, stepPredicate, scenarioPredicate }) { +export function findStep({ features, stepPredicate, scenarioPredicate }) { let steps if (scenarioPredicate) { steps = findScenario({ features, scenarioPredicate }).steps @@ -46,17 +45,16 @@ export function findStep ({ features, stepPredicate, scenarioPredicate }) { const step = _.find(steps, stepPredicate) if (step) { return step - } else { - throw new Error( - `Could not find step matching predicate: ${util.inspect(features, { - depth: null - })}` - ) } + throw new Error( + `Could not find step matching predicate: ${util.inspect(features, { + depth: null + })}` + ) } -export function neutraliseVariableValues (report) { - report.forEach(function (item) { +export function neutraliseVariableValues(report) { + report.forEach(item => { ;(item.elements || []).forEach(element => { ;(element.steps || []).forEach(step => { if ('result' in step) { diff --git a/features/support/world.js b/features/support/world.js index bce1f85e2..86798a28a 100644 --- a/features/support/world.js +++ b/features/support/world.js @@ -10,7 +10,7 @@ import VError from 'verror' import _ from 'lodash' class World { - async run (executablePath, inputArgs) { + async run(executablePath, inputArgs) { const args = ['node', executablePath] .concat(inputArgs, ['--backtrace', '--format', 'json:out.json']) .map(arg => { diff --git a/package.json b/package.json index c244f18e0..d6eba178c 100644 --- a/package.json +++ b/package.json @@ -180,16 +180,21 @@ "connect": "^3.4.0", "coveralls": "^3.0.0", "dependency-lint": "^5.0.1", + "eslint": "^4.16.0", + "eslint-config-airbnb-base": "^12.1.0", + "eslint-config-prettier": "^2.9.0", + "eslint-plugin-babel": "^4.1.2", + "eslint-plugin-import": "^2.8.0", + "eslint-plugin-prettier": "^2.5.0", "fs-extra": "^4.0.2", "mocha": "^4.0.1", "mustache": "^2.3.0", "nyc": "^11.0.2", + "prettier": "^1.10.2", "regenerator-runtime": "^0.11.0", "serve-static": "^1.10.0", "sinon": "^4.0.1", "sinon-chai": "^2.11.0", - "snazzy": "^7.0.0", - "standard": "^10.0.3", "stream-to-string": "^1.1.0", "tmp": "^0.0.33" }, @@ -200,8 +205,8 @@ "build-release": "BABEL_ENV=browser browserify src/index.js -o dist/cucumber.js -t babelify --standalone Cucumber", "feature-test": "node ./bin/cucumber.js", "lint-dependencies": "dependency-lint", - "lint-code": "standard --verbose \"{example,features,scripts,src,test}/**/*.js\" | snazzy", - "lint-autofix": "standard --fix --verbose \"{example,features,scripts,src,test}/**/*.js\" | snazzy", + "lint-code": "eslint \"{example,features,scripts,src,test}/**/*.js\"", + "lint-autofix": "eslint --fix \"{example,features,scripts,src,test}/**/*.js\"", "lint": "yarn run lint-code && yarn run lint-dependencies", "prefeature-test": "yarn run build-local", "prepublish": "yarn run build-local", @@ -219,17 +224,5 @@ "bin/", "dist/", "lib/" - ], - "standard": { - "globals": [ - "afterEach", - "beforeEach", - "createMock", - "describe", - "expect", - "it", - "sinon" - ], - "parser": "babel-eslint" - } + ] } diff --git a/scripts/server.js b/scripts/server.js index 96e97f69d..7a8e36918 100644 --- a/scripts/server.js +++ b/scripts/server.js @@ -1,14 +1,14 @@ -let path = require('path') -let http = require('http') -let connect = require('connect') -let serveStatic = require('serve-static') +const path = require('path') +const http = require('http') +const connect = require('connect') +const serveStatic = require('serve-static') -let port = process.env.PORT || 9797 -let app = connect() +const port = process.env.PORT || 9797 +const app = connect() app.use(serveStatic(path.join(__dirname, '..', 'example'))) app.use(serveStatic(path.join(__dirname, '..', 'dist'))) http.createServer(app).listen(port) /* eslint-disable no-console */ -console.log('Accepting connections on port ' + port + '...') +console.log(`Accepting connections on port ${port}...`) /* eslint-enable no-console */ diff --git a/src/cli/argv_parser.js b/src/cli/argv_parser.js index 4969c5967..75eec6dc7 100644 --- a/src/cli/argv_parser.js +++ b/src/cli/argv_parser.js @@ -5,40 +5,40 @@ import path from 'path' import Gherkin from 'gherkin' export default class ArgvParser { - static collect (val, memo) { + static collect(val, memo) { memo.push(val) return memo } - static mergeJson (option) { - return function (str, memo) { + static mergeJson(option) { + return function(str, memo) { let val try { val = JSON.parse(str) } catch (error) { throw new Error( - option + ' passed invalid JSON: ' + error.message + ': ' + str + `${option} passed invalid JSON: ${error.message}: ${str}` ) } if (!_.isPlainObject(val)) { - throw new Error(option + ' must be passed JSON of an object: ' + str) + throw new Error(`${option} must be passed JSON of an object: ${str}`) } return _.merge(memo, val) } } - static mergeTags (val, memo) { + static mergeTags(val, memo) { return memo === '' ? `(${val})` : `${memo} and (${val})` } - static validateLanguage (val) { + static validateLanguage(val) { if (!_.includes(_.keys(Gherkin.DIALECTS), val)) { - throw new Error('Unsupported ISO 639-1: ' + val) + throw new Error(`Unsupported ISO 639-1: ${val}`) } return val } - static parse (argv) { + static parse(argv) { const program = new Command(path.basename(argv[1])) program diff --git a/src/cli/configuration_builder.js b/src/cli/configuration_builder.js index 68e5ed326..851b90d38 100644 --- a/src/cli/configuration_builder.js +++ b/src/cli/configuration_builder.js @@ -7,12 +7,12 @@ import OptionSplitter from './option_splitter' import Promise from 'bluebird' export default class ConfigurationBuilder { - static async build (options) { + static async build(options) { const builder = new ConfigurationBuilder(options) return builder.build() } - constructor ({ argv, cwd }) { + constructor({ argv, cwd }) { this.cwd = cwd this.pathExpander = new PathExpander(cwd) @@ -21,7 +21,7 @@ export default class ConfigurationBuilder { this.options = parsedArgv.options } - async build () { + async build() { const listI18nKeywordsFor = this.options.i18nKeywords const listI18nLanguages = !!this.options.i18nLanguages const unexpandedFeaturePaths = await this.getUnexpandedFeaturePaths() @@ -63,14 +63,14 @@ export default class ConfigurationBuilder { } } - async expandFeaturePaths (featurePaths) { + async expandFeaturePaths(featurePaths) { featurePaths = featurePaths.map(p => p.replace(/(:\d+)*$/g, '')) // Strip line numbers return this.pathExpander.expandPathsWithExtensions(featurePaths, [ 'feature' ]) } - getFeatureDirectoryPaths (featurePaths) { + getFeatureDirectoryPaths(featurePaths) { const featureDirs = featurePaths.map(featurePath => { let featureDir = path.dirname(featurePath) let childDir @@ -88,25 +88,23 @@ export default class ConfigurationBuilder { return _.uniq(featureDirs) } - getFormatOptions () { + getFormatOptions() { const formatOptions = _.clone(this.options.formatOptions) formatOptions.cwd = this.cwd _.defaults(formatOptions, { colorsEnabled: true }) return formatOptions } - getFormats () { + getFormats() { const mapping = { '': 'progress' } this.options.format.forEach(format => { const [type, outputTo] = OptionSplitter.split(format) mapping[outputTo || ''] = type }) - return _.map(mapping, function (type, outputTo) { - return { outputTo, type } - }) + return _.map(mapping, (type, outputTo) => ({ outputTo, type })) } - async getUnexpandedFeaturePaths () { + async getUnexpandedFeaturePaths() { if (this.args.length > 0) { const nestedFeaturePaths = await Promise.map(this.args, async arg => { const filename = path.basename(arg) @@ -118,9 +116,8 @@ export default class ConfigurationBuilder { .map(_.trim) .compact() .value() - } else { - return arg } + return arg }) const featurePaths = _.flatten(nestedFeaturePaths) if (featurePaths.length > 0) { @@ -130,7 +127,7 @@ export default class ConfigurationBuilder { return ['features'] } - async expandSupportCodePaths (supportCodePaths) { + async expandSupportCodePaths(supportCodePaths) { const extensions = ['js'] this.options.compiler.forEach(compiler => { const [extension, module] = OptionSplitter.split(compiler) diff --git a/src/cli/configuration_builder_spec.js b/src/cli/configuration_builder_spec.js index 3a132d1a4..328476bd7 100644 --- a/src/cli/configuration_builder_spec.js +++ b/src/cli/configuration_builder_spec.js @@ -6,8 +6,8 @@ import tmp from 'tmp' const outputFile = promisify(fsExtra.outputFile) -describe('Configuration', function () { - beforeEach(async function () { +describe('Configuration', () => { + beforeEach(async function() { this.tmpDir = await promisify(tmp.dir)({ unsafeCleanup: true }) await promisify(fsExtra.mkdirp)(path.join(this.tmpDir, 'features')) this.argv = ['path/to/node', 'path/to/cucumber.js'] @@ -17,12 +17,12 @@ describe('Configuration', function () { } }) - describe('no argv', function () { - beforeEach(async function () { + describe('no argv', () => { + beforeEach(async function() { this.result = await ConfigurationBuilder.build(this.configurationOptions) }) - it('returns the default configuration', function () { + it('returns the default configuration', function() { expect(this.result).to.eql({ featureDefaultLanguage: '', featurePaths: [], @@ -52,8 +52,8 @@ describe('Configuration', function () { }) }) - describe('path to a feature', function () { - beforeEach(async function () { + describe('path to a feature', () => { + beforeEach(async function() { this.relativeFeaturePath = path.join('features', 'a.feature') this.featurePath = path.join(this.tmpDir, this.relativeFeaturePath) await outputFile(this.featurePath, '') @@ -63,7 +63,7 @@ describe('Configuration', function () { this.result = await ConfigurationBuilder.build(this.configurationOptions) }) - it('returns the appropriate feature and support code paths', async function () { + it('returns the appropriate feature and support code paths', async function() { const { featurePaths, pickleFilterOptions, @@ -77,8 +77,8 @@ describe('Configuration', function () { }) }) - describe('path to a nested feature', function () { - beforeEach(async function () { + describe('path to a nested feature', () => { + beforeEach(async function() { this.relativeFeaturePath = path.join('features', 'nested', 'a.feature') this.featurePath = path.join(this.tmpDir, this.relativeFeaturePath) await outputFile(this.featurePath, '') @@ -88,7 +88,7 @@ describe('Configuration', function () { this.result = await ConfigurationBuilder.build(this.configurationOptions) }) - it('returns the appropriate feature and support code paths', async function () { + it('returns the appropriate feature and support code paths', async function() { const { featurePaths, pickleFilterOptions, @@ -102,13 +102,13 @@ describe('Configuration', function () { }) }) - describe('formatters', function () { - it('adds a default', async function () { + describe('formatters', () => { + it('adds a default', async function() { const formats = await getFormats(this.configurationOptions) expect(formats).to.eql([{ outputTo: '', type: 'progress' }]) }) - it('splits relative unix paths', async function () { + it('splits relative unix paths', async function() { this.argv.push('-f', '../custom/formatter:../formatter/output.txt') const formats = await getFormats(this.configurationOptions) @@ -118,7 +118,7 @@ describe('Configuration', function () { ]) }) - it('splits absolute unix paths', async function () { + it('splits absolute unix paths', async function() { this.argv.push('-f', '/custom/formatter:/formatter/output.txt') const formats = await getFormats(this.configurationOptions) @@ -128,7 +128,7 @@ describe('Configuration', function () { ]) }) - it('splits absolute windows paths', async function () { + it('splits absolute windows paths', async function() { this.argv.push('-f', 'C:\\custom\\formatter:D:\\formatter\\output.txt') const formats = await getFormats(this.configurationOptions) @@ -138,14 +138,14 @@ describe('Configuration', function () { ]) }) - it('does not split absolute windows paths without an output', async function () { + it('does not split absolute windows paths without an output', async function() { this.argv.push('-f', 'C:\\custom\\formatter') const formats = await getFormats(this.configurationOptions) expect(formats).to.eql([{ outputTo: '', type: 'C:\\custom\\formatter' }]) }) - async function getFormats (options) { + async function getFormats(options) { const result = await ConfigurationBuilder.build(options) return result.formats } diff --git a/src/cli/helpers.js b/src/cli/helpers.js index 0e1edd1a9..eaf2fec1a 100644 --- a/src/cli/helpers.js +++ b/src/cli/helpers.js @@ -6,8 +6,8 @@ import path from 'path' import ProfileLoader from './profile_loader' import Promise from 'bluebird' -export async function getExpandedArgv ({ argv, cwd }) { - let { options } = ArgvParser.parse(argv) +export async function getExpandedArgv({ argv, cwd }) { + const { options } = ArgvParser.parse(argv) let fullArgv = argv const profileArgv = await new ProfileLoader(cwd).getArgv(options.profile) if (profileArgv.length > 0) { @@ -16,7 +16,7 @@ export async function getExpandedArgv ({ argv, cwd }) { return fullArgv } -export async function getTestCasesFromFilesystem ({ +export async function getTestCasesFromFilesystem({ cwd, eventBroadcaster, featureDefaultLanguage, @@ -39,7 +39,7 @@ export async function getTestCasesFromFilesystem ({ return result } -export async function getTestCases ({ +export async function getTestCases({ eventBroadcaster, language, pickleFilter, diff --git a/src/cli/helpers_spec.js b/src/cli/helpers_spec.js index e8cdb3bcc..ea33d6fab 100644 --- a/src/cli/helpers_spec.js +++ b/src/cli/helpers_spec.js @@ -6,9 +6,9 @@ import path from 'path' import PickleFilter from '../pickle_filter' import tmp from 'tmp' -describe('helpers', function () { - describe('getTestCasesFromFilesystem', function () { - beforeEach(async function () { +describe('helpers', () => { + describe('getTestCasesFromFilesystem', () => { + beforeEach(async function() { this.onSource = sinon.stub() this.onGherkinDocument = sinon.stub() this.onPickle = sinon.stub() @@ -22,8 +22,8 @@ describe('helpers', function () { this.eventBroadcaster.on('pickle-rejected', this.onPickleRejected) }) - describe('empty feature', function () { - beforeEach(async function () { + describe('empty feature', () => { + beforeEach(async function() { this.tmpDir = await promisify(tmp.dir)() this.relativeFeaturePath = path.join('features', 'a.feature') const featurePath = path.join(this.tmpDir, 'features', 'a.feature') @@ -36,11 +36,11 @@ describe('helpers', function () { }) }) - it('returns an empty array', function () { + it('returns an empty array', function() { expect(this.result).to.eql([]) }) - it('emits a source event', function () { + it('emits a source event', function() { expect(this.onSource).to.have.callCount(1) expect(this.onSource).to.have.been.calledWith({ data: '', @@ -49,22 +49,22 @@ describe('helpers', function () { }) }) - it('emits a gherkin-document event', function () { + it('emits a gherkin-document event', function() { expect(this.onGherkinDocument).to.have.callCount(1) const arg = this.onGherkinDocument.firstCall.args[0] expect(arg).to.have.keys(['document', 'uri']) expect(arg.uri).to.eql(this.relativeFeaturePath) }) - it('does not emit pickle events', function () { + it('does not emit pickle events', function() { expect(this.onPickle).to.have.callCount(0) expect(this.onPickleAccepted).to.have.callCount(0) expect(this.onPickleRejected).to.have.callCount(0) }) }) - describe('feature with scenario that does not match the filter', function () { - beforeEach(async function () { + describe('feature with scenario that does not match the filter', () => { + beforeEach(async function() { this.tmpDir = await promisify(tmp.dir)() this.relativeFeaturePath = path.join('features', 'a.feature') const featurePath = path.join(this.tmpDir, 'features', 'a.feature') @@ -82,11 +82,11 @@ describe('helpers', function () { }) }) - it('returns an empty array', function () { + it('returns an empty array', function() { expect(this.result).to.eql([]) }) - it('emits a source event', function () { + it('emits a source event', function() { expect(this.onSource).to.have.callCount(1) expect(this.onSource).to.have.been.calledWith({ data: 'Feature: a\nScenario: b\nGiven a step', @@ -95,7 +95,7 @@ describe('helpers', function () { }) }) - it('emits a gherkin-document event', function () { + it('emits a gherkin-document event', function() { expect(this.onGherkinDocument).to.have.callCount(1) const arg = this.onGherkinDocument.firstCall.args[0] expect(arg).to.have.keys(['document', 'uri']) @@ -103,8 +103,8 @@ describe('helpers', function () { }) }) - describe('feature with scenario that matches the filter', function () { - beforeEach(async function () { + describe('feature with scenario that matches the filter', () => { + beforeEach(async function() { this.tmpDir = await promisify(tmp.dir)() this.relativeFeaturePath = path.join('features', 'a.feature') const featurePath = path.join(this.tmpDir, 'features', 'a.feature') @@ -120,13 +120,13 @@ describe('helpers', function () { }) }) - it('returns the test case', function () { + it('returns the test case', function() { expect(this.result).to.have.lengthOf(1) expect(this.result[0]).to.have.keys(['pickle', 'uri']) expect(this.result[0].uri).to.eql(this.relativeFeaturePath) }) - it('emits a source event', function () { + it('emits a source event', function() { expect(this.onSource).to.have.callCount(1) expect(this.onSource).to.have.been.calledWith({ data: 'Feature: a\nScenario: b\nGiven a step', @@ -135,14 +135,14 @@ describe('helpers', function () { }) }) - it('emits a gherkin-document event', function () { + it('emits a gherkin-document event', function() { expect(this.onGherkinDocument).to.have.callCount(1) const arg = this.onGherkinDocument.firstCall.args[0] expect(arg).to.have.keys(['document', 'uri']) expect(arg.uri).to.eql(this.relativeFeaturePath) }) - it('emits a pickle and pickle-accepted event', function () { + it('emits a pickle and pickle-accepted event', function() { expect(this.onPickle).to.have.callCount(1) expect(this.onPickleAccepted).to.have.callCount(1) expect(this.onPickleRejected).to.have.callCount(0) diff --git a/src/cli/i18n.js b/src/cli/i18n.js index f94517495..db96aad20 100644 --- a/src/cli/i18n.js +++ b/src/cli/i18n.js @@ -16,7 +16,7 @@ const keywords = [ 'but' ] -function getAsTable (header, rows) { +function getAsTable(header, rows) { const table = new Table({ chars: { bottom: '', @@ -42,18 +42,20 @@ function getAsTable (header, rows) { } }) table.push(header) - table.push.apply(table, rows) + table.push(...rows) return table.toString() } -export function getLanguages () { - const rows = _.map(Gherkin.DIALECTS, (data, isoCode) => { - return [isoCode, data.name, data['native']] - }) +export function getLanguages() { + const rows = _.map(Gherkin.DIALECTS, (data, isoCode) => [ + isoCode, + data.name, + data.native + ]) return getAsTable(['ISO 639-1', 'ENGLISH NAME', 'NATIVE NAME'], rows) } -export function getKeywords (isoCode) { +export function getKeywords(isoCode) { const language = Gherkin.DIALECTS[isoCode] const rows = _.map(keywords, keyword => { const words = _.map(language[keyword], s => `"${s}"`).join(', ') diff --git a/src/cli/index.js b/src/cli/index.js index a3b7de5a4..483c9571b 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -13,18 +13,18 @@ import Runtime from '../runtime' import supportCodeLibraryBuilder from '../support_code_library_builder' export default class Cli { - constructor ({ argv, cwd, stdout }) { + constructor({ argv, cwd, stdout }) { this.argv = argv this.cwd = cwd this.stdout = stdout } - async getConfiguration () { + async getConfiguration() { const fullArgv = await getExpandedArgv({ argv: this.argv, cwd: this.cwd }) return ConfigurationBuilder.build({ argv: fullArgv, cwd: this.cwd }) } - async initializeFormatters ({ + async initializeFormatters({ eventBroadcaster, formatOptions, formats, @@ -35,7 +35,7 @@ export default class Cli { await Promise.map(formats, async ({ type, outputTo }) => { let stream = this.stdout if (outputTo) { - let fd = await fs.open(path.resolve(this.cwd, outputTo), 'w') + const fd = await fs.open(path.resolve(this.cwd, outputTo), 'w') stream = fs.createWriteStream(null, { fd }) streamsToClose.push(stream) } @@ -49,20 +49,20 @@ export default class Cli { } return FormatterBuilder.build(type, typeOptions) }) - return function () { + return function() { return Promise.each(streamsToClose, stream => Promise.promisify(::stream.end)() ) } } - getSupportCodeLibrary (supportCodePaths) { + getSupportCodeLibrary(supportCodePaths) { supportCodeLibraryBuilder.reset(this.cwd) supportCodePaths.forEach(codePath => require(codePath)) return supportCodeLibraryBuilder.finalize() } - async run () { + async run() { await validateInstall(this.cwd) const configuration = await this.getConfiguration() if (configuration.listI18nLanguages) { diff --git a/src/cli/install_validator.js b/src/cli/install_validator.js index 7af97d3e6..1387ce86e 100644 --- a/src/cli/install_validator.js +++ b/src/cli/install_validator.js @@ -3,7 +3,7 @@ import fs from 'mz/fs' import path from 'path' import resolve from 'resolve' -export async function validateInstall (cwd) { +export async function validateInstall(cwd) { const projectPath = path.join(__dirname, '..', '..') if (projectPath === cwd) { return // cucumber testing itself diff --git a/src/cli/option_splitter.js b/src/cli/option_splitter.js index 3326d3f5e..19cee5342 100644 --- a/src/cli/option_splitter.js +++ b/src/cli/option_splitter.js @@ -1,5 +1,5 @@ export default class OptionSplitter { - static split (option) { + static split(option) { const parts = option.split(/([^A-Z]):(?!\\)/) return parts.reduce((memo, part, i) => { @@ -12,6 +12,6 @@ export default class OptionSplitter { } } -function partNeedsRecombined (i) { +function partNeedsRecombined(i) { return i % 2 === 0 } diff --git a/src/cli/option_splitter_spec.js b/src/cli/option_splitter_spec.js index d60463260..03b6266b9 100644 --- a/src/cli/option_splitter_spec.js +++ b/src/cli/option_splitter_spec.js @@ -1,6 +1,6 @@ import OptionSplitter from './option_splitter' -describe('OptionSplitter', function () { +describe('OptionSplitter', () => { const examples = [ { description: "doesn't split when nothing to split on", @@ -45,7 +45,7 @@ describe('OptionSplitter', function () { ] examples.forEach(({ description, input, output }) => { - it(description, function () { + it(description, () => { expect(OptionSplitter.split(input)).to.eql(output) }) }) diff --git a/src/cli/path_expander.js b/src/cli/path_expander.js index 3a83f3ced..c2a7529d4 100644 --- a/src/cli/path_expander.js +++ b/src/cli/path_expander.js @@ -5,31 +5,30 @@ import path from 'path' import Promise from 'bluebird' export default class PathExpander { - constructor (directory) { + constructor(directory) { this.directory = directory } - async expandPathsWithExtensions (paths, extensions) { - const expandedPaths = await Promise.map(paths, async p => { - return this.expandPathWithExtensions(p, extensions) - }) + async expandPathsWithExtensions(paths, extensions) { + const expandedPaths = await Promise.map(paths, async p => + this.expandPathWithExtensions(p, extensions) + ) return _.uniq(_.flatten(expandedPaths)) } - async expandPathWithExtensions (p, extensions) { + async expandPathWithExtensions(p, extensions) { const fullPath = path.resolve(this.directory, p) const stats = await fs.stat(fullPath) if (stats.isDirectory()) { return this.expandDirectoryWithExtensions(fullPath, extensions) - } else { - return [fullPath] } + return [fullPath] } - async expandDirectoryWithExtensions (realPath, extensions) { - let pattern = realPath + '/**/*.' + async expandDirectoryWithExtensions(realPath, extensions) { + let pattern = `${realPath}/**/*.` if (extensions.length > 1) { - pattern += '{' + extensions.join(',') + '}' + pattern += `{${extensions.join(',')}}` } else { pattern += extensions[0] } diff --git a/src/cli/path_expander_spec.js b/src/cli/path_expander_spec.js index 04a166131..d2f476719 100644 --- a/src/cli/path_expander_spec.js +++ b/src/cli/path_expander_spec.js @@ -4,15 +4,15 @@ import path from 'path' import PathExpander from './path_expander' import tmp from 'tmp' -describe('PathExpander', function () { - describe('expandPathsWithExtensions', function () { - beforeEach(async function () { +describe('PathExpander', () => { + describe('expandPathsWithExtensions', () => { + beforeEach(async function() { this.tmpDir = await promisify(tmp.dir)({ unsafeCleanup: true }) this.pathExpander = new PathExpander(this.tmpDir) }) - describe('with a file', function () { - beforeEach(async function () { + describe('with a file', () => { + beforeEach(async function() { await fs.writeFile(path.join(this.tmpDir, 'a.ext'), 'content') this.results = await this.pathExpander.expandPathsWithExtensions( ['a.ext'], @@ -20,32 +20,32 @@ describe('PathExpander', function () { ) }) - it('returns the file', async function () { + it('returns the file', async function() { expect(this.results).to.eql([path.join(this.tmpDir, 'a.ext')]) }) }) - describe('with a folder', function () { - beforeEach(async function () { + describe('with a folder', () => { + beforeEach(async function() { this.subdirectoryPath = path.join(this.tmpDir, 'subdirectory') await fs.mkdir(this.subdirectoryPath) }) - describe('no files with the extension', function () { - beforeEach(async function () { + describe('no files with the extension', () => { + beforeEach(async function() { this.results = await this.pathExpander.expandPathsWithExtensions( ['subdirectory'], ['ext'] ) }) - it('returns an empty array', function () { + it('returns an empty array', function() { expect(this.results).to.eql([]) }) }) - describe('child file with the extension', function () { - beforeEach(async function () { + describe('child file with the extension', () => { + beforeEach(async function() { await fs.writeFile( path.join(this.subdirectoryPath, 'a.ext'), 'content' @@ -56,15 +56,15 @@ describe('PathExpander', function () { ) }) - it('returns the file', async function () { + it('returns the file', async function() { expect(this.results).to.eql([ path.join(this.subdirectoryPath, 'a.ext') ]) }) }) - describe('nested child file with the extension', function () { - beforeEach(async function () { + describe('nested child file with the extension', () => { + beforeEach(async function() { this.nestedSubdirectoryPath = path.join( this.subdirectoryPath, 'nested-subdirectory' @@ -80,7 +80,7 @@ describe('PathExpander', function () { ) }) - it('returns the file', async function () { + it('returns the file', async function() { expect(this.results).to.eql([ path.join(this.nestedSubdirectoryPath, 'a.ext') ]) diff --git a/src/cli/profile_loader.js b/src/cli/profile_loader.js index 78c440f6c..d251af083 100644 --- a/src/cli/profile_loader.js +++ b/src/cli/profile_loader.js @@ -4,11 +4,11 @@ import path from 'path' import stringArgv from 'string-argv' export default class ProfileLoader { - constructor (directory) { + constructor(directory) { this.directory = directory } - async getDefinitions () { + async getDefinitions() { const definitionsFilePath = path.join(this.directory, 'cucumber.js') const exists = await fs.exists(definitionsFilePath) if (!exists) { @@ -16,19 +16,19 @@ export default class ProfileLoader { } const definitions = require(definitionsFilePath) if (typeof definitions !== 'object') { - throw new Error(definitionsFilePath + ' does not export an object') + throw new Error(`${definitionsFilePath} does not export an object`) } return definitions } - async getArgv (profiles) { + async getArgv(profiles) { const definitions = await this.getDefinitions() - if (profiles.length === 0 && definitions['default']) { + if (profiles.length === 0 && definitions.default) { profiles = ['default'] } - const argvs = profiles.map(function (profile) { + const argvs = profiles.map(profile => { if (!definitions[profile]) { - throw new Error('Undefined profile: ' + profile) + throw new Error(`Undefined profile: ${profile}`) } return stringArgv(definitions[profile]) }) diff --git a/src/cli/profile_loader_spec.js b/src/cli/profile_loader_spec.js index a463a3f54..ae2056fd0 100644 --- a/src/cli/profile_loader_spec.js +++ b/src/cli/profile_loader_spec.js @@ -4,24 +4,24 @@ import path from 'path' import ProfileLoader from './profile_loader' import tmp from 'tmp' -describe('ProfileLoader', function () { - describe('getArgv', function () { - beforeEach(async function () { +describe('ProfileLoader', () => { + describe('getArgv', () => { + beforeEach(async function() { this.tmpDir = await promisify(tmp.dir)({ unsafeCleanup: true }) this.profileLoader = new ProfileLoader(this.tmpDir) }) - describe('with no identifiers', function () { - describe('no definition file', function () { - it('returns an empty array', async function () { + describe('with no identifiers', () => { + describe('no definition file', () => { + it('returns an empty array', async function() { const result = await this.profileLoader.getArgv([]) expect(result).to.eql([]) }) }) - describe('with definition file', function () { - describe('with a default', function () { - beforeEach(async function () { + describe('with definition file', () => { + describe('with a default', () => { + beforeEach(async function() { const fileContent = 'module.exports = {default: "--opt1 --opt2"}' await fs.writeFile( path.join(this.tmpDir, 'cucumber.js'), @@ -29,14 +29,14 @@ describe('ProfileLoader', function () { ) }) - it('returns the argv for the default profile', async function () { + it('returns the argv for the default profile', async function() { const result = await this.profileLoader.getArgv([]) expect(result).to.eql(['--opt1', '--opt2']) }) }) - describe('without a default', function () { - beforeEach(async function () { + describe('without a default', () => { + beforeEach(async function() { const fileContent = 'module.exports = {profile1: "--opt1 --opt2"}' await fs.writeFile( path.join(this.tmpDir, 'cucumber.js'), @@ -44,7 +44,7 @@ describe('ProfileLoader', function () { ) }) - it('returns an empty array', async function () { + it('returns an empty array', async function() { const result = await this.profileLoader.getArgv([]) expect(result).to.eql([]) }) @@ -52,9 +52,9 @@ describe('ProfileLoader', function () { }) }) - describe('with identifiers', function () { - describe('no definition file', function () { - it('throws', async function () { + describe('with identifiers', () => { + describe('no definition file', () => { + it('throws', async function() { let thrown = false try { await this.profileLoader.getArgv(['profile1']) @@ -66,8 +66,8 @@ describe('ProfileLoader', function () { }) }) - describe('with definition file', function () { - beforeEach(async function () { + describe('with definition file', () => { + beforeEach(async function() { const fileContent = 'module.exports = {\n' + ' profile1: "--opt1 --opt2",\n' + @@ -76,22 +76,22 @@ describe('ProfileLoader', function () { await fs.writeFile(path.join(this.tmpDir, 'cucumber.js'), fileContent) }) - describe('profile is defined', function () { - it('returns the argv for the given profile', async function () { + describe('profile is defined', () => { + it('returns the argv for the given profile', async function() { const result = await this.profileLoader.getArgv(['profile1']) expect(result).to.eql(['--opt1', '--opt2']) }) }) - describe('profile is defined and contains quoted string', function () { - it('returns the argv for the given profile', async function () { + describe('profile is defined and contains quoted string', () => { + it('returns the argv for the given profile', async function() { const result = await this.profileLoader.getArgv(['profile2']) expect(result).to.eql(['--opt3', 'some value']) }) }) - describe('profile is not defined', function () { - it('throws', async function () { + describe('profile is not defined', () => { + it('throws', async function() { let thrown = false try { await this.profileLoader.getArgv(['profile3']) diff --git a/src/cli/run.js b/src/cli/run.js index 5b5a24df6..37eb56757 100644 --- a/src/cli/run.js +++ b/src/cli/run.js @@ -1,12 +1,12 @@ import Cli from './' import VError from 'verror' -function exitWithError (error) { +function exitWithError(error) { console.error(VError.fullStack(error)) // eslint-disable-line no-console process.exit(1) } -export default async function run () { +export default async function run() { const cwd = process.cwd() const cli = new Cli({ argv: process.argv, diff --git a/src/formatter/builder.js b/src/formatter/builder.js index 36c320fcf..e2b041603 100644 --- a/src/formatter/builder.js +++ b/src/formatter/builder.js @@ -13,7 +13,7 @@ import UsageFormatter from './usage_formatter' import UsageJsonFormatter from './usage_json_formatter' export default class FormatterBuilder { - static build (type, options) { + static build(type, options) { const Formatter = FormatterBuilder.getConstructorByType(type, options) const extendedOptions = { colorFns: getColorFns(options.colorsEnabled), @@ -23,7 +23,7 @@ export default class FormatterBuilder { return new Formatter(extendedOptions) } - static getConstructorByType (type, options) { + static getConstructorByType(type, options) { switch (type) { case 'event-protocol': return EventProtocolFormatter @@ -48,7 +48,7 @@ export default class FormatterBuilder { } } - static getStepDefinitionSnippetBuilder ({ + static getStepDefinitionSnippetBuilder({ cwd, snippetInterface, snippetSyntax, @@ -68,7 +68,7 @@ export default class FormatterBuilder { }) } - static loadCustomFormatter (customFormatterPath, { cwd }) { + static loadCustomFormatter(customFormatterPath, { cwd }) { const fullCustomFormatterPath = path.resolve(cwd, customFormatterPath) const CustomFormatter = require(fullCustomFormatterPath) if (typeof CustomFormatter === 'function') { @@ -78,10 +78,9 @@ export default class FormatterBuilder { typeof CustomFormatter.default === 'function' ) { return CustomFormatter.default - } else { - throw new Error( - `Custom formatter (${customFormatterPath}) does not export a function` - ) } + throw new Error( + `Custom formatter (${customFormatterPath}) does not export a function` + ) } } diff --git a/src/formatter/event_protocol_formatter.js b/src/formatter/event_protocol_formatter.js index 210db060e..921b60f32 100644 --- a/src/formatter/event_protocol_formatter.js +++ b/src/formatter/event_protocol_formatter.js @@ -20,7 +20,7 @@ const EVENT_NAMES = [ ] export default class EventProtocolFormatter extends Formatter { - constructor (options) { + constructor(options) { super(options) EVENT_NAMES.forEach(eventName => { options.eventBroadcaster.on(eventName, data => @@ -34,19 +34,18 @@ export default class EventProtocolFormatter extends Formatter { this.pathRegexp = new RegExp(escapeStringRegexp(pathToRemove), 'g') } - logEvent (eventName, data) { + logEvent(eventName, data) { const text = JSON.stringify( { type: eventName, ...data }, ::this.formatJsonData ) - this.log(text + '\n') + this.log(`${text}\n`) } - formatJsonData (key, value) { + formatJsonData(key, value) { if (value instanceof Error) { return value.stack.replace(this.pathRegexp, '') - } else { - return value } + return value } } diff --git a/src/formatter/get_color_fns.js b/src/formatter/get_color_fns.js index db0b9a3e4..6a6291d85 100644 --- a/src/formatter/get_color_fns.js +++ b/src/formatter/get_color_fns.js @@ -1,7 +1,7 @@ import colors from 'colors/safe' import Status from '../status' -export default function getColorFns (enabled) { +export default function getColorFns(enabled) { colors.enabled = enabled colors.setTheme({ [Status.AMBIGUOUS]: 'red', diff --git a/src/formatter/helpers/error_helpers.js b/src/formatter/helpers/error_helpers.js index 1d881f637..4ab7f0130 100644 --- a/src/formatter/helpers/error_helpers.js +++ b/src/formatter/helpers/error_helpers.js @@ -1,6 +1,6 @@ import { format } from 'assertion-error-formatter' -export function formatError (error, colorFns) { +export function formatError(error, colorFns) { return format(error, { colorFns: { diffAdded: colorFns.red, diff --git a/src/formatter/helpers/event_data_collector.js b/src/formatter/helpers/event_data_collector.js index d19cb1f12..aa30f1172 100644 --- a/src/formatter/helpers/event_data_collector.js +++ b/src/formatter/helpers/event_data_collector.js @@ -2,7 +2,7 @@ import { getStepLineToKeywordMap } from './gherkin_document_parser' import { getStepLineToPickledStepMap } from './pickle_parser' export default class EventDataCollector { - constructor (eventBroadcaster) { + constructor(eventBroadcaster) { eventBroadcaster .on('gherkin-document', ::this.storeGherkinDocument) .on('pickle-accepted', ::this.storePickle) @@ -15,11 +15,11 @@ export default class EventDataCollector { this.testCaseMap = {} // uri:line to {sourceLocation, steps, result} } - getTestCaseKey ({ uri, line }) { + getTestCaseKey({ uri, line }) { return `${uri}:${line}` } - getTestCaseData (sourceLocation) { + getTestCaseData(sourceLocation) { return { gherkinDocument: this.gherkinDocumentMap[sourceLocation.uri], pickle: this.pickleMap[this.getTestCaseKey(sourceLocation)], @@ -27,7 +27,7 @@ export default class EventDataCollector { } } - getTestStepData ({ testCase: { sourceLocation }, index }) { + getTestStepData({ testCase: { sourceLocation }, index }) { const { gherkinDocument, pickle, testCase } = this.getTestCaseData( sourceLocation ) @@ -40,20 +40,20 @@ export default class EventDataCollector { return result } - storeGherkinDocument ({ document, uri }) { + storeGherkinDocument({ document, uri }) { this.gherkinDocumentMap[uri] = document } - storePickle ({ pickle, uri }) { + storePickle({ pickle, uri }) { this.pickleMap[`${uri}:${pickle.locations[0].line}`] = pickle } - storeTestCase ({ sourceLocation, steps }) { + storeTestCase({ sourceLocation, steps }) { const key = this.getTestCaseKey(sourceLocation) this.testCaseMap[key] = { sourceLocation, steps } } - storeTestStepAttachment ({ index, testCase, data, media }) { + storeTestStepAttachment({ index, testCase, data, media }) { const key = this.getTestCaseKey(testCase.sourceLocation) const step = this.testCaseMap[key].steps[index] if (!step.attachments) { @@ -62,12 +62,12 @@ export default class EventDataCollector { step.attachments.push({ data, media }) } - storeTestStepResult ({ index, testCase, result }) { + storeTestStepResult({ index, testCase, result }) { const key = this.getTestCaseKey(testCase.sourceLocation) this.testCaseMap[key].steps[index].result = result } - storeTestCaseResult ({ sourceLocation, result }) { + storeTestCaseResult({ sourceLocation, result }) { const key = this.getTestCaseKey(sourceLocation) this.testCaseMap[key].result = result } diff --git a/src/formatter/helpers/gherkin_document_parser.js b/src/formatter/helpers/gherkin_document_parser.js index d3fe9a861..b6dc5e1d9 100644 --- a/src/formatter/helpers/gherkin_document_parser.js +++ b/src/formatter/helpers/gherkin_document_parser.js @@ -1,6 +1,6 @@ import _ from 'lodash' -export function getStepLineToKeywordMap (gherkinDocument) { +export function getStepLineToKeywordMap(gherkinDocument) { return _.chain(gherkinDocument.feature.children) .map('steps') .flatten() @@ -9,7 +9,7 @@ export function getStepLineToKeywordMap (gherkinDocument) { .value() } -export function getScenarioLineToDescriptionMap (gherkinDocument) { +export function getScenarioLineToDescriptionMap(gherkinDocument) { return _.chain(gherkinDocument.feature.children) .map(element => [element.location.line, element.description]) .fromPairs() diff --git a/src/formatter/helpers/issue_helpers.js b/src/formatter/helpers/issue_helpers.js index a882442c6..587b46b68 100644 --- a/src/formatter/helpers/issue_helpers.js +++ b/src/formatter/helpers/issue_helpers.js @@ -28,12 +28,12 @@ const IS_ISSUE = { [Status.UNDEFINED]: true } -function formatDataTable (arg) { - const rows = arg.rows.map(row => { - return row.cells.map(cell => { - return cell.value.replace(/\\/g, '\\\\').replace(/\n/g, '\\n') - }) - }) +function formatDataTable(arg) { + const rows = arg.rows.map(row => + row.cells.map(cell => + cell.value.replace(/\\/g, '\\\\').replace(/\n/g, '\\n') + ) + ) const table = new Table({ chars: { bottom: '', @@ -58,15 +58,15 @@ function formatDataTable (arg) { 'padding-right': 1 } }) - table.push.apply(table, rows) + table.push(...rows) return table.toString() } -function formatDocString (arg) { - return '"""\n' + arg.content + '\n"""' +function formatDocString(arg) { + return `"""\n${arg.content}\n"""` } -function formatStep ({ +function formatStep({ colorFns, isBeforeHook, keyword, @@ -85,11 +85,11 @@ function formatStep ({ identifier = isBeforeHook ? 'Before' : 'After' } - let text = colorFn(CHARACTERS[status] + ' ' + identifier) + let text = colorFn(`${CHARACTERS[status]} ${identifier}`) const { actionLocation } = testStep if (actionLocation) { - text += ' # ' + colorFns.location(formatLocation(actionLocation)) + text += ` # ${colorFns.location(formatLocation(actionLocation))}` } text += '\n' @@ -101,7 +101,7 @@ function formatStep ({ }) _.each(pickleStep.arguments, iterator) if (str) { - text += indentString(colorFn(str) + '\n', 4) + text += indentString(`${colorFn(str)}\n`, 4) } } const message = getStepMessage({ @@ -112,16 +112,16 @@ function formatStep ({ testStep }) if (message) { - text += indentString(message, 4) + '\n' + text += `${indentString(message, 4)}\n` } return text } -export function isIssue (status) { +export function isIssue(status) { return IS_ISSUE[status] } -export function formatIssue ({ +export function formatIssue({ colorFns, gherkinDocument, number, @@ -129,15 +129,10 @@ export function formatIssue ({ snippetBuilder, testCase }) { - const prefix = number + ') ' + const prefix = `${number}) ` let text = prefix const scenarioLocation = formatLocation(testCase.sourceLocation) - text += - 'Scenario: ' + - pickle.name + - ' # ' + - colorFns.location(scenarioLocation) + - '\n' + text += `Scenario: ${pickle.name} # ${colorFns.location(scenarioLocation)}\n` const stepLineToKeywordMap = getStepLineToKeywordMap(gherkinDocument) const stepLineToPickledStepMap = getStepLineToPickledStepMap(pickle) let isBeforeHook = true @@ -166,5 +161,5 @@ export function formatIssue ({ text += indentString(formattedStep, prefix.length) previousKeywordType = keywordType }) - return text + '\n' + return `${text}\n` } diff --git a/src/formatter/helpers/issue_helpers_spec.js b/src/formatter/helpers/issue_helpers_spec.js index d503c41fc..9bb5d9bcb 100644 --- a/src/formatter/helpers/issue_helpers_spec.js +++ b/src/formatter/helpers/issue_helpers_spec.js @@ -4,8 +4,8 @@ import { formatIssue } from './issue_helpers' import figures from 'figures' import Gherkin from 'gherkin' -describe('IssueHelpers', function () { - beforeEach(function () { +describe('IssueHelpers', () => { + beforeEach(function() { const gherkinDocument = new Gherkin.Parser().parse( 'Feature: my feature\n' + ' Scenario: my scenario\n' + @@ -43,9 +43,9 @@ describe('IssueHelpers', function () { this.skippedStepResult = { status: Status.SKIPPED } }) - describe('formatIssue', function () { - describe('returns the formatted scenario', function () { - beforeEach(function () { + describe('formatIssue', () => { + describe('returns the formatted scenario', () => { + beforeEach(function() { this.testCase.steps[0].result = this.passedStepResult this.testCase.steps[1] = { actionLocation: { line: 3, uri: 'steps.js' }, @@ -59,7 +59,7 @@ describe('IssueHelpers', function () { this.formattedIssue = formatIssue(this.options) }) - it('prints the scenario', function () { + it('prints the scenario', function() { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + @@ -70,8 +70,8 @@ describe('IssueHelpers', function () { }) }) - describe('with an ambiguous step', function () { - beforeEach(function () { + describe('with an ambiguous step', () => { + beforeEach(function() { this.testCase.steps[0].result = this.passedStepResult this.testCase.steps[1] = { actionLocation: { line: 3, uri: 'steps.js' }, @@ -88,7 +88,7 @@ describe('IssueHelpers', function () { this.formattedIssue = formatIssue(this.options) }) - it('returns the formatted scenario', function () { + it('returns the formatted scenario', function() { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + @@ -101,8 +101,8 @@ describe('IssueHelpers', function () { }) }) - describe('with an undefined step', function () { - beforeEach(function () { + describe('with an undefined step', () => { + beforeEach(function() { this.testCase.steps[0].result = this.passedStepResult this.testCase.steps[1] = { sourceLocation: { line: 4, uri: 'a.feature' }, @@ -112,7 +112,7 @@ describe('IssueHelpers', function () { this.formattedIssue = formatIssue(this.options) }) - it('returns the formatted scenario', function () { + it('returns the formatted scenario', function() { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + @@ -126,8 +126,8 @@ describe('IssueHelpers', function () { }) }) - describe('with a pending step', function () { - beforeEach(function () { + describe('with a pending step', () => { + beforeEach(function() { this.testCase.steps[0].result = this.passedStepResult this.testCase.steps[1] = { actionLocation: { line: 3, uri: 'steps.js' }, @@ -138,7 +138,7 @@ describe('IssueHelpers', function () { this.formattedIssue = formatIssue(this.options) }) - it('returns the formatted scenario', function () { + it('returns the formatted scenario', function() { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + @@ -149,8 +149,8 @@ describe('IssueHelpers', function () { }) }) - describe('step with data table', function () { - beforeEach(function () { + describe('step with data table', () => { + beforeEach(function() { const gherkinDocument = new Gherkin.Parser().parse( 'Feature: my feature\n' + ' Scenario: my scenario\n' + @@ -174,7 +174,7 @@ describe('IssueHelpers', function () { this.formattedIssue = formatIssue(this.options) }) - it('returns the formatted scenario', function () { + it('returns the formatted scenario', function() { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + @@ -188,8 +188,8 @@ describe('IssueHelpers', function () { }) }) - describe('step with doc string', function () { - beforeEach(function () { + describe('step with doc string', () => { + beforeEach(function() { const gherkinDocument = new Gherkin.Parser().parse( 'Feature: my feature\n' + ' Scenario: my scenario\n' + @@ -216,7 +216,7 @@ describe('IssueHelpers', function () { this.formattedIssue = formatIssue(this.options) }) - it('returns the formatted scenario', function () { + it('returns the formatted scenario', function() { expect(this.formattedIssue).to.eql( '1) Scenario: my scenario # a.feature:2\n' + ` ${figures.tick} Given step1 # steps.js:2\n` + diff --git a/src/formatter/helpers/keyword_type.js b/src/formatter/helpers/keyword_type.js index 1bb9dfd36..d6a379ad7 100644 --- a/src/formatter/helpers/keyword_type.js +++ b/src/formatter/helpers/keyword_type.js @@ -9,11 +9,11 @@ const types = { export default types -export function getStepKeywordType ({ keyword, language, previousKeywordType }) { +export function getStepKeywordType({ keyword, language, previousKeywordType }) { const dialect = Gherkin.DIALECTS[language] - const type = _.find(['given', 'when', 'then', 'and', 'but'], key => { - return _.includes(dialect[key], keyword) - }) + const type = _.find(['given', 'when', 'then', 'and', 'but'], key => + _.includes(dialect[key], keyword) + ) switch (type) { case 'when': return types.EVENT diff --git a/src/formatter/helpers/keyword_type_spec.js b/src/formatter/helpers/keyword_type_spec.js index 1a16ec8a2..b5774db6a 100644 --- a/src/formatter/helpers/keyword_type_spec.js +++ b/src/formatter/helpers/keyword_type_spec.js @@ -1,67 +1,67 @@ import KeywordType, { getStepKeywordType } from './keyword_type' -describe('KeywordType', function () { - describe('constants', function () { - it('exposes the proper constants', function () { +describe('KeywordType', () => { + describe('constants', () => { + it('exposes the proper constants', () => { expect(KeywordType).to.include.keys(['EVENT', 'OUTCOME', 'PRECONDITION']) }) }) - describe('getStepKeywordType()', function () { - describe('keyword is Given', function () { - beforeEach(function () { + describe('getStepKeywordType()', () => { + describe('keyword is Given', () => { + beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'Given ', language: 'en' }) }) - it('returns precondition', function () { + it('returns precondition', function() { expect(this.keywordType).to.eql(KeywordType.PRECONDITION) }) }) - describe('keyword is When', function () { - beforeEach(function () { + describe('keyword is When', () => { + beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'When ', language: 'en' }) }) - it('returns event', function () { + it('returns event', function() { expect(this.keywordType).to.eql(KeywordType.EVENT) }) }) - describe('keyword is Then', function () { - beforeEach(function () { + describe('keyword is Then', () => { + beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'Then ', language: 'en' }) }) - it('returns outcome', function () { + it('returns outcome', function() { expect(this.keywordType).to.eql(KeywordType.OUTCOME) }) }) - describe('keyword is And, no previous step', function () { - beforeEach(function () { + describe('keyword is And, no previous step', () => { + beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'And ', language: 'en' }) }) - it('returns precondition', function () { + it('returns precondition', function() { expect(this.keywordType).to.eql(KeywordType.PRECONDITION) }) }) - describe('keyword is And, previous keyword type is event', function () { - beforeEach(function () { + describe('keyword is And, previous keyword type is event', () => { + beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'And ', language: 'en', @@ -69,26 +69,26 @@ describe('KeywordType', function () { }) }) - it('returns event', function () { + it('returns event', function() { expect(this.keywordType).to.eql(KeywordType.EVENT) }) }) - describe('keyword is But, no previous step', function () { - beforeEach(function () { + describe('keyword is But, no previous step', () => { + beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'But ', language: 'en' }) }) - it('returns precondition', function () { + it('returns precondition', function() { expect(this.keywordType).to.eql(KeywordType.PRECONDITION) }) }) - describe('keyword is But, previous keyword type is outcome', function () { - beforeEach(function () { + describe('keyword is But, previous keyword type is outcome', () => { + beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'But ', language: 'en', @@ -96,13 +96,13 @@ describe('KeywordType', function () { }) }) - it('returns outcome', function () { + it('returns outcome', function() { expect(this.keywordType).to.eql(KeywordType.OUTCOME) }) }) - describe('keyword is unknown', function () { - beforeEach(function () { + describe('keyword is unknown', () => { + beforeEach(function() { this.keywordType = getStepKeywordType({ index: 0, language: 'en', @@ -110,7 +110,7 @@ describe('KeywordType', function () { }) }) - it('returns precondition', function () { + it('returns precondition', function() { expect(this.keywordType).to.eql(KeywordType.PRECONDITION) }) }) diff --git a/src/formatter/helpers/location_helpers.js b/src/formatter/helpers/location_helpers.js index b5ee98cfc..a78a3e25e 100644 --- a/src/formatter/helpers/location_helpers.js +++ b/src/formatter/helpers/location_helpers.js @@ -1,3 +1,3 @@ -export function formatLocation (obj) { +export function formatLocation(obj) { return `${obj.uri}:${obj.line}` } diff --git a/src/formatter/helpers/pickle_parser.js b/src/formatter/helpers/pickle_parser.js index ee75185a1..856abaf43 100644 --- a/src/formatter/helpers/pickle_parser.js +++ b/src/formatter/helpers/pickle_parser.js @@ -1,6 +1,6 @@ import _ from 'lodash' -export function getScenarioDescription ({ +export function getScenarioDescription({ pickle, scenarioLineToDescriptionMap }) { @@ -11,7 +11,7 @@ export function getScenarioDescription ({ .value() } -export function getStepKeyword ({ pickleStep, stepLineToKeywordMap }) { +export function getStepKeyword({ pickleStep, stepLineToKeywordMap }) { return _.chain(pickleStep.locations) .map(({ line }) => stepLineToKeywordMap[line]) .compact() @@ -19,7 +19,7 @@ export function getStepKeyword ({ pickleStep, stepLineToKeywordMap }) { .value() } -export function getStepLineToPickledStepMap (pickle) { +export function getStepLineToPickledStepMap(pickle) { return _.chain(pickle.steps) .map(step => [_.last(step.locations).line, step]) .fromPairs() diff --git a/src/formatter/helpers/step_result_helpers.js b/src/formatter/helpers/step_result_helpers.js index b54a49e5b..92668b394 100644 --- a/src/formatter/helpers/step_result_helpers.js +++ b/src/formatter/helpers/step_result_helpers.js @@ -2,19 +2,19 @@ import { formatError } from './error_helpers' import Status from '../../status' import indentString from 'indent-string' -function getAmbiguousStepResultMessage ({ colorFns, testStep }) { +function getAmbiguousStepResultMessage({ colorFns, testStep }) { return colorFns.ambiguous(testStep.result.exception) } -function getFailedStepResultMessage ({ colorFns, testStep }) { +function getFailedStepResultMessage({ colorFns, testStep }) { return formatError(testStep.result.exception, colorFns) } -function getPendingStepResultMessage ({ colorFns }) { +function getPendingStepResultMessage({ colorFns }) { return colorFns.pending('Pending') } -export function getStepMessage ({ +export function getStepMessage({ colorFns, keywordType, snippetBuilder, @@ -38,17 +38,14 @@ export function getStepMessage ({ } } -function getUndefinedStepResultMessage ({ +function getUndefinedStepResultMessage({ colorFns, keywordType, snippetBuilder, pickleStep }) { const snippet = snippetBuilder.build({ keywordType, pickleStep }) - const message = - 'Undefined. Implement with the following snippet:' + - '\n\n' + - indentString(snippet, 2) + - '\n' + const message = `${'Undefined. Implement with the following snippet:' + + '\n\n'}${indentString(snippet, 2)}\n` return colorFns.undefined(message) } diff --git a/src/formatter/helpers/summary_helpers.js b/src/formatter/helpers/summary_helpers.js index 73a6d1512..9032bf696 100644 --- a/src/formatter/helpers/summary_helpers.js +++ b/src/formatter/helpers/summary_helpers.js @@ -11,7 +11,7 @@ const STATUS_REPORT_ORDER = [ Status.PASSED ] -export function formatSummary ({ colorFns, testCaseMap, testRun }) { +export function formatSummary({ colorFns, testCaseMap, testRun }) { const testCaseResults = [] const testStepResults = [] _.each(testCaseMap, ({ result, steps }) => { @@ -36,37 +36,33 @@ export function formatSummary ({ colorFns, testCaseMap, testRun }) { return [scenarioSummary, stepSummary, durationSummary].join('\n') } -function getCountSummary ({ colorFns, objects, type }) { +function getCountSummary({ colorFns, objects, type }) { const counts = _.chain(objects) .groupBy('status') .mapValues('length') .value() const total = _.reduce(counts, (memo, value) => memo + value) || 0 - let text = total + ' ' + type + (total === 1 ? '' : 's') + let text = `${total} ${type}${total === 1 ? '' : 's'}` if (total > 0) { const details = [] STATUS_REPORT_ORDER.forEach(status => { if (counts[status] > 0) { - details.push(colorFns[status](counts[status] + ' ' + status)) + details.push(colorFns[status](`${counts[status]} ${status}`)) } }) - text += ' (' + details.join(', ') + ')' + text += ` (${details.join(', ')})` } return text } -function getDuration (milliseconds) { +function getDuration(milliseconds) { const start = new Date(0) const end = new Date(milliseconds) const duration = new Duration(start, end) return ( - duration.minutes + - 'm' + - duration.toString('%S') + - '.' + - duration.toString('%L') + - 's' + - '\n' + `${duration.minutes}m${duration.toString('%S')}.${duration.toString( + '%L' + )}s` + `\n` ) } diff --git a/src/formatter/helpers/summary_helpers_spec.js b/src/formatter/helpers/summary_helpers_spec.js index 925b6693f..219013a8c 100644 --- a/src/formatter/helpers/summary_helpers_spec.js +++ b/src/formatter/helpers/summary_helpers_spec.js @@ -2,9 +2,9 @@ import getColorFns from '../get_color_fns' import { formatSummary } from './summary_helpers' import Status from '../../status' -describe('SummaryHelpers', function () { - describe('formatSummary', function () { - beforeEach(function () { +describe('SummaryHelpers', () => { + describe('formatSummary', () => { + beforeEach(function() { this.testCaseMap = {} this.testRun = { result: { duration: 0 } } this.options = { @@ -14,20 +14,20 @@ describe('SummaryHelpers', function () { } }) - describe('with no test cases', function () { - beforeEach(function () { + describe('with no test cases', () => { + beforeEach(function() { this.result = formatSummary(this.options) }) - it('outputs step totals, scenario totals, and duration', function () { + it('outputs step totals, scenario totals, and duration', function() { expect(this.result).to.contain( '0 scenarios\n' + '0 steps\n' + '0m00.000s\n' ) }) }) - describe('with one passing scenario with one passing step', function () { - beforeEach(function () { + describe('with one passing scenario with one passing step', () => { + beforeEach(function() { this.testCaseMap['a.feature:1'] = { steps: [ { @@ -40,15 +40,15 @@ describe('SummaryHelpers', function () { this.result = formatSummary(this.options) }) - it('outputs the totals and number of each status', function () { + it('outputs the totals and number of each status', function() { expect(this.result).to.contain( '1 scenario (1 passed)\n' + '1 step (1 passed)\n' + '0m00.000s\n' ) }) }) - describe('with one passing scenario with one step and hook', function () { - beforeEach(function () { + describe('with one passing scenario with one step and hook', () => { + beforeEach(function() { this.testCaseMap['a.feature:1'] = { steps: [ { result: { status: Status.PASSED } }, @@ -62,15 +62,15 @@ describe('SummaryHelpers', function () { this.result = formatSummary(this.options) }) - it('filter out the hooks', function () { + it('filter out the hooks', function() { expect(this.result).to.contain( '1 scenario (1 passed)\n' + '1 step (1 passed)\n' + '0m00.000s\n' ) }) }) - describe('with one passing scenario with multiple passing steps', function () { - beforeEach(function () { + describe('with one passing scenario with multiple passing steps', () => { + beforeEach(function() { this.testCaseMap['a.feature:1'] = { steps: [ { @@ -87,15 +87,15 @@ describe('SummaryHelpers', function () { this.result = formatSummary(this.options) }) - it('outputs the totals and number of each status', function () { + it('outputs the totals and number of each status', function() { expect(this.result).to.contain( '1 scenario (1 passed)\n' + '2 steps (2 passed)\n' + '0m00.000s\n' ) }) }) - describe('with one of every kind of scenario', function () { - beforeEach(function () { + describe('with one of every kind of scenario', () => { + beforeEach(function() { this.testCaseMap['a.feature:1'] = { steps: [ { @@ -153,7 +153,7 @@ describe('SummaryHelpers', function () { this.result = formatSummary(this.options) }) - it('outputs the totals and number of each status', function () { + it('outputs the totals and number of each status', function() { expect(this.result).to.contain( '6 scenarios (1 failed, 1 ambiguous, 1 undefined, 1 pending, 1 skipped, 1 passed)\n' + '6 steps (1 failed, 1 ambiguous, 1 undefined, 1 pending, 1 skipped, 1 passed)\n' + @@ -162,39 +162,39 @@ describe('SummaryHelpers', function () { }) }) - describe('with a duration of 123 milliseconds', function () { - beforeEach(function () { + describe('with a duration of 123 milliseconds', () => { + beforeEach(function() { this.testRun.result.duration = 123 this.result = formatSummary(this.options) }) - it('outputs the duration as 0m00.123s', function () { + it('outputs the duration as 0m00.123s', function() { expect(this.result).to.contain( '0 scenarios\n' + '0 steps\n' + '0m00.123s\n' ) }) }) - describe('with a duration of 12.3 seconds', function () { - beforeEach(function () { + describe('with a duration of 12.3 seconds', () => { + beforeEach(function() { this.testRun.result.duration = 123 * 100 this.result = formatSummary(this.options) }) - it('outputs the duration as 0m12.300s', function () { + it('outputs the duration as 0m12.300s', function() { expect(this.result).to.contain( '0 scenarios\n' + '0 steps\n' + '0m12.300s\n' ) }) }) - describe('with a duration of 120.3 seconds', function () { - beforeEach(function () { + describe('with a duration of 120.3 seconds', () => { + beforeEach(function() { this.testRun.result.duration = 123 * 1000 this.result = formatSummary(this.options) }) - it('outputs the duration as 2m03.000s', function () { + it('outputs the duration as 2m03.000s', function() { expect(this.result).to.contain( '0 scenarios\n' + '0 steps\n' + '2m03.000s\n' ) diff --git a/src/formatter/helpers/usage_helpers/index.js b/src/formatter/helpers/usage_helpers/index.js index b0d8cb350..e36d17824 100644 --- a/src/formatter/helpers/usage_helpers/index.js +++ b/src/formatter/helpers/usage_helpers/index.js @@ -2,7 +2,7 @@ import _ from 'lodash' import { formatLocation } from '../location_helpers' import { getStepLineToPickledStepMap } from '../pickle_parser' -function buildEmptyMapping (stepDefinitions) { +function buildEmptyMapping(stepDefinitions) { const mapping = {} stepDefinitions.forEach(stepDefinition => { const location = formatLocation(stepDefinition) @@ -16,7 +16,7 @@ function buildEmptyMapping (stepDefinitions) { return mapping } -function buildMapping ({ stepDefinitions, eventDataCollector }) { +function buildMapping({ stepDefinitions, eventDataCollector }) { const mapping = buildEmptyMapping(stepDefinitions) _.each(eventDataCollector.testCaseMap, testCase => { const { pickle } = eventDataCollector.getTestCaseData( @@ -44,7 +44,7 @@ function buildMapping ({ stepDefinitions, eventDataCollector }) { return mapping } -function invertNumber (key) { +function invertNumber(key) { return obj => { const value = obj[key] if (isFinite(value)) { @@ -54,7 +54,7 @@ function invertNumber (key) { } } -function buildResult (mapping) { +function buildResult(mapping) { return _.chain(mapping) .map(({ line, matches, pattern, uri }) => { const sortedMatches = _.sortBy(matches, [ @@ -72,7 +72,7 @@ function buildResult (mapping) { .value() } -export function getUsage ({ stepDefinitions, eventDataCollector }) { +export function getUsage({ stepDefinitions, eventDataCollector }) { const mapping = buildMapping({ stepDefinitions, eventDataCollector }) return buildResult(mapping) } diff --git a/src/formatter/helpers/usage_helpers/index_spec.js b/src/formatter/helpers/usage_helpers/index_spec.js index 4882b6537..d29e60ff4 100644 --- a/src/formatter/helpers/usage_helpers/index_spec.js +++ b/src/formatter/helpers/usage_helpers/index_spec.js @@ -3,9 +3,9 @@ import EventEmitter from 'events' import Gherkin from 'gherkin' import EventDataCollector from '../event_data_collector' -describe('Usage Helpers', function () { - describe('getUsage', function () { - beforeEach(function () { +describe('Usage Helpers', () => { + describe('getUsage', () => { + beforeEach(function() { this.eventBroadcaster = new EventEmitter() this.eventDataCollector = new EventDataCollector(this.eventBroadcaster) this.stepDefinitions = [] @@ -16,19 +16,19 @@ describe('Usage Helpers', function () { }) }) - describe('no step definitions', function () { - describe('without steps', function () { - beforeEach(function () { + describe('no step definitions', () => { + describe('without steps', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-run-finished') }) - it('returns an empty array', function () { + it('returns an empty array', function() { expect(this.getResult()).to.eql([]) }) }) - describe('with a step', function () { - beforeEach(function () { + describe('with a step', () => { + beforeEach(function() { const events = Gherkin.generateEvents( 'Feature: a\nScenario: b\nWhen abc\nThen ab', 'a.feature' @@ -64,7 +64,7 @@ describe('Usage Helpers', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('returns an empty array', function () { + it('returns an empty array', function() { expect(this.getResult()).to.eql([]) }) }) diff --git a/src/formatter/index.js b/src/formatter/index.js index 9e248d200..fd823848d 100644 --- a/src/formatter/index.js +++ b/src/formatter/index.js @@ -1,7 +1,7 @@ import _ from 'lodash' export default class Formatter { - constructor (options) { + constructor(options) { _.assign( this, _.pick(options, [ diff --git a/src/formatter/json_formatter.js b/src/formatter/json_formatter.js index 9b4052eee..61cb5254b 100644 --- a/src/formatter/json_formatter.js +++ b/src/formatter/json_formatter.js @@ -17,31 +17,29 @@ const { } = PickleParser export default class JsonFormatter extends Formatter { - constructor (options) { + constructor(options) { super(options) options.eventBroadcaster.on('test-run-finished', ::this.onTestRunFinished) } - convertNameToId (obj) { + convertNameToId(obj) { return obj.name.replace(/ /g, '-').toLowerCase() } - formatDataTable (dataTable) { + formatDataTable(dataTable) { return { - rows: dataTable.rows.map(row => { - return { cells: _.map(row.cells, 'value') } - }) + rows: dataTable.rows.map(row => ({ cells: _.map(row.cells, 'value') })) } } - formatDocString (docString) { + formatDocString(docString) { return { content: docString.content, line: docString.location.line } } - formatStepArguments (stepArguments) { + formatStepArguments(stepArguments) { const iterator = buildStepArgumentIterator({ dataTable: this.formatDataTable.bind(this), docString: this.formatDocString.bind(this) @@ -49,7 +47,7 @@ export default class JsonFormatter extends Formatter { return _.map(stepArguments, iterator) } - onTestRunFinished () { + onTestRunFinished() { const groupedTestCases = {} _.each(this.eventDataCollector.testCaseMap, testCase => { const { sourceLocation: { uri } } = testCase @@ -92,7 +90,7 @@ export default class JsonFormatter extends Formatter { this.log(JSON.stringify(features, null, 2)) } - getFeatureData (feature, uri) { + getFeatureData(feature, uri) { return { description: feature.description, keyword: feature.keyword, @@ -104,14 +102,14 @@ export default class JsonFormatter extends Formatter { } } - getScenarioData ({ featureId, pickle, scenarioLineToDescriptionMap }) { + getScenarioData({ featureId, pickle, scenarioLineToDescriptionMap }) { const description = getScenarioDescription({ pickle, scenarioLineToDescriptionMap }) return { description, - id: featureId + ';' + this.convertNameToId(pickle), + id: `${featureId};${this.convertNameToId(pickle)}`, keyword: 'Scenario', line: pickle.locations[0].line, name: pickle.name, @@ -120,7 +118,7 @@ export default class JsonFormatter extends Formatter { } } - getStepData ({ + getStepData({ isBeforeHook, stepLineToKeywordMap, stepLineToPickledStepMap, @@ -152,19 +150,18 @@ export default class JsonFormatter extends Formatter { } } if (_.size(testStep.attachments) > 0) { - data.embeddings = testStep.attachments.map(attachment => { - return { - data: attachment.data, - mime_type: attachment.media.type - } - }) + data.embeddings = testStep.attachments.map(attachment => ({ + data: attachment.data, + mime_type: attachment.media.type + })) } return data } - getTags (obj) { - return _.map(obj.tags, tagData => { - return { name: tagData.name, line: tagData.location.line } - }) + getTags(obj) { + return _.map(obj.tags, tagData => ({ + name: tagData.name, + line: tagData.location.line + })) } } diff --git a/src/formatter/json_formatter_spec.js b/src/formatter/json_formatter_spec.js index 5eb0d594b..0bfa18498 100644 --- a/src/formatter/json_formatter_spec.js +++ b/src/formatter/json_formatter_spec.js @@ -4,8 +4,8 @@ import EventEmitter from 'events' import Gherkin from 'gherkin' import { EventDataCollector } from './helpers' -describe('JsonFormatter', function () { - beforeEach(function () { +describe('JsonFormatter', () => { + beforeEach(function() { this.eventBroadcaster = new EventEmitter() this.output = '' const logFn = data => { @@ -18,18 +18,18 @@ describe('JsonFormatter', function () { }) }) - describe('no features', function () { - beforeEach(function () { + describe('no features', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs an empty array', function () { + it('outputs an empty array', function() { expect(JSON.parse(this.output)).to.eql([]) }) }) - describe('one scenario with one step', function () { - beforeEach(function () { + describe('one scenario with one step', () => { + beforeEach(function() { const events = Gherkin.generateEvents( '@tag1 @tag2\n' + 'Feature: my feature\n' + @@ -52,8 +52,8 @@ describe('JsonFormatter', function () { this.testCase = { sourceLocation: { uri: 'a.feature', line: 4 } } }) - describe('passed', function () { - beforeEach(function () { + describe('passed', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -74,7 +74,7 @@ describe('JsonFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the feature', function () { + it('outputs the feature', function() { expect(JSON.parse(this.output)).to.eql([ { description: 'my feature description', @@ -112,8 +112,8 @@ describe('JsonFormatter', function () { }) }) - describe('failed', function () { - beforeEach(function () { + describe('failed', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -134,7 +134,7 @@ describe('JsonFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('includes the error message', function () { + it('includes the error message', function() { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].result).to.eql({ status: 'failed', @@ -144,8 +144,8 @@ describe('JsonFormatter', function () { }) }) - describe('with a step definition', function () { - beforeEach(function () { + describe('with a step definition', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -167,7 +167,7 @@ describe('JsonFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step with a match attribute', function () { + it('outputs the step with a match attribute', function() { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].match).to.eql({ location: 'steps.js:10' @@ -175,8 +175,8 @@ describe('JsonFormatter', function () { }) }) - describe('with hooks', function () { - beforeEach(function () { + describe('with hooks', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -199,7 +199,7 @@ describe('JsonFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the before hook with special properties', function () { + it('outputs the before hook with special properties', function() { const features = JSON.parse(this.output) const beforeHook = features[0].elements[0].steps[0] expect(beforeHook).to.not.have.ownProperty('line') @@ -207,7 +207,7 @@ describe('JsonFormatter', function () { expect(beforeHook.hidden).to.eql(true) }) - it('outputs the after hook with special properties', function () { + it('outputs the after hook with special properties', function() { const features = JSON.parse(this.output) const beforeHook = features[0].elements[0].steps[2] expect(beforeHook).to.not.have.ownProperty('line') @@ -216,8 +216,8 @@ describe('JsonFormatter', function () { }) }) - describe('with attachments', function () { - beforeEach(function () { + describe('with attachments', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -250,7 +250,7 @@ describe('JsonFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step with embeddings', function () { + it('outputs the step with embeddings', function() { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].embeddings).to.eql([ { data: 'first data', mime_type: 'first media type' }, @@ -260,8 +260,8 @@ describe('JsonFormatter', function () { }) }) - describe('one scenario with one step with a doc string', function () { - beforeEach(function () { + describe('one scenario with one step with a doc string', () => { + beforeEach(function() { const events = Gherkin.generateEvents( 'Feature: my feature\n' + ' Scenario: my scenario\n' + @@ -303,7 +303,7 @@ describe('JsonFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the doc string as a step argument', function () { + it('outputs the doc string as a step argument', function() { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].arguments).to.eql([ { @@ -314,8 +314,8 @@ describe('JsonFormatter', function () { }) }) - describe('one scenario with one step with a data table string', function () { - beforeEach(function () { + describe('one scenario with one step with a data table string', () => { + beforeEach(function() { const events = Gherkin.generateEvents( 'Feature: my feature\n' + ' Scenario: my scenario\n' + @@ -357,7 +357,7 @@ describe('JsonFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the data table as a step argument', function () { + it('outputs the data table as a step argument', function() { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].arguments).to.eql([ { diff --git a/src/formatter/progress_bar_formatter.js b/src/formatter/progress_bar_formatter.js index af10621c3..521fe706a 100644 --- a/src/formatter/progress_bar_formatter.js +++ b/src/formatter/progress_bar_formatter.js @@ -4,7 +4,7 @@ import ProgressBar from 'progress' // Inspired by https://github.com/thekompanee/fuubar and https://github.com/martinciu/fuubar-cucumber export default class ProgressBarFormatter extends Formatter { - constructor (options) { + constructor(options) { super(options) options.eventBroadcaster .on('pickle-accepted', ::this.incrementStepCount) @@ -16,11 +16,11 @@ export default class ProgressBarFormatter extends Formatter { this.issueCount = 0 } - incrementStepCount ({ pickle }) { + incrementStepCount({ pickle }) { this.numberOfSteps += pickle.steps.length } - initializeProgressBar () { + initializeProgressBar() { this.progressBar = new ProgressBar(':current/:total steps [:bar] ', { clear: true, incomplete: ' ', @@ -30,14 +30,14 @@ export default class ProgressBarFormatter extends Formatter { }) } - logProgress ({ index, testCase: { sourceLocation } }) { + logProgress({ index, testCase: { sourceLocation } }) { const { testCase } = this.eventDataCollector.getTestCaseData(sourceLocation) if (testCase.steps[index].sourceLocation) { this.progressBar.tick() } } - logErrorIfNeeded ({ sourceLocation, result }) { + logErrorIfNeeded({ sourceLocation, result }) { if (isIssue(result.status)) { this.issueCount += 1 const { @@ -58,7 +58,7 @@ export default class ProgressBarFormatter extends Formatter { } } - logSummary (testRun) { + logSummary(testRun) { this.log( formatSummary({ colorFns: this.colorFns, diff --git a/src/formatter/progress_bar_formatter_spec.js b/src/formatter/progress_bar_formatter_spec.js index b578950fd..eaf03875d 100644 --- a/src/formatter/progress_bar_formatter_spec.js +++ b/src/formatter/progress_bar_formatter_spec.js @@ -5,8 +5,8 @@ import { EventEmitter } from 'events' import Gherkin from 'gherkin' import { EventDataCollector } from './helpers' -describe('ProgressBarFormatter', function () { - beforeEach(function () { +describe('ProgressBarFormatter', () => { + beforeEach(function() { this.eventBroadcaster = new EventEmitter() this.output = '' const logFn = data => { @@ -24,8 +24,8 @@ describe('ProgressBarFormatter', function () { }) }) - describe('pickle-accepted, test-case-started', function () { - beforeEach(function () { + describe('pickle-accepted, test-case-started', () => { + beforeEach(function() { this.eventBroadcaster.emit('pickle-accepted', { pickle: { locations: [{ line: 2 }], steps: [1, 2, 3] }, uri: 'path/to/feature' @@ -37,13 +37,13 @@ describe('ProgressBarFormatter', function () { this.eventBroadcaster.emit('test-case-started') }) - it('initializes a progress bar with the total number of steps', function () { + it('initializes a progress bar with the total number of steps', function() { expect(this.progressBarFormatter.progressBar.total).to.eql(5) }) }) - describe('test-step-finished', function () { - beforeEach(function () { + describe('test-step-finished', () => { + beforeEach(function() { this.progressBarFormatter.progressBar = { interrupt: sinon.stub(), tick: sinon.stub() @@ -60,8 +60,8 @@ describe('ProgressBarFormatter', function () { }) }) - describe('step is a hook', function () { - beforeEach(function () { + describe('step is a hook', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: { @@ -71,13 +71,13 @@ describe('ProgressBarFormatter', function () { }) }) - it('does not increase the progress bar percentage', function () { + it('does not increase the progress bar percentage', function() { expect(this.progressBarFormatter.progressBar.tick).to.have.callCount(0) }) }) - describe('step is a normal step', function () { - beforeEach(function () { + describe('step is a normal step', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-step-finished', { index: 1, testCase: { @@ -87,14 +87,14 @@ describe('ProgressBarFormatter', function () { }) }) - it('increases the progress bar percentage', function () { + it('increases the progress bar percentage', function() { expect(this.progressBarFormatter.progressBar.tick).to.have.callCount(1) }) }) }) - describe('test-case-finished', function () { - beforeEach(function () { + describe('test-case-finished', () => { + beforeEach(function() { this.progressBarFormatter.progressBar = { interrupt: sinon.stub(), tick: sinon.stub() @@ -116,8 +116,8 @@ describe('ProgressBarFormatter', function () { this.testCase = { sourceLocation: { uri: 'a.feature', line: 2 } } }) - describe('ambiguous', function () { - beforeEach(function () { + describe('ambiguous', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -143,13 +143,15 @@ describe('ProgressBarFormatter', function () { }) }) - it('prints the error', function () { - expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(1) + it('prints the error', function() { + expect( + this.progressBarFormatter.progressBar.interrupt + ).to.have.callCount(1) }) }) - describe('failed', function () { - beforeEach(function () { + describe('failed', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -170,13 +172,15 @@ describe('ProgressBarFormatter', function () { }) }) - it('prints the error', function () { - expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(1) + it('prints the error', function() { + expect( + this.progressBarFormatter.progressBar.interrupt + ).to.have.callCount(1) }) }) - describe('passed', function () { - beforeEach(function () { + describe('passed', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -197,13 +201,15 @@ describe('ProgressBarFormatter', function () { }) }) - it('does not print anything', function () { - expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(0) + it('does not print anything', function() { + expect( + this.progressBarFormatter.progressBar.interrupt + ).to.have.callCount(0) }) }) - describe('pending', function () { - beforeEach(function () { + describe('pending', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -224,13 +230,15 @@ describe('ProgressBarFormatter', function () { }) }) - it('prints the warning', function () { - expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(1) + it('prints the warning', function() { + expect( + this.progressBarFormatter.progressBar.interrupt + ).to.have.callCount(1) }) }) - describe('skipped', function () { - beforeEach(function () { + describe('skipped', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -251,13 +259,15 @@ describe('ProgressBarFormatter', function () { }) }) - it('does not print anything', function () { - expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(0) + it('does not print anything', function() { + expect( + this.progressBarFormatter.progressBar.interrupt + ).to.have.callCount(0) }) }) - describe('undefined', function () { - beforeEach(function () { + describe('undefined', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -277,20 +287,22 @@ describe('ProgressBarFormatter', function () { }) }) - it('prints the warning', function () { - expect(this.progressBarFormatter.progressBar.interrupt).to.have.callCount(0) + it('prints the warning', function() { + expect( + this.progressBarFormatter.progressBar.interrupt + ).to.have.callCount(0) }) }) }) - describe('test-run-finished', function () { - beforeEach(function () { + describe('test-run-finished', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-run-finished', { result: { duration: 0 } }) }) - it('outputs step totals, scenario totals, and duration', function () { + it('outputs step totals, scenario totals, and duration', function() { expect(this.output).to.contain( '0 scenarios\n' + '0 steps\n' + '0m00.000s\n' ) diff --git a/src/formatter/progress_formatter.js b/src/formatter/progress_formatter.js index a38ddd1ac..c2d096d69 100644 --- a/src/formatter/progress_formatter.js +++ b/src/formatter/progress_formatter.js @@ -11,7 +11,7 @@ const STATUS_CHARACTER_MAPPING = { } export default class ProgressFormatter extends SummaryFormatter { - constructor (options) { + constructor(options) { options.eventBroadcaster.on('test-run-finished', () => { this.log('\n\n') }) @@ -19,7 +19,7 @@ export default class ProgressFormatter extends SummaryFormatter { options.eventBroadcaster.on('test-step-finished', ::this.logProgress) } - logProgress ({ result }) { + logProgress({ result }) { const { status } = result const character = this.colorFns[status](STATUS_CHARACTER_MAPPING[status]) this.log(character) diff --git a/src/formatter/progress_formatter_spec.js b/src/formatter/progress_formatter_spec.js index e66ad5137..b32dcf34e 100644 --- a/src/formatter/progress_formatter_spec.js +++ b/src/formatter/progress_formatter_spec.js @@ -4,8 +4,8 @@ import Status from '../status' import { EventEmitter } from 'events' import { EventDataCollector } from './helpers' -describe('ProgressFormatter', function () { - beforeEach(function () { +describe('ProgressFormatter', () => { + beforeEach(function() { this.eventBroadcaster = new EventEmitter() this.output = '' const colorFns = getColorFns(false) @@ -20,8 +20,8 @@ describe('ProgressFormatter', function () { }) }) - describe('test step finished', function () { - beforeEach(function () { + describe('test step finished', () => { + beforeEach(function() { this.testCase = { sourceLocation: { uri: 'path/to/feature', line: 1 } } this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, @@ -29,8 +29,8 @@ describe('ProgressFormatter', function () { }) }) - describe('ambiguous', function () { - beforeEach(function () { + describe('ambiguous', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.AMBIGUOUS }, @@ -38,13 +38,13 @@ describe('ProgressFormatter', function () { }) }) - it('outputs A', function () { + it('outputs A', function() { expect(this.output).to.eql('A') }) }) - describe('failed', function () { - beforeEach(function () { + describe('failed', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.FAILED }, @@ -52,13 +52,13 @@ describe('ProgressFormatter', function () { }) }) - it('outputs F', function () { + it('outputs F', function() { expect(this.output).to.eql('F') }) }) - describe('passed', function () { - beforeEach(function () { + describe('passed', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.PASSED }, @@ -66,13 +66,13 @@ describe('ProgressFormatter', function () { }) }) - it('outputs .', function () { + it('outputs .', function() { expect(this.output).to.eql('.') }) }) - describe('pending', function () { - beforeEach(function () { + describe('pending', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.PENDING }, @@ -80,13 +80,13 @@ describe('ProgressFormatter', function () { }) }) - it('outputs P', function () { + it('outputs P', function() { expect(this.output).to.eql('P') }) }) - describe('skipped', function () { - beforeEach(function () { + describe('skipped', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.SKIPPED }, @@ -94,13 +94,13 @@ describe('ProgressFormatter', function () { }) }) - it('outputs -', function () { + it('outputs -', function() { expect(this.output).to.eql('-') }) }) - describe('undefined', function () { - beforeEach(function () { + describe('undefined', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.UNDEFINED }, @@ -108,20 +108,20 @@ describe('ProgressFormatter', function () { }) }) - it('outputs U', function () { + it('outputs U', function() { expect(this.output).to.eql('U') }) }) }) - describe('test run finished', function () { - beforeEach(function () { + describe('test run finished', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-run-finished', { result: { duration: 0 } }) }) - it('outputs two newlines before the summary', function () { + it('outputs two newlines before the summary', function() { expect(this.output).to.eql('\n\n0 scenarios\n0 steps\n0m00.000s\n') }) }) diff --git a/src/formatter/rerun_formatter.js b/src/formatter/rerun_formatter.js index 8096ad5a5..5e30624c4 100644 --- a/src/formatter/rerun_formatter.js +++ b/src/formatter/rerun_formatter.js @@ -5,7 +5,7 @@ import Status from '../status' const DEFAULT_SEPARATOR = '\n' export default class RerunFormatter extends Formatter { - constructor (options) { + constructor(options) { super(options) options.eventBroadcaster .on('test-case-finished', ::this.storeFailedTestCases) @@ -14,7 +14,7 @@ export default class RerunFormatter extends Formatter { this.separator = _.get(options, 'rerun.separator', DEFAULT_SEPARATOR) } - storeFailedTestCases ({ sourceLocation: { line, uri }, result: { status } }) { + storeFailedTestCases({ sourceLocation: { line, uri }, result: { status } }) { if (status !== Status.PASSED) { if (!this.mapping[uri]) { this.mapping[uri] = [] @@ -23,9 +23,9 @@ export default class RerunFormatter extends Formatter { } } - logFailedTestCases () { + logFailedTestCases() { const text = _.chain(this.mapping) - .map((lines, uri) => uri + ':' + lines.join(':')) + .map((lines, uri) => `${uri}:${lines.join(':')}`) .join(this.separator) .value() this.log(text) diff --git a/src/formatter/rerun_formatter_spec.js b/src/formatter/rerun_formatter_spec.js index e19ea016f..b1f6ec10f 100644 --- a/src/formatter/rerun_formatter_spec.js +++ b/src/formatter/rerun_formatter_spec.js @@ -4,7 +4,7 @@ import RerunFormatter from './rerun_formatter' import Status from '../status' import { EventEmitter } from 'events' -function prepareFormatter (options = {}) { +function prepareFormatter(options = {}) { this.output = '' const logFn = data => { this.output += data @@ -19,22 +19,22 @@ function prepareFormatter (options = {}) { }) } -describe('RerunFormatter', function () { +describe('RerunFormatter', () => { beforeEach(prepareFormatter) - describe('with no scenarios', function () { - beforeEach(function () { + describe('with no scenarios', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs nothing', function () { + it('outputs nothing', function() { expect(this.output).to.eql('') }) }) _.each([Status.PASSED], status => { - describe('with one ' + status + ' scenario', function () { - beforeEach(function () { + describe(`with one ${status} scenario`, () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature1Path, line: 1 }, result: { status } @@ -42,7 +42,7 @@ describe('RerunFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs nothing', function () { + it('outputs nothing', function() { expect(this.output).to.eql('') }) }) @@ -57,8 +57,8 @@ describe('RerunFormatter', function () { Status.UNDEFINED ], status => { - describe('with one ' + status + ' scenario', function () { - beforeEach(function () { + describe(`with one ${status} scenario`, () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature1Path, line: 1 }, result: { status } @@ -66,15 +66,15 @@ describe('RerunFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the reference needed to run the scenario again', function () { + it('outputs the reference needed to run the scenario again', function() { expect(this.output).to.eql(`${this.feature1Path}:1`) }) }) } ) - describe('with two failing scenarios in the same file', function () { - beforeEach(function () { + describe('with two failing scenarios in the same file', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature1Path, line: 1 }, result: { status: Status.FAILED } @@ -86,7 +86,7 @@ describe('RerunFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the reference needed to run the scenarios again', function () { + it('outputs the reference needed to run the scenarios again', function() { expect(this.output).to.eql(`${this.feature1Path}:1:2`) }) }) @@ -98,9 +98,9 @@ describe('RerunFormatter', function () { { separator: { opt: ' ', expected: ' ' }, label: 'space' } ], ({ separator, label }) => { - describe('using ' + label + ' separator', function () { - describe('with two failing scenarios in different files', function () { - beforeEach(function () { + describe(`using ${label} separator`, () => { + describe('with two failing scenarios in different files', () => { + beforeEach(function() { prepareFormatter.apply(this, [ { rerun: { separator: separator.opt } } ]) @@ -116,11 +116,11 @@ describe('RerunFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the references needed to run the scenarios again', function () { + it('outputs the references needed to run the scenarios again', function() { expect(this.output).to.eql( - `${this.feature1Path}:1` + - separator.expected + - `${this.feature2Path}:2` + `${this.feature1Path}:1${separator.expected}${ + this.feature2Path + }:2` ) }) }) diff --git a/src/formatter/snippets_formatter.js b/src/formatter/snippets_formatter.js index 2d34e9f89..fa9362d08 100644 --- a/src/formatter/snippets_formatter.js +++ b/src/formatter/snippets_formatter.js @@ -3,7 +3,7 @@ import Status from '../status' import { KeywordType, getStepKeywordType } from './helpers' export default class SnippetsFormatter extends Formatter { - constructor (options) { + constructor(options) { super(options) options.eventBroadcaster.on( 'test-step-finished', @@ -11,7 +11,7 @@ export default class SnippetsFormatter extends Formatter { ) } - logUndefinedTestStepSnippet ({ testCase: { sourceLocation }, index, result }) { + logUndefinedTestStepSnippet({ testCase: { sourceLocation }, index, result }) { if (result.status === Status.UNDEFINED) { const { gherkinDocument, @@ -32,11 +32,11 @@ export default class SnippetsFormatter extends Formatter { previousKeywordType }) const snippet = this.snippetBuilder.build({ keywordType, pickleStep }) - this.log(snippet + '\n\n') + this.log(`${snippet}\n\n`) } } - getPreviousKeywordType ({ gherkinDocument, testCase, index }) { + getPreviousKeywordType({ gherkinDocument, testCase, index }) { let previousKeywordType = KeywordType.PRECONDITION for (let i = 0; i < index; i += 1) { const { gherkinKeyword } = this.eventDataCollector.getTestStepData({ diff --git a/src/formatter/step_definition_snippet_builder/index.js b/src/formatter/step_definition_snippet_builder/index.js index b1cbd1bf1..66acdd624 100644 --- a/src/formatter/step_definition_snippet_builder/index.js +++ b/src/formatter/step_definition_snippet_builder/index.js @@ -3,14 +3,14 @@ import { KeywordType } from '../helpers' import { buildStepArgumentIterator } from '../../step_arguments' export default class StepDefinitionSnippetBuilder { - constructor ({ snippetSyntax, parameterTypeRegistry }) { + constructor({ snippetSyntax, parameterTypeRegistry }) { this.snippetSyntax = snippetSyntax this.cucumberExpressionGenerator = new CucumberExpressionGenerator( parameterTypeRegistry ) } - build ({ keywordType, pickleStep }) { + build({ keywordType, pickleStep }) { const comment = 'Write code here that turns the phrase above into concrete actions' const functionName = this.getFunctionName(keywordType) @@ -27,7 +27,7 @@ export default class StepDefinitionSnippetBuilder { }) } - getFunctionName (keywordType) { + getFunctionName(keywordType) { switch (keywordType) { case KeywordType.EVENT: return 'When' @@ -38,7 +38,7 @@ export default class StepDefinitionSnippetBuilder { } } - getStepParameterNames (step) { + getStepParameterNames(step) { const iterator = buildStepArgumentIterator({ dataTable: () => 'dataTable', docString: () => 'docString' diff --git a/src/formatter/step_definition_snippet_builder/index_spec.js b/src/formatter/step_definition_snippet_builder/index_spec.js index ef964e004..ab1e81418 100644 --- a/src/formatter/step_definition_snippet_builder/index_spec.js +++ b/src/formatter/step_definition_snippet_builder/index_spec.js @@ -2,8 +2,8 @@ import { KeywordType } from '../helpers' import StepDefinitionSnippetBuilder from './' import TransformLookupBuilder from '../../support_code_library_builder/parameter_type_registry_builder' -describe('StepDefinitionSnippetBuilder', function () { - beforeEach(function () { +describe('StepDefinitionSnippetBuilder', () => { + beforeEach(function() { this.snippetSyntax = createMock(['build']) this.transformsLookup = TransformLookupBuilder.build() this.snippetBuilder = new StepDefinitionSnippetBuilder({ @@ -12,8 +12,8 @@ describe('StepDefinitionSnippetBuilder', function () { }) }) - describe('build()', function () { - beforeEach(function () { + describe('build()', () => { + beforeEach(function() { this.input = { keywordType: KeywordType.PRECONDITION, pickleStep: { @@ -23,79 +23,79 @@ describe('StepDefinitionSnippetBuilder', function () { } }) - describe('step is an precondition step', function () { - beforeEach(function () { + describe('step is an precondition step', () => { + beforeEach(function() { this.input.keywordType = KeywordType.PRECONDITION this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('uses Given as the function name', function () { + it('uses Given as the function name', function() { expect(this.arg.functionName).to.eql('Given') }) }) - describe('step is an event step', function () { - beforeEach(function () { + describe('step is an event step', () => { + beforeEach(function() { this.input.keywordType = KeywordType.EVENT this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('uses When as the function name', function () { + it('uses When as the function name', function() { expect(this.arg.functionName).to.eql('When') }) }) - describe('step is an outcome step', function () { - beforeEach(function () { + describe('step is an outcome step', () => { + beforeEach(function() { this.input.keywordType = KeywordType.OUTCOME this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('uses Then as the function name', function () { + it('uses Then as the function name', function() { expect(this.arg.functionName).to.eql('Then') }) }) - describe('step has simple name', function () { - beforeEach(function () { + describe('step has simple name', () => { + beforeEach(function() { this.input.pickleStep.text = 'abc' this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('adds the proper generated expression', function () { - let generatedExpression = this.arg.generatedExpressions[0] + it('adds the proper generated expression', function() { + const generatedExpression = this.arg.generatedExpressions[0] expect(generatedExpression.source).to.eql('abc') expect(generatedExpression.parameterNames).to.eql([]) }) }) - describe('step name has a quoted string', function () { - beforeEach(function () { + describe('step name has a quoted string', () => { + beforeEach(function() { this.input.pickleStep.text = 'abc "def" ghi' this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('adds the proper generated expression', function () { - let generatedExpression = this.arg.generatedExpressions[0] + it('adds the proper generated expression', function() { + const generatedExpression = this.arg.generatedExpressions[0] expect(generatedExpression.source).to.eql('abc {string} ghi') expect(generatedExpression.parameterNames).to.eql(['string']) }) }) - describe('step name has multiple quoted strings', function () { - beforeEach(function () { + describe('step name has multiple quoted strings', () => { + beforeEach(function() { this.input.pickleStep.text = 'abc "def" ghi "jkl" mno' this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('adds the proper generated expression', function () { - let generatedExpression = this.arg.generatedExpressions[0] + it('adds the proper generated expression', function() { + const generatedExpression = this.arg.generatedExpressions[0] expect(generatedExpression.source).to.eql( 'abc {string} ghi {string} mno' ) @@ -103,51 +103,51 @@ describe('StepDefinitionSnippetBuilder', function () { }) }) - describe('step name has a standalone number', function () { - beforeEach(function () { + describe('step name has a standalone number', () => { + beforeEach(function() { this.input.pickleStep.text = 'abc 123 def' this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('adds the proper generated expression', function () { - let generatedExpression = this.arg.generatedExpressions[0] + it('adds the proper generated expression', function() { + const generatedExpression = this.arg.generatedExpressions[0] expect(generatedExpression.source).to.eql('abc {int} def') expect(generatedExpression.parameterNames).to.eql(['int']) }) }) - describe('step has no arguments', function () { - beforeEach(function () { + describe('step has no arguments', () => { + beforeEach(function() { this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('passes no step parameter names', function () { + it('passes no step parameter names', function() { expect(this.arg.stepParameterNames).to.eql([]) }) }) - describe('step has a data table argument', function () { - beforeEach(function () { + describe('step has a data table argument', () => { + beforeEach(function() { this.input.pickleStep.arguments = [{ rows: [] }] this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('passes dataTable as a step parameter name', function () { + it('passes dataTable as a step parameter name', function() { expect(this.arg.stepParameterNames).to.eql(['dataTable']) }) }) - describe('step has a doc string argument', function () { - beforeEach(function () { + describe('step has a doc string argument', () => { + beforeEach(function() { this.input.pickleStep.arguments = [{ content: '' }] this.result = this.snippetBuilder.build(this.input) this.arg = this.snippetSyntax.build.firstCall.args[0] }) - it('passes docString as a step parameter name', function () { + it('passes docString as a step parameter name', function() { expect(this.arg.stepParameterNames).to.eql(['docString']) }) }) diff --git a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js index 23fc1fc37..a965ebb6b 100644 --- a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +++ b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js @@ -1,11 +1,11 @@ const CALLBACK_NAME = 'callback' export default class JavaScriptSnippetSyntax { - constructor (snippetInterface) { + constructor(snippetInterface) { this.snippetInterface = snippetInterface } - build ({ comment, generatedExpressions, functionName, stepParameterNames }) { + build({ comment, generatedExpressions, functionName, stepParameterNames }) { let functionKeyword = 'function ' if (this.snippetInterface === 'generator') { functionKeyword += '*' @@ -27,25 +27,17 @@ export default class JavaScriptSnippetSyntax { if (this.snippetInterface === 'callback') { allParameterNames.push(CALLBACK_NAME) } - return ( - prefix + - functionName + - "('" + - generatedExpression.source.replace(/'/g, "\\'") + - "', " + - functionKeyword + - '(' + - allParameterNames.join(', ') + - ') {\n' - ) + return `${prefix + functionName}('${generatedExpression.source.replace( + /'/g, + "\\'" + )}', ${functionKeyword}(${allParameterNames.join(', ')}) {\n` } ) return ( - definitionChoices.join('') + - ` // ${comment}\n` + + `${definitionChoices.join('')} // ${comment}\n` + ` ${implementation}\n` + - '});' + `});` ) } } diff --git a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js index 034333739..3700b5147 100644 --- a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js +++ b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js @@ -1,13 +1,13 @@ import JavascriptSnippetSyntax from './javascript_snippet_syntax' -describe('JavascriptSnippetSyntax', function () { - describe('build()', function () { - describe('callback interface', function () { - beforeEach(function () { +describe('JavascriptSnippetSyntax', () => { + describe('build()', () => { + describe('callback interface', () => { + beforeEach(function() { this.syntax = new JavascriptSnippetSyntax('callback') }) - it('returns the proper snippet', function () { + it('returns the proper snippet', function() { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', @@ -28,12 +28,12 @@ describe('JavascriptSnippetSyntax', function () { }) }) - describe('generator interface', function () { - beforeEach(function () { + describe('generator interface', () => { + beforeEach(function() { this.syntax = new JavascriptSnippetSyntax('generator') }) - it('returns the proper snippet', function () { + it('returns the proper snippet', function() { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', @@ -54,12 +54,12 @@ describe('JavascriptSnippetSyntax', function () { }) }) - describe('promise interface', function () { - beforeEach(function () { + describe('promise interface', () => { + beforeEach(function() { this.syntax = new JavascriptSnippetSyntax('promise') }) - it('returns the proper snippet', function () { + it('returns the proper snippet', function() { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', @@ -80,12 +80,12 @@ describe('JavascriptSnippetSyntax', function () { }) }) - describe('synchronous interface', function () { - beforeEach(function () { + describe('synchronous interface', () => { + beforeEach(function() { this.syntax = new JavascriptSnippetSyntax('synchronous') }) - it('returns the proper snippet', function () { + it('returns the proper snippet', function() { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', @@ -106,12 +106,12 @@ describe('JavascriptSnippetSyntax', function () { }) }) - describe('pattern contains single quote', function () { - beforeEach(function () { + describe('pattern contains single quote', () => { + beforeEach(function() { this.syntax = new JavascriptSnippetSyntax('synchronous') }) - it('returns the proper snippet', function () { + it('returns the proper snippet', function() { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', @@ -132,12 +132,12 @@ describe('JavascriptSnippetSyntax', function () { }) }) - describe('multiple patterns', function () { - beforeEach(function () { + describe('multiple patterns', () => { + beforeEach(function() { this.syntax = new JavascriptSnippetSyntax('synchronous') }) - it('returns the snippet with the other choices commented out', function () { + it('returns the snippet with the other choices commented out', function() { const actual = this.syntax.build({ comment: 'comment', functionName: 'functionName', diff --git a/src/formatter/summary_formatter.js b/src/formatter/summary_formatter.js index 5125d502e..9729456ee 100644 --- a/src/formatter/summary_formatter.js +++ b/src/formatter/summary_formatter.js @@ -4,23 +4,23 @@ import Formatter from './' import Status from '../status' export default class SummaryFormatter extends Formatter { - constructor (options) { + constructor(options) { super(options) options.eventBroadcaster.on('test-run-finished', ::this.logSummary) } - isTestCaseFailure (testCase) { + isTestCaseFailure(testCase) { return _.includes([Status.AMBIGUOUS, Status.FAILED], testCase.result.status) } - isTestCaseWarning (testCase) { + isTestCaseWarning(testCase) { return _.includes( [Status.PENDING, Status.UNDEFINED], testCase.result.status ) } - logSummary (testRun) { + logSummary(testRun) { const failures = [] const warnings = [] _.each(this.eventDataCollector.testCaseMap, testCase => { @@ -45,8 +45,8 @@ export default class SummaryFormatter extends Formatter { ) } - logIssues ({ issues, title }) { - this.log(title + ':\n\n') + logIssues({ issues, title }) { + this.log(`${title}:\n\n`) issues.forEach((testCase, index) => { const { gherkinDocument, diff --git a/src/formatter/summary_formatter_spec.js b/src/formatter/summary_formatter_spec.js index 2e934a6aa..8dba3468d 100644 --- a/src/formatter/summary_formatter_spec.js +++ b/src/formatter/summary_formatter_spec.js @@ -6,8 +6,8 @@ import { EventEmitter } from 'events' import Gherkin from 'gherkin' import { EventDataCollector } from './helpers' -describe('SummaryFormatter', function () { - beforeEach(function () { +describe('SummaryFormatter', () => { + beforeEach(function() { this.output = '' const logFn = data => { this.output += data @@ -22,8 +22,8 @@ describe('SummaryFormatter', function () { }) }) - describe('issues', function () { - beforeEach(function () { + describe('issues', () => { + beforeEach(function() { const events = Gherkin.generateEvents( 'Feature: a\nScenario: b\nGiven a step', 'a.feature' @@ -41,8 +41,8 @@ describe('SummaryFormatter', function () { this.testCase = { sourceLocation: { uri: 'a.feature', line: 2 } } }) - describe('with a failing scenario', function () { - beforeEach(function () { + describe('with a failing scenario', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -66,7 +66,7 @@ describe('SummaryFormatter', function () { }) }) - it('logs the issue', function () { + it('logs the issue', function() { expect(this.output).to.eql( 'Failures:\n' + '\n' + @@ -81,8 +81,8 @@ describe('SummaryFormatter', function () { }) }) - describe('with an ambiguous step', function () { - beforeEach(function () { + describe('with an ambiguous step', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -111,7 +111,7 @@ describe('SummaryFormatter', function () { }) }) - it('logs the issue', function () { + it('logs the issue', function() { expect(this.output).to.eql( 'Failures:\n' + '\n' + @@ -128,8 +128,8 @@ describe('SummaryFormatter', function () { }) }) - describe('with an undefined step', function () { - beforeEach(function () { + describe('with an undefined step', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -152,7 +152,7 @@ describe('SummaryFormatter', function () { }) }) - it('logs the issue', function () { + it('logs the issue', function() { expect(this.output).to.eql( 'Warnings:\n' + '\n' + @@ -170,8 +170,8 @@ describe('SummaryFormatter', function () { }) }) - describe('with a pending step', function () { - beforeEach(function () { + describe('with a pending step', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, steps: [ @@ -195,7 +195,7 @@ describe('SummaryFormatter', function () { }) }) - it('logs the issue', function () { + it('logs the issue', function() { expect(this.output).to.eql( 'Warnings:\n' + '\n' + @@ -210,39 +210,39 @@ describe('SummaryFormatter', function () { }) }) - describe('summary', function () { - describe('with a duration of 123 milliseconds', function () { - beforeEach(function () { + describe('summary', () => { + describe('with a duration of 123 milliseconds', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-run-finished', { result: { duration: 123 } }) }) - it('outputs scenario totals, step totals, and duration', function () { + it('outputs scenario totals, step totals, and duration', function() { expect(this.output).to.contain('0 scenarios\n0 steps\n0m00.123s\n') }) }) - describe('with a duration of 12.3 seconds', function () { - beforeEach(function () { + describe('with a duration of 12.3 seconds', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-run-finished', { result: { duration: 123 * 100 } }) }) - it('outputs scenario totals, step totals, and duration', function () { + it('outputs scenario totals, step totals, and duration', function() { expect(this.output).to.contain('0 scenarios\n0 steps\n0m12.300s\n') }) }) - describe('with a duration of 120.3 seconds', function () { - beforeEach(function () { + describe('with a duration of 120.3 seconds', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-run-finished', { result: { duration: 123 * 1000 } }) }) - it('outputs scenario totals, step totals, and duration', function () { + it('outputs scenario totals, step totals, and duration', function() { expect(this.output).to.contain('0 scenarios\n0 steps\n2m03.000s\n') }) }) diff --git a/src/formatter/usage_formatter.js b/src/formatter/usage_formatter.js index 427de5300..3e37bf742 100644 --- a/src/formatter/usage_formatter.js +++ b/src/formatter/usage_formatter.js @@ -4,12 +4,12 @@ import Formatter from './' import Table from 'cli-table' export default class UsageFormatter extends Formatter { - constructor (options) { + constructor(options) { super(options) options.eventBroadcaster.on('test-run-finished', ::this.logUsage) } - logUsage () { + logUsage() { const usage = getUsage({ stepDefinitions: this.supportCodeLibrary.stepDefinitions, eventDataCollector: this.eventDataCollector @@ -26,8 +26,8 @@ export default class UsageFormatter extends Formatter { } }) usage.forEach(({ line, matches, meanDuration, pattern, uri }) => { - let col1 = [pattern.toString()] - let col2 = [] + const col1 = [pattern.toString()] + const col2 = [] if (matches.length > 0) { if (isFinite(meanDuration)) { col2.push(`${parseFloat(meanDuration.toFixed(2))}ms`) @@ -37,7 +37,7 @@ export default class UsageFormatter extends Formatter { } else { col2.push('UNUSED') } - let col3 = [formatLocation({ line, uri })] + const col3 = [formatLocation({ line, uri })] _.take(matches, 5).forEach(match => { col1.push(` ${match.text}`) if (isFinite(match.duration)) { @@ -52,6 +52,6 @@ export default class UsageFormatter extends Formatter { } table.push([col1.join('\n'), col2.join('\n'), col3.join('\n')]) }) - this.log(table.toString() + '\n') + this.log(`${table.toString()}\n`) } } diff --git a/src/formatter/usage_formatter_spec.js b/src/formatter/usage_formatter_spec.js index c3b82005e..bb9093b14 100644 --- a/src/formatter/usage_formatter_spec.js +++ b/src/formatter/usage_formatter_spec.js @@ -3,9 +3,9 @@ import EventEmitter from 'events' import Gherkin from 'gherkin' import { EventDataCollector } from './helpers' -describe('UsageFormatter', function () { - describe('handleFeaturesResult', function () { - beforeEach(function () { +describe('UsageFormatter', () => { + describe('handleFeaturesResult', () => { + beforeEach(function() { this.eventBroadcaster = new EventEmitter() this.output = '' const logFn = data => { @@ -22,18 +22,18 @@ describe('UsageFormatter', function () { }) }) - describe('no step definitions', function () { - beforeEach(function () { + describe('no step definitions', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs "No step definitions"', function () { + it('outputs "No step definitions"', function() { expect(this.output).to.eql('No step definitions') }) }) - describe('with one step definition', function () { - beforeEach(function () { + describe('with one step definition', () => { + beforeEach(function() { this.stepDefinition = { line: 1, pattern: '/^abc?$/', @@ -42,12 +42,12 @@ describe('UsageFormatter', function () { this.supportCodeLibrary.stepDefinitions = [this.stepDefinition] }) - describe('unused', function () { - beforeEach(function () { + describe('unused', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step definition as unused', function () { + it('outputs the step definition as unused', function() { expect(this.output).to.eql( '┌────────────────┬──────────┬────────────┐\n' + '│ Pattern / Text │ Duration │ Location │\n' + @@ -58,8 +58,8 @@ describe('UsageFormatter', function () { }) }) - describe('used', function () { - beforeEach(function () { + describe('used', () => { + beforeEach(function() { const events = Gherkin.generateEvents( 'Feature: a\nScenario: b\nWhen abc\nThen ab', 'a.feature' @@ -90,8 +90,8 @@ describe('UsageFormatter', function () { }) }) - describe('in dry run', function () { - beforeEach(function () { + describe('in dry run', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, @@ -105,7 +105,7 @@ describe('UsageFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step definition without durations', function () { + it('outputs the step definition without durations', function() { expect(this.output).to.eql( '┌────────────────┬──────────┬─────────────┐\n' + '│ Pattern / Text │ Duration │ Location │\n' + @@ -118,8 +118,8 @@ describe('UsageFormatter', function () { }) }) - describe('not in dry run', function () { - beforeEach(function () { + describe('not in dry run', () => { + beforeEach(function() { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, @@ -133,7 +133,7 @@ describe('UsageFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step definition with durations in desending order', function () { + it('outputs the step definition with durations in desending order', function() { expect(this.output).to.eql( '┌────────────────┬──────────┬─────────────┐\n' + '│ Pattern / Text │ Duration │ Location │\n' + @@ -148,8 +148,8 @@ describe('UsageFormatter', function () { }) }) - describe('with multiple definition', function () { - beforeEach(function () { + describe('with multiple definition', () => { + beforeEach(function() { this.supportCodeLibrary.stepDefinitions = [ { line: 1, @@ -208,7 +208,7 @@ describe('UsageFormatter', function () { this.eventBroadcaster.emit('test-run-finished') }) - it('outputs the step definitions ordered by mean duration descending with unused steps at the end', function () { + it('outputs the step definitions ordered by mean duration descending with unused steps at the end', function() { expect(this.output).to.eql( '┌────────────────┬──────────┬─────────────┐\n' + '│ Pattern / Text │ Duration │ Location │\n' + diff --git a/src/formatter/usage_json_formatter.js b/src/formatter/usage_json_formatter.js index 12df25b00..81a8c3b00 100644 --- a/src/formatter/usage_json_formatter.js +++ b/src/formatter/usage_json_formatter.js @@ -2,12 +2,12 @@ import { getUsage } from './helpers' import Formatter from './' export default class UsageJsonFormatter extends Formatter { - constructor (options) { + constructor(options) { super(options) options.eventBroadcaster.on('test-run-finished', ::this.logUsage) } - logUsage () { + logUsage() { const usage = getUsage({ stepDefinitions: this.supportCodeLibrary.stepDefinitions, eventDataCollector: this.eventDataCollector diff --git a/src/formatter/usage_json_formatter_spec.js b/src/formatter/usage_json_formatter_spec.js index f5586dee4..0a43d8b2b 100644 --- a/src/formatter/usage_json_formatter_spec.js +++ b/src/formatter/usage_json_formatter_spec.js @@ -3,9 +3,9 @@ import EventEmitter from 'events' import Gherkin from 'gherkin' import { EventDataCollector } from './helpers' -describe('UsageJsonFormatter', function () { - describe('handleFeaturesResult', function () { - beforeEach(function () { +describe('UsageJsonFormatter', () => { + describe('handleFeaturesResult', () => { + beforeEach(function() { const eventBroadcaster = new EventEmitter() this.output = '' const logFn = data => { @@ -77,7 +77,7 @@ describe('UsageJsonFormatter', function () { eventBroadcaster.emit('test-run-finished') }) - it('outputs the usage in json format', function () { + it('outputs the usage in json format', function() { const parsedOutput = JSON.parse(this.output) expect(parsedOutput).to.eql([ { diff --git a/src/models/data_table.js b/src/models/data_table.js index 5efb7f42e..2245e862d 100644 --- a/src/models/data_table.js +++ b/src/models/data_table.js @@ -1,30 +1,30 @@ import _ from 'lodash' export default class DataTable { - constructor (gherkinData) { + constructor(gherkinData) { this.rawTable = gherkinData.rows.map(row => row.cells.map(cell => cell.value) ) } - hashes () { + hashes() { const copy = this.raw() const keys = copy[0] const valuesArray = copy.slice(1) return valuesArray.map(values => _.zipObject(keys, values)) } - raw () { + raw() { return this.rawTable.slice(0) } - rows () { + rows() { const copy = this.raw() copy.shift() return copy } - rowsHash () { + rowsHash() { const rows = this.raw() const everyRowHasTwoColumns = _.every(rows, row => row.length === 2) if (!everyRowHasTwoColumns) { diff --git a/src/models/data_table_spec.js b/src/models/data_table_spec.js index 0c6743117..2e0205be8 100644 --- a/src/models/data_table_spec.js +++ b/src/models/data_table_spec.js @@ -1,8 +1,8 @@ import DataTable from './data_table' -describe('DataTable', function () { - describe('table with headers', function () { - beforeEach(function () { +describe('DataTable', () => { + describe('table with headers', () => { + beforeEach(function() { this.dataTable = new DataTable({ rows: [ { @@ -18,8 +18,8 @@ describe('DataTable', function () { }) }) - describe('rows', function () { - it('returns a 2-D array without the header', function () { + describe('rows', () => { + it('returns a 2-D array without the header', function() { expect(this.dataTable.rows()).to.eql([ ['row 1 col 1', 'row 1 col 2'], ['row 2 col 1', 'row 2 col 2'] @@ -27,8 +27,8 @@ describe('DataTable', function () { }) }) - describe('hashes', function () { - it('returns an array of object where the keys are the headers', function () { + describe('hashes', () => { + it('returns an array of object where the keys are the headers', function() { expect(this.dataTable.hashes()).to.eql([ { 'header 1': 'row 1 col 1', 'header 2': 'row 1 col 2' }, { 'header 1': 'row 2 col 1', 'header 2': 'row 2 col 2' } @@ -37,8 +37,8 @@ describe('DataTable', function () { }) }) - describe('table without headers', function () { - beforeEach(function () { + describe('table without headers', () => { + beforeEach(function() { this.dataTable = new DataTable({ rows: [ { @@ -51,8 +51,8 @@ describe('DataTable', function () { }) }) - describe('raw', function () { - it('returns a 2-D array', function () { + describe('raw', () => { + it('returns a 2-D array', function() { expect(this.dataTable.raw()).to.eql([ ['row 1 col 1', 'row 1 col 2'], ['row 2 col 1', 'row 2 col 2'] @@ -60,8 +60,8 @@ describe('DataTable', function () { }) }) - describe('rowsHash', function () { - it('returns an object where the keys are the first column', function () { + describe('rowsHash', () => { + it('returns an object where the keys are the first column', function() { expect(this.dataTable.rowsHash()).to.eql({ 'row 1 col 1': 'row 1 col 2', 'row 2 col 1': 'row 2 col 2' diff --git a/src/models/step_definition.js b/src/models/step_definition.js index 3fc105fc7..7e6cbec9e 100644 --- a/src/models/step_definition.js +++ b/src/models/step_definition.js @@ -3,7 +3,7 @@ import DataTable from './data_table' import { buildStepArgumentIterator } from '../step_arguments' export default class StepDefinition { - constructor ({ code, line, options, pattern, uri }) { + constructor({ code, line, options, pattern, uri }) { this.code = code this.line = line this.options = options @@ -11,28 +11,22 @@ export default class StepDefinition { this.uri = uri } - buildInvalidCodeLengthMessage (syncOrPromiseLength, callbackLength) { + buildInvalidCodeLengthMessage(syncOrPromiseLength, callbackLength) { return ( - 'function has ' + - this.code.length + - ' arguments' + - ', should have ' + - syncOrPromiseLength + - ' (if synchronous or returning a promise)' + - ' or ' + - callbackLength + - ' (if accepting a callback)' + `function has ${this.code.length} arguments` + + `, should have ${syncOrPromiseLength} (if synchronous or returning a promise)` + + ` or ${callbackLength} (if accepting a callback)` ) } - getInvalidCodeLengthMessage (parameters) { + getInvalidCodeLengthMessage(parameters) { return this.buildInvalidCodeLengthMessage( parameters.length, parameters.length + 1 ) } - getInvocationParameters ({ step, parameterTypeRegistry, world }) { + getInvocationParameters({ step, parameterTypeRegistry, world }) { const cucumberExpression = this.getCucumberExpression(parameterTypeRegistry) const stepNameParameters = cucumberExpression .match(step.text) @@ -45,19 +39,18 @@ export default class StepDefinition { return stepNameParameters.concat(stepArgumentParameters) } - getCucumberExpression (parameterTypeRegistry) { + getCucumberExpression(parameterTypeRegistry) { if (typeof this.pattern === 'string') { return new CucumberExpression(this.pattern, parameterTypeRegistry) - } else { - return new RegularExpression(this.pattern, parameterTypeRegistry) } + return new RegularExpression(this.pattern, parameterTypeRegistry) } - getValidCodeLengths (parameters) { + getValidCodeLengths(parameters) { return [parameters.length, parameters.length + 1] } - matchesStepName ({ stepName, parameterTypeRegistry }) { + matchesStepName({ stepName, parameterTypeRegistry }) { const cucumberExpression = this.getCucumberExpression(parameterTypeRegistry) return Boolean(cucumberExpression.match(stepName)) } diff --git a/src/models/test_case_hook_definition.js b/src/models/test_case_hook_definition.js index 059a9eb41..2d3ca9d2a 100644 --- a/src/models/test_case_hook_definition.js +++ b/src/models/test_case_hook_definition.js @@ -2,26 +2,26 @@ import PickleFilter from '../pickle_filter' import StepDefinition from './step_definition' export default class TestCaseHookDefinition extends StepDefinition { - constructor (data) { + constructor(data) { super(data) this.pickleFilter = new PickleFilter({ tagExpression: this.options.tags }) } - appliesToTestCase ({ pickle, uri }) { + appliesToTestCase({ pickle, uri }) { return this.pickleFilter.matches({ pickle, uri }) } - getInvalidCodeLengthMessage () { + getInvalidCodeLengthMessage() { return this.buildInvalidCodeLengthMessage('0 or 1', '2') } - getInvocationParameters ({ hookParameter }) { + getInvocationParameters({ hookParameter }) { return [hookParameter] } - getValidCodeLengths () { + getValidCodeLengths() { return [0, 1, 2] } } diff --git a/src/models/test_case_hook_definition_spec.js b/src/models/test_case_hook_definition_spec.js index 4357a3950..6ecca1149 100644 --- a/src/models/test_case_hook_definition_spec.js +++ b/src/models/test_case_hook_definition_spec.js @@ -1,8 +1,8 @@ import TestCaseHookDefinition from './test_case_hook_definition' -describe('TestCaseHookDefinition', function () { - describe('appliesToTestCase', function () { - beforeEach(function () { +describe('TestCaseHookDefinition', () => { + describe('appliesToTestCase', () => { + beforeEach(function() { this.input = { pickle: { tags: [] @@ -11,40 +11,46 @@ describe('TestCaseHookDefinition', function () { } }) - describe('no tags', function () { - beforeEach(function () { + describe('no tags', () => { + beforeEach(function() { this.testCaseHookDefinition = new TestCaseHookDefinition({ options: {} }) }) - it('returns true', function () { - expect(this.testCaseHookDefinition.appliesToTestCase(this.input)).to.eql(true) + it('returns true', function() { + expect( + this.testCaseHookDefinition.appliesToTestCase(this.input) + ).to.eql(true) }) }) - describe('tags match', function () { - beforeEach(function () { + describe('tags match', () => { + beforeEach(function() { this.input.pickle.tags = [{ name: '@tagA' }] this.testCaseHookDefinition = new TestCaseHookDefinition({ options: { tags: '@tagA' } }) }) - it('returns true', function () { - expect(this.testCaseHookDefinition.appliesToTestCase(this.input)).to.eql(true) + it('returns true', function() { + expect( + this.testCaseHookDefinition.appliesToTestCase(this.input) + ).to.eql(true) }) }) - describe('tags do not match', function () { - beforeEach(function () { + describe('tags do not match', () => { + beforeEach(function() { this.testCaseHookDefinition = new TestCaseHookDefinition({ options: { tags: '@tagA' } }) }) - it('returns false', function () { - expect(this.testCaseHookDefinition.appliesToTestCase(this.input)).to.eql(false) + it('returns false', function() { + expect( + this.testCaseHookDefinition.appliesToTestCase(this.input) + ).to.eql(false) }) }) }) diff --git a/src/models/test_run_hook_definition.js b/src/models/test_run_hook_definition.js index e6df8c184..d3a80c840 100644 --- a/src/models/test_run_hook_definition.js +++ b/src/models/test_run_hook_definition.js @@ -1,15 +1,15 @@ import StepDefinition from './step_definition' export default class TestRunHookDefinition extends StepDefinition { - getInvalidCodeLengthMessage () { + getInvalidCodeLengthMessage() { return this.buildInvalidCodeLengthMessage('0', '1') } - getInvocationParameters () { + getInvocationParameters() { return [] } - getValidCodeLengths () { + getValidCodeLengths() { return [0, 1] } } diff --git a/src/pickle_filter.js b/src/pickle_filter.js index 8c8dbed51..236aea149 100644 --- a/src/pickle_filter.js +++ b/src/pickle_filter.js @@ -6,7 +6,7 @@ const FEATURE_LINENUM_REGEXP = /^(.*?)((?::[\d]+)+)?$/ const tagExpressionParser = new TagExpressionParser() export default class PickleFilter { - constructor ({ featurePaths, names, tagExpression }) { + constructor({ featurePaths, names, tagExpression }) { this.featureUriToLinesMapping = this.getFeatureUriToLinesMapping( featurePaths || [] ) @@ -16,7 +16,7 @@ export default class PickleFilter { } } - getFeatureUriToLinesMapping (featurePaths) { + getFeatureUriToLinesMapping(featurePaths) { const mapping = {} featurePaths.forEach(featurePath => { const match = FEATURE_LINENUM_REGEXP.exec(featurePath) @@ -30,7 +30,7 @@ export default class PickleFilter { linesExpression .slice(1) .split(':') - .forEach(function (line) { + .forEach(line => { mapping[uri].push(parseInt(line)) }) } @@ -39,7 +39,7 @@ export default class PickleFilter { return mapping } - matches ({ pickle, uri }) { + matches({ pickle, uri }) { return ( this.matchesAnyLine({ pickle, uri }) && this.matchesAnyName(pickle) && @@ -47,25 +47,22 @@ export default class PickleFilter { ) } - matchesAnyLine ({ pickle, uri }) { + matchesAnyLine({ pickle, uri }) { const lines = this.featureUriToLinesMapping[path.resolve(uri)] if (lines) { return _.size(_.intersection(lines, _.map(pickle.locations, 'line'))) > 0 - } else { - return true } + return true } - matchesAnyName (pickle) { + matchesAnyName(pickle) { if (this.names.length === 0) { return true } - return _.some(this.names, function (name) { - return pickle.name.match(name) - }) + return _.some(this.names, name => pickle.name.match(name)) } - matchesAllTagExpressions (pickle) { + matchesAllTagExpressions(pickle) { if (!this.tagExpressionNode) { return true } diff --git a/src/pickle_filter_spec.js b/src/pickle_filter_spec.js index a79b46be4..97876fa25 100644 --- a/src/pickle_filter_spec.js +++ b/src/pickle_filter_spec.js @@ -1,8 +1,8 @@ import PickleFilter from './pickle_filter' -describe('PickleFilter', function () { - describe('matches', function () { - beforeEach(function () { +describe('PickleFilter', () => { + describe('matches', () => { + beforeEach(function() { this.input = { pickle: { locations: [], @@ -13,8 +13,8 @@ describe('PickleFilter', function () { } }) - describe('no filters', function () { - beforeEach(function () { + describe('no filters', () => { + beforeEach(function() { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], @@ -22,13 +22,13 @@ describe('PickleFilter', function () { }) }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('line filters', function () { - beforeEach(function () { + describe('line filters', () => { + beforeEach(function() { this.pickleFilter = new PickleFilter({ featurePaths: ['features/a.feature', 'features/b.feature:1:2'], names: [], @@ -36,72 +36,72 @@ describe('PickleFilter', function () { }) }) - describe('scenario in feature without line specified', function () { - beforeEach(function () { + describe('scenario in feature without line specified', () => { + beforeEach(function() { this.input.uri = 'features/a.feature' }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario in feature with line specified', function () { - beforeEach(function () { + describe('scenario in feature with line specified', () => { + beforeEach(function() { this.input.uri = 'features/b.feature' }) - describe('scenario line matches', function () { - beforeEach(function () { + describe('scenario line matches', () => { + beforeEach(function() { this.input.pickle.locations = [{ line: 1 }] }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario line does not match', function () { - beforeEach(function () { + describe('scenario line does not match', () => { + beforeEach(function() { this.input.pickle.locations = [{ line: 3 }] }) - it('returns false', function () { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) - describe('scenario line using current directory path representation', function () { - beforeEach(function () { + describe('scenario line using current directory path representation', () => { + beforeEach(function() { this.input.uri = './features/b.feature' }) - describe('scenario line matches', function () { - beforeEach(function () { + describe('scenario line matches', () => { + beforeEach(function() { this.input.pickle.locations = [{ line: 1 }] }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario line does not match', function () { - beforeEach(function () { + describe('scenario line does not match', () => { + beforeEach(function() { this.input.pickle.locations = [{ line: 3 }] }) - it('returns false', function () { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) }) - describe('name filters', function () { - describe('should match name A', function () { - beforeEach(function () { + describe('name filters', () => { + describe('should match name A', () => { + beforeEach(function() { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: ['nameA'], @@ -109,29 +109,29 @@ describe('PickleFilter', function () { }) }) - describe('scenario name matches A', function () { - beforeEach(function () { + describe('scenario name matches A', () => { + beforeEach(function() { this.input.pickle.name = 'nameA descriptionA' }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario name does not match A', function () { - beforeEach(function () { + describe('scenario name does not match A', () => { + beforeEach(function() { this.input.pickle.name = 'nameB descriptionB' }) - it('returns false', function () { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) - describe('should match name A or B', function () { - beforeEach(function () { + describe('should match name A or B', () => { + beforeEach(function() { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: ['nameA', 'nameB'], @@ -139,41 +139,41 @@ describe('PickleFilter', function () { }) }) - describe('scenario name matches A', function () { - beforeEach(function () { + describe('scenario name matches A', () => { + beforeEach(function() { this.input.pickle.name = 'nameA descriptionA' }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario name matches B', function () { - beforeEach(function () { + describe('scenario name matches B', () => { + beforeEach(function() { this.input.pickle.name = 'nameB descriptionB' }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario name does not match A or B', function () { - beforeEach(function () { + describe('scenario name does not match A or B', () => { + beforeEach(function() { this.input.pickle.name = 'nameC descriptionC' }) - it('returns false', function () { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) }) - describe('tag filters', function () { - describe('should have tag A', function () { - beforeEach(function () { + describe('tag filters', () => { + describe('should have tag A', () => { + beforeEach(function() { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], @@ -181,25 +181,25 @@ describe('PickleFilter', function () { }) }) - describe('scenario has tag A', function () { - beforeEach(function () { + describe('scenario has tag A', () => { + beforeEach(function() { this.input.pickle.tags = [{ name: '@tagA' }] }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario does not have tag A', function () { - it('returns false', function () { + describe('scenario does not have tag A', () => { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) - describe('should not have tag A', function () { - beforeEach(function () { + describe('should not have tag A', () => { + beforeEach(function() { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], @@ -207,25 +207,25 @@ describe('PickleFilter', function () { }) }) - describe('scenario has tag A', function () { - beforeEach(function () { + describe('scenario has tag A', () => { + beforeEach(function() { this.input.pickle.tags = [{ name: '@tagA' }] }) - it('returns false', function () { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) - describe('scenario does not have tag A', function () { - it('returns true', function () { + describe('scenario does not have tag A', () => { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) }) - describe('should have tag A and B', function () { - beforeEach(function () { + describe('should have tag A and B', () => { + beforeEach(function() { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], @@ -233,45 +233,45 @@ describe('PickleFilter', function () { }) }) - describe('scenario has tag A and B', function () { - beforeEach(function () { + describe('scenario has tag A and B', () => { + beforeEach(function() { this.input.pickle.tags = [{ name: '@tagA' }, { name: '@tagB' }] }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario has tag A, but not B', function () { - beforeEach(function () { + describe('scenario has tag A, but not B', () => { + beforeEach(function() { this.input.pickle.tags = [{ name: '@tagA' }] }) - it('returns false', function () { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) - describe('scenario has tag B, but not A', function () { - beforeEach(function () { + describe('scenario has tag B, but not A', () => { + beforeEach(function() { this.input.pickle.tags = [{ name: '@tagB' }] }) - it('returns false', function () { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) - describe('scenario does have tag A or B', function () { - it('returns false', function () { + describe('scenario does have tag A or B', () => { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) - describe('should have tag A or B', function () { - beforeEach(function () { + describe('should have tag A or B', () => { + beforeEach(function() { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], @@ -279,51 +279,51 @@ describe('PickleFilter', function () { }) }) - describe('scenario has tag A and B', function () { - beforeEach(function () { + describe('scenario has tag A and B', () => { + beforeEach(function() { this.input.pickle.tags = [{ name: '@tagA' }, { name: '@tagB' }] }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario has tag A, but not B', function () { - beforeEach(function () { + describe('scenario has tag A, but not B', () => { + beforeEach(function() { this.input.pickle.tags = [{ name: '@tagA' }] }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario has tag B, but not A', function () { - beforeEach(function () { + describe('scenario has tag B, but not A', () => { + beforeEach(function() { this.input.pickle.tags = [{ name: '@tagB' }] }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario does have tag A or B', function () { - it('returns false', function () { + describe('scenario does have tag A or B', () => { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) }) }) - describe('line, name, and tag filters', function () { - beforeEach(function () { + describe('line, name, and tag filters', () => { + beforeEach(function() { this.input.uri = 'features/b.feature' }) - describe('scenario matches all filters', function () { - beforeEach(function () { + describe('scenario matches all filters', () => { + beforeEach(function() { this.pickleFilter = new PickleFilter({ featurePaths: ['features/b.feature:1:2'], names: ['nameA'], @@ -334,13 +334,13 @@ describe('PickleFilter', function () { this.input.pickle.tags = [{ name: '@tagA' }] }) - it('returns true', function () { + it('returns true', function() { expect(this.pickleFilter.matches(this.input)).to.eql(true) }) }) - describe('scenario matches some filters', function () { - beforeEach(function () { + describe('scenario matches some filters', () => { + beforeEach(function() { this.pickleFilter = new PickleFilter({ featurePaths: ['features/b.feature:1:2'], names: ['nameA'], @@ -349,13 +349,13 @@ describe('PickleFilter', function () { this.input.pickle.locations = [{ line: 1 }] }) - it('returns false', function () { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) - describe('scenario matches no filters', function () { - beforeEach(function () { + describe('scenario matches no filters', () => { + beforeEach(function() { this.pickleFilter = new PickleFilter({ featurePaths: ['features/b.feature:1:2'], names: ['nameA'], @@ -364,7 +364,7 @@ describe('PickleFilter', function () { this.input.pickle.locations = [{ line: 1 }] }) - it('returns false', function () { + it('returns false', function() { expect(this.pickleFilter.matches(this.input)).to.eql(false) }) }) diff --git a/src/runtime/attachment_manager/index.js b/src/runtime/attachment_manager/index.js index fcf1cdffa..31b24a9d4 100644 --- a/src/runtime/attachment_manager/index.js +++ b/src/runtime/attachment_manager/index.js @@ -2,11 +2,11 @@ import isStream from 'is-stream' import Promise from 'bluebird' export default class AttachmentManager { - constructor (onAttachment) { + constructor(onAttachment) { this.onAttachment = onAttachment } - create (data, mediaType, callback) { + create(data, mediaType, callback) { if (Buffer.isBuffer(data)) { if (!mediaType) { throw Error('Buffer attachments must specify a media type') @@ -29,14 +29,14 @@ export default class AttachmentManager { } } - createBufferAttachment (data, mediaType) { + createBufferAttachment(data, mediaType) { this.createStringAttachment(data.toString('base64'), { encoding: 'base64', type: mediaType }) } - createStreamAttachment (data, mediaType, callback) { + createStreamAttachment(data, mediaType, callback) { const promise = new Promise((resolve, reject) => { const buffers = [] data.on('data', chunk => { @@ -55,7 +55,7 @@ export default class AttachmentManager { } } - createStringAttachment (data, media) { + createStringAttachment(data, media) { this.onAttachment({ data, media }) } } diff --git a/src/runtime/attachment_manager/index_spec.js b/src/runtime/attachment_manager/index_spec.js index 8ddbe61d2..db89a137e 100644 --- a/src/runtime/attachment_manager/index_spec.js +++ b/src/runtime/attachment_manager/index_spec.js @@ -1,20 +1,23 @@ import AttachmentManager from './' import stream from 'stream' -describe('AttachmentManager', function () { - describe('create()', function () { - beforeEach(function () { +describe('AttachmentManager', () => { + describe('create()', () => { + beforeEach(function() { this.onAttachment = sinon.stub() this.attachmentManager = new AttachmentManager(this.onAttachment) }) - describe('buffer', function () { - describe('with mime type', function () { - beforeEach(function () { - this.attachmentManager.create(Buffer.from('my string'), 'text/special') + describe('buffer', () => { + describe('with mime type', () => { + beforeEach(function() { + this.attachmentManager.create( + Buffer.from('my string'), + 'text/special' + ) }) - it('adds the data and media', function () { + it('adds the data and media', function() { expect(this.onAttachment).to.have.callCount(1) const attachment = this.onAttachment.firstCall.args[0] const encodedData = attachment.data @@ -28,8 +31,8 @@ describe('AttachmentManager', function () { }) }) - describe('without media type', function () { - it('throws', function () { + describe('without media type', () => { + it('throws', function() { expect(() => { this.attachmentManager.create(Buffer.from('my string')) }).to.throw('Buffer attachments must specify a media type') @@ -37,27 +40,27 @@ describe('AttachmentManager', function () { }) }) - describe('readable stream', function () { - describe('with mime type', function () { - describe('with callback', function () { - beforeEach(function (done) { + describe('readable stream', () => { + describe('with mime type', () => { + describe('with callback', () => { + beforeEach(function(done) { const readableStream = new stream.PassThrough() this.result = this.attachmentManager.create( readableStream, 'text/special', done ) - setTimeout(function () { + setTimeout(() => { readableStream.write('my string') readableStream.end() }, 25) }) - it('does not return a promise', function () { + it('does not return a promise', function() { expect(this.result).to.eql(undefined) }) - it('adds the data and media', function () { + it('adds the data and media', function() { expect(this.onAttachment).to.have.callCount(1) const attachment = this.onAttachment.firstCall.args[0] const encodedData = attachment.data @@ -71,25 +74,25 @@ describe('AttachmentManager', function () { }) }) - describe('without callback', function () { - beforeEach(function () { + describe('without callback', () => { + beforeEach(function() { const readableStream = new stream.PassThrough() this.result = this.attachmentManager.create( readableStream, 'text/special' ) - setTimeout(function () { + setTimeout(() => { readableStream.write('my string') readableStream.end() }, 25) return this.result }) - it('returns a promise', function () { + it('returns a promise', function() { expect(this.result.then).to.be.a('function') }) - it('adds the data and media', function () { + it('adds the data and media', function() { expect(this.onAttachment).to.have.callCount(1) const attachment = this.onAttachment.firstCall.args[0] const encodedData = attachment.data @@ -104,8 +107,8 @@ describe('AttachmentManager', function () { }) }) - describe('without media type', function () { - it('throws', function () { + describe('without media type', () => { + it('throws', function() { expect(() => { const readableStream = new stream.PassThrough() this.attachmentManager.create(readableStream) @@ -114,13 +117,13 @@ describe('AttachmentManager', function () { }) }) - describe('string', function () { - describe('with media type', function () { - beforeEach(function () { + describe('string', () => { + describe('with media type', () => { + beforeEach(function() { this.attachmentManager.create('my string', 'text/special') }) - it('adds the data and media', function () { + it('adds the data and media', function() { expect(this.onAttachment).to.have.callCount(1) const attachment = this.onAttachment.firstCall.args[0] expect(attachment.data).to.eql('my string') @@ -128,12 +131,12 @@ describe('AttachmentManager', function () { }) }) - describe('without mime type', function () { - beforeEach(function () { + describe('without mime type', () => { + beforeEach(function() { this.attachmentManager.create('my string') }) - it('adds the data with the default mime type', function () { + it('adds the data with the default mime type', function() { expect(this.onAttachment).to.have.callCount(1) const attachment = this.onAttachment.firstCall.args[0] expect(attachment.data).to.eql('my string') @@ -142,8 +145,8 @@ describe('AttachmentManager', function () { }) }) - describe('unsupported data type', function () { - it('throws', function () { + describe('unsupported data type', () => { + it('throws', function() { expect(() => { this.attachmentManager.create({}, 'object/special') }).to.throw( diff --git a/src/runtime/helpers.js b/src/runtime/helpers.js index dae9ff965..ec61cbb9d 100644 --- a/src/runtime/helpers.js +++ b/src/runtime/helpers.js @@ -2,7 +2,7 @@ import { formatLocation } from '../formatter/helpers/location_helpers' import Table from 'cli-table' import indentString from 'indent-string' -export function getAmbiguousStepException (stepDefinitions) { +export function getAmbiguousStepException(stepDefinitions) { const table = new Table({ chars: { bottom: '', @@ -27,16 +27,14 @@ export function getAmbiguousStepException (stepDefinitions) { 'padding-right': 0 } }) - table.push.apply( - table, - stepDefinitions.map(stepDefinition => { + table.push( + ...stepDefinitions.map(stepDefinition => { const pattern = stepDefinition.pattern.toString() return [pattern, formatLocation(stepDefinition)] }) ) - return ( - 'Multiple step definitions match:' + - '\n' + - indentString(table.toString(), 2) - ) + return `${'Multiple step definitions match:' + '\n'}${indentString( + table.toString(), + 2 + )}` } diff --git a/src/runtime/helpers_spec.js b/src/runtime/helpers_spec.js index 01b407f8a..3dce5c0cb 100644 --- a/src/runtime/helpers_spec.js +++ b/src/runtime/helpers_spec.js @@ -1,8 +1,8 @@ import { getAmbiguousStepException } from './helpers' -describe('Helpers', function () { - describe('getAmbiguousStepException', function () { - beforeEach(function () { +describe('Helpers', () => { + describe('getAmbiguousStepException', () => { + beforeEach(function() { this.result = getAmbiguousStepException([ { line: 3, pattern: 'pattern1', uri: 'steps1.js' }, { @@ -13,7 +13,7 @@ describe('Helpers', function () { ]) }) - it('returns a nicely formatted error', function () { + it('returns a nicely formatted error', function() { expect(this.result).to.eql( 'Multiple step definitions match:\n' + ' pattern1 - steps1.js:3\n' + diff --git a/src/runtime/index.js b/src/runtime/index.js index dbbaa4c47..82b96e86e 100644 --- a/src/runtime/index.js +++ b/src/runtime/index.js @@ -9,7 +9,7 @@ import VError from 'verror' export default class Runtime { // options - {dryRun, failFast, filterStacktraces, strict} - constructor ({ eventBroadcaster, options, supportCodeLibrary, testCases }) { + constructor({ eventBroadcaster, options, supportCodeLibrary, testCases }) { this.eventBroadcaster = eventBroadcaster this.options = options || {} this.stackTraceFilter = new StackTraceFilter() @@ -21,7 +21,7 @@ export default class Runtime { } } - async runTestRunHooks (key, name) { + async runTestRunHooks(key, name) { await Promise.each(this.supportCodeLibrary[key], async hookDefinition => { const { error } = await UserCodeRunner.run({ argsArray: [], @@ -41,7 +41,7 @@ export default class Runtime { }) } - async runTestCase (testCase) { + async runTestCase(testCase) { const skip = this.options.dryRun || (this.options.failFast && !this.result.success) const testCaseRunner = new TestCaseRunner({ @@ -60,7 +60,7 @@ export default class Runtime { } } - async start () { + async start() { if (this.options.filterStacktraces) { this.stackTraceFilter.filter() } @@ -75,7 +75,7 @@ export default class Runtime { return this.result.success } - shouldCauseFailure (status) { + shouldCauseFailure(status) { return ( _.includes([Status.AMBIGUOUS, Status.FAILED, Status.UNDEFINED], status) || (status === Status.PENDING && this.options.strict) diff --git a/src/runtime/stack_trace_filter.js b/src/runtime/stack_trace_filter.js index 78fdbc02d..7b71dd354 100644 --- a/src/runtime/stack_trace_filter.js +++ b/src/runtime/stack_trace_filter.js @@ -3,42 +3,41 @@ import stackChain from 'stack-chain' import path from 'path' export default class StackTraceFilter { - constructor () { + constructor() { this.cucumberPath = path.join(__dirname, '..', '..') } - filter () { - this.currentFilter = stackChain.filter.attach((_, frames) => { + filter() { + this.currentFilter = stackChain.filter.attach((_err, frames) => { if (this.isErrorInCucumber(frames)) { return frames } const index = _.findIndex(frames, ::this.isFrameInCucumber) if (index === -1) { return frames - } else { - return frames.slice(0, index) } + return frames.slice(0, index) }) } - isErrorInCucumber (frames) { + isErrorInCucumber(frames) { const filteredFrames = _.reject(frames, ::this.isFrameInNode) return ( filteredFrames.length > 0 && this.isFrameInCucumber(filteredFrames[0]) ) } - isFrameInCucumber (frame) { + isFrameInCucumber(frame) { const fileName = frame.getFileName() || '' return _.startsWith(fileName, this.cucumberPath) } - isFrameInNode (frame) { + isFrameInNode(frame) { const fileName = frame.getFileName() || '' return !_.includes(fileName, path.sep) } - unfilter () { + unfilter() { stackChain.filter.deattach(this.currentFilter) } } diff --git a/src/runtime/step_runner.js b/src/runtime/step_runner.js index 37b47f139..cb750c96a 100644 --- a/src/runtime/step_runner.js +++ b/src/runtime/step_runner.js @@ -6,7 +6,7 @@ import Promise from 'bluebird' const { beginTiming, endTiming } = Time -async function run ({ +async function run({ defaultTimeout, hookParameter, parameterTypeRegistry, diff --git a/src/runtime/test_case_runner.js b/src/runtime/test_case_runner.js index 036533258..f236ffb6e 100644 --- a/src/runtime/test_case_runner.js +++ b/src/runtime/test_case_runner.js @@ -6,7 +6,7 @@ import Status from '../status' import StepRunner from './step_runner' export default class TestCaseRunner { - constructor ({ + constructor({ eventBroadcaster, skip, testCase, @@ -41,8 +41,8 @@ export default class TestCaseRunner { } } - emit (name, data) { - let eventData = { ...data } + emit(name, data) { + const eventData = { ...data } if (_.startsWith(name, 'test-case')) { eventData.sourceLocation = this.testCaseSourceLocation } else { @@ -51,16 +51,17 @@ export default class TestCaseRunner { this.eventBroadcaster.emit(name, eventData) } - emitPrepared () { + emitPrepared() { const steps = [] this.beforeHookDefinitions.forEach(definition => { const actionLocation = { uri: definition.uri, line: definition.line } steps.push({ actionLocation }) }) this.testCase.pickle.steps.forEach(step => { - const actionLocations = this.getStepDefinitions(step).map(definition => { - return { uri: definition.uri, line: definition.line } - }) + const actionLocations = this.getStepDefinitions(step).map(definition => ({ + uri: definition.uri, + line: definition.line + })) const sourceLocation = { uri: this.testCase.uri, line: _.last(step.locations).line @@ -78,32 +79,28 @@ export default class TestCaseRunner { this.emit('test-case-prepared', { steps }) } - getAfterHookDefinitions () { + getAfterHookDefinitions() { return this.supportCodeLibrary.afterTestCaseHookDefinitions.filter( - hookDefinition => { - return hookDefinition.appliesToTestCase(this.testCase) - } + hookDefinition => hookDefinition.appliesToTestCase(this.testCase) ) } - getBeforeHookDefinitions () { + getBeforeHookDefinitions() { return this.supportCodeLibrary.beforeTestCaseHookDefinitions.filter( - hookDefinition => { - return hookDefinition.appliesToTestCase(this.testCase) - } + hookDefinition => hookDefinition.appliesToTestCase(this.testCase) ) } - getStepDefinitions (step) { - return this.supportCodeLibrary.stepDefinitions.filter(stepDefinition => { - return stepDefinition.matchesStepName({ + getStepDefinitions(step) { + return this.supportCodeLibrary.stepDefinitions.filter(stepDefinition => + stepDefinition.matchesStepName({ stepName: step.text, parameterTypeRegistry: this.supportCodeLibrary.parameterTypeRegistry }) - }) + ) } - invokeStep (step, stepDefinition, hookParameter) { + invokeStep(step, stepDefinition, hookParameter) { return StepRunner.run({ defaultTimeout: this.supportCodeLibrary.defaultTimeout, hookParameter, @@ -114,11 +111,11 @@ export default class TestCaseRunner { }) } - isSkippingSteps () { + isSkippingSteps() { return this.result.status !== Status.PASSED } - shouldUpdateStatus (testStepResult) { + shouldUpdateStatus(testStepResult) { switch (testStepResult.status) { case Status.FAILED: case Status.AMBIGUOUS: @@ -134,7 +131,7 @@ export default class TestCaseRunner { } } - async aroundTestStep (runStepFn) { + async aroundTestStep(runStepFn) { this.emit('test-step-started', { index: this.testStepIndex }) const testStepResult = await runStepFn() if (testStepResult.duration) { @@ -153,7 +150,7 @@ export default class TestCaseRunner { this.testStepIndex += 1 } - async run () { + async run() { this.emitPrepared() this.emit('test-case-started', {}) await this.runHooks(this.beforeHookDefinitions, { @@ -170,23 +167,22 @@ export default class TestCaseRunner { return this.result } - async runHook (hookDefinition, hookParameter) { + async runHook(hookDefinition, hookParameter) { if (this.skip) { return { status: Status.SKIPPED } - } else { - return this.invokeStep(null, hookDefinition, hookParameter) } + return this.invokeStep(null, hookDefinition, hookParameter) } - async runHooks (hookDefinitions, hookParameter) { + async runHooks(hookDefinitions, hookParameter) { await Promise.each(hookDefinitions, async hookDefinition => { - await this.aroundTestStep(() => { - return this.runHook(hookDefinition, hookParameter) - }) + await this.aroundTestStep(() => + this.runHook(hookDefinition, hookParameter) + ) }) } - async runStep (step) { + async runStep(step) { const stepDefinitions = this.getStepDefinitions(step) if (stepDefinitions.length === 0) { return { status: Status.UNDEFINED } @@ -197,16 +193,13 @@ export default class TestCaseRunner { } } else if (this.isSkippingSteps()) { return { status: Status.SKIPPED } - } else { - return this.invokeStep(step, stepDefinitions[0]) } + return this.invokeStep(step, stepDefinitions[0]) } - async runSteps () { + async runSteps() { await Promise.each(this.testCase.pickle.steps, async step => { - await this.aroundTestStep(() => { - return this.runStep(step) - }) + await this.aroundTestStep(() => this.runStep(step)) }) } } diff --git a/src/runtime/test_case_runner_spec.js b/src/runtime/test_case_runner_spec.js index fa589b9c7..38a12be84 100644 --- a/src/runtime/test_case_runner_spec.js +++ b/src/runtime/test_case_runner_spec.js @@ -4,8 +4,8 @@ import Status from '../status' import StepRunner from './step_runner' import { EventEmitter } from 'events' -describe('TestCaseRunner', function () { - beforeEach(function () { +describe('TestCaseRunner', () => { + beforeEach(function() { this.onTestCasePrepared = sinon.stub() this.onTestCaseStarted = sinon.stub() this.onTestStepStarted = sinon.stub() @@ -30,18 +30,18 @@ describe('TestCaseRunner', function () { defaultTimeout: 5000, stepDefinitions: [], parameterTypeRegistry: {}, - World () {} + World() {} } sinon.stub(StepRunner, 'run') }) - afterEach(function () { + afterEach(() => { StepRunner.run.restore() }) - describe('run()', function () { - describe('with no steps or hooks', function () { - beforeEach(async function () { + describe('run()', () => { + describe('with no steps or hooks', () => { + beforeEach(async function() { const scenarioRunner = new TestCaseRunner({ eventBroadcaster: this.eventBroadcaster, skip: false, @@ -51,7 +51,7 @@ describe('TestCaseRunner', function () { await scenarioRunner.run() }) - it('emits test-case-prepared', function () { + it('emits test-case-prepared', function() { expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [], @@ -59,14 +59,14 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-started', function () { + it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-case-finished', function () { + it('emits test-case-finished', function() { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.PASSED }, @@ -75,8 +75,8 @@ describe('TestCaseRunner', function () { }) }) - describe('with a passing step', function () { - beforeEach(async function () { + describe('with a passing step', () => { + beforeEach(async function() { this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } this.stepResult = { duration: 1, @@ -99,7 +99,7 @@ describe('TestCaseRunner', function () { await scenarioRunner.run() }) - it('emits test-case-prepared', function () { + it('emits test-case-prepared', function() { expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ @@ -112,14 +112,14 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-started', function () { + it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function () { + it('emits test-step-started', function() { expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, @@ -127,7 +127,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-step-finished', function () { + it('emits test-step-finished', function() { expect(this.onTestStepFinished).to.have.callCount(1) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, @@ -136,7 +136,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-finished', function () { + it('emits test-case-finished', function() { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 1, status: Status.PASSED }, @@ -145,8 +145,8 @@ describe('TestCaseRunner', function () { }) }) - describe('with a failing step', function () { - beforeEach(async function () { + describe('with a failing step', () => { + beforeEach(async function() { this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } this.error = new Error('a') this.stepResult = { @@ -171,7 +171,7 @@ describe('TestCaseRunner', function () { await scenarioRunner.run() }) - it('emits test-case-prepared', function () { + it('emits test-case-prepared', function() { expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ @@ -184,14 +184,14 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-started', function () { + it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function () { + it('emits test-step-started', function() { expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, @@ -199,7 +199,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-step-finished', function () { + it('emits test-step-finished', function() { expect(this.onTestStepFinished).to.have.callCount(1) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, @@ -212,7 +212,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-finished', function () { + it('emits test-case-finished', function() { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { @@ -225,8 +225,8 @@ describe('TestCaseRunner', function () { }) }) - describe('with an ambiguous step', function () { - beforeEach(async function () { + describe('with an ambiguous step', () => { + beforeEach(async function() { this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } const stepDefinition1 = { pattern: 'pattern1', @@ -254,7 +254,7 @@ describe('TestCaseRunner', function () { await scenarioRunner.run() }) - it('emits test-case-prepared', function () { + it('emits test-case-prepared', function() { expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ @@ -266,14 +266,14 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-started', function () { + it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function () { + it('emits test-step-started', function() { expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, @@ -281,7 +281,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-step-finished', function () { + it('emits test-step-finished', function() { expect(this.onTestStepFinished).to.have.callCount(1) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, @@ -296,7 +296,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-finished', function () { + it('emits test-case-finished', function() { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { @@ -312,8 +312,8 @@ describe('TestCaseRunner', function () { }) }) - describe('with an undefined step', function () { - beforeEach(async function () { + describe('with an undefined step', () => { + beforeEach(async function() { this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } this.testCase.pickle.steps = [this.step] const scenarioRunner = new TestCaseRunner({ @@ -325,7 +325,7 @@ describe('TestCaseRunner', function () { await scenarioRunner.run() }) - it('emits test-case-prepared', function () { + it('emits test-case-prepared', function() { expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [{ sourceLocation: { line: 2, uri: 'path/to/feature' } }], @@ -333,14 +333,14 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-started', function () { + it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function () { + it('emits test-step-started', function() { expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, @@ -348,7 +348,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-step-finished', function () { + it('emits test-step-finished', function() { expect(this.onTestStepFinished).to.have.callCount(1) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, @@ -357,7 +357,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-finished', function () { + it('emits test-case-finished', function() { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.UNDEFINED }, @@ -366,8 +366,8 @@ describe('TestCaseRunner', function () { }) }) - describe('with a step when skipping', function () { - beforeEach(async function () { + describe('with a step when skipping', () => { + beforeEach(async function() { this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } const stepDefinition = { uri: 'path/to/steps', @@ -385,7 +385,7 @@ describe('TestCaseRunner', function () { await scenarioRunner.run() }) - it('emits test-case-prepared', function () { + it('emits test-case-prepared', function() { expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ @@ -398,14 +398,14 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-started', function () { + it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function () { + it('emits test-step-started', function() { expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, @@ -413,7 +413,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-step-finished', function () { + it('emits test-step-finished', function() { expect(this.onTestStepFinished).to.have.callCount(1) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, @@ -422,7 +422,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-finished', function () { + it('emits test-case-finished', function() { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.SKIPPED }, @@ -431,10 +431,10 @@ describe('TestCaseRunner', function () { }) }) - describe('with a before hook and step when skipping', function () { - beforeEach(async function () { + describe('with a before hook and step when skipping', () => { + beforeEach(async function() { const testCaseHookDefinition = new TestCaseHookDefinition({ - code () { + code() { throw new Error('error') }, line: 4, @@ -461,7 +461,7 @@ describe('TestCaseRunner', function () { await scenarioRunner.run() }) - it('emits test-case-prepared', function () { + it('emits test-case-prepared', function() { expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ @@ -475,14 +475,14 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-started', function () { + it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function () { + it('emits test-step-started', function() { expect(this.onTestStepStarted).to.have.callCount(2) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, @@ -494,7 +494,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-step-finished', function () { + it('emits test-step-finished', function() { expect(this.onTestStepFinished).to.have.callCount(2) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, @@ -508,7 +508,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-finished', function () { + it('emits test-case-finished', function() { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.SKIPPED }, @@ -517,10 +517,10 @@ describe('TestCaseRunner', function () { }) }) - describe('with an after hook when skipping', function () { - beforeEach(async function () { + describe('with an after hook when skipping', () => { + beforeEach(async function() { const testCaseHookDefinition = new TestCaseHookDefinition({ - code () { + code() { throw new Error('error') }, line: 4, @@ -547,7 +547,7 @@ describe('TestCaseRunner', function () { await scenarioRunner.run() }) - it('emits test-case-prepared', function () { + it('emits test-case-prepared', function() { expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ @@ -561,14 +561,14 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-started', function () { + it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ sourceLocation: { line: 1, uri: 'path/to/feature' } }) }) - it('emits test-step-started', function () { + it('emits test-step-started', function() { expect(this.onTestStepStarted).to.have.callCount(2) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, @@ -580,7 +580,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-step-finished', function () { + it('emits test-step-finished', function() { expect(this.onTestStepFinished).to.have.callCount(2) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, @@ -594,7 +594,7 @@ describe('TestCaseRunner', function () { }) }) - it('emits test-case-finished', function () { + it('emits test-case-finished', function() { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.SKIPPED }, diff --git a/src/status.js b/src/status.js index b8fa1f7c1..e37370bd6 100644 --- a/src/status.js +++ b/src/status.js @@ -11,7 +11,7 @@ const statuses = { export default statuses -export function getStatusMapping (initialValue) { +export function getStatusMapping(initialValue) { return _.chain(statuses) .map(status => [status, initialValue]) .fromPairs() diff --git a/src/status_spec.js b/src/status_spec.js index 808dd845f..4ad611bae 100644 --- a/src/status_spec.js +++ b/src/status_spec.js @@ -1,8 +1,8 @@ import Status, { getStatusMapping } from './status' -describe('Status', function () { - describe('constants', function () { - it('exposes the proper constants', function () { +describe('Status', () => { + describe('constants', () => { + it('exposes the proper constants', () => { expect(Status).to.include.keys([ 'AMBIGUOUS', 'FAILED', @@ -14,8 +14,8 @@ describe('Status', function () { }) }) - describe('getStatusMapping', function () { - it('returns a mapping of the statuses with the given initial value', function () { + describe('getStatusMapping', () => { + it('returns a mapping of the statuses with the given initial value', () => { const result = getStatusMapping(0) expect(result).to.eql({ [Status.AMBIGUOUS]: 0, diff --git a/src/step_arguments.js b/src/step_arguments.js index 2adf0ba16..d44a71233 100644 --- a/src/step_arguments.js +++ b/src/step_arguments.js @@ -1,13 +1,12 @@ import util from 'util' -export function buildStepArgumentIterator (mapping) { - return function (arg) { +export function buildStepArgumentIterator(mapping) { + return function(arg) { if (arg.hasOwnProperty('rows')) { return mapping.dataTable(arg) } else if (arg.hasOwnProperty('content')) { return mapping.docString(arg) - } else { - throw new Error('Unknown argument type:' + util.inspect(arg)) } + throw new Error(`Unknown argument type:${util.inspect(arg)}`) } } diff --git a/src/support_code_library_builder/define_helpers.js b/src/support_code_library_builder/define_helpers.js index 07250abc8..ee998e986 100644 --- a/src/support_code_library_builder/define_helpers.js +++ b/src/support_code_library_builder/define_helpers.js @@ -9,7 +9,7 @@ import TestCaseHookDefinition from '../models/test_case_hook_definition' import TestRunHookDefinition from '../models/test_run_hook_definition' import validateArguments from './validate_arguments' -export function defineTestCaseHook (builder, collectionName) { +export function defineTestCaseHook(builder, collectionName) { return (options, code) => { if (typeof options === 'string') { options = { tags: options } @@ -33,7 +33,7 @@ export function defineTestCaseHook (builder, collectionName) { } } -export function defineTestRunHook (builder, collectionName) { +export function defineTestRunHook(builder, collectionName) { return (options, code) => { if (typeof options === 'string') { options = { tags: options } @@ -57,7 +57,7 @@ export function defineTestRunHook (builder, collectionName) { } } -export function defineStep (builder) { +export function defineStep(builder) { return (pattern, options, code) => { if (typeof options === 'function') { code = options @@ -84,7 +84,7 @@ const projectPath = path.join(__dirname, '..', '..') const projectSrcPath = path.join(projectPath, 'src') const projectLibPath = path.join(projectPath, 'lib') -function getDefinitionLineAndUri (cwd) { +function getDefinitionLineAndUri(cwd) { let line = 'unknown' let uri = 'unknown' const stackframes = StackTrace.getSync() @@ -105,7 +105,7 @@ function getDefinitionLineAndUri (cwd) { return { line, uri } } -export function defineParameterType (builder) { +export function defineParameterType(builder) { return ({ name, typeName, diff --git a/src/support_code_library_builder/finalize_helpers.js b/src/support_code_library_builder/finalize_helpers.js index 99b7c3a15..6b647e41a 100644 --- a/src/support_code_library_builder/finalize_helpers.js +++ b/src/support_code_library_builder/finalize_helpers.js @@ -3,7 +3,7 @@ import arity from 'util-arity' import isGenerator from 'is-generator' import path from 'path' -export function wrapDefinitions ({ +export function wrapDefinitions({ cwd, definitionFunctionWrapper, definitions @@ -20,14 +20,15 @@ export function wrapDefinitions ({ } }) } else { - const generatorDefinitions = _.filter(definitions, definition => { - return isGenerator.fn(definition.code) - }) + const generatorDefinitions = _.filter(definitions, definition => + isGenerator.fn(definition.code) + ) if (generatorDefinitions.length > 0) { const references = generatorDefinitions - .map(definition => { - return path.relative(cwd, definition.uri) + ':' + definition.line - }) + .map( + definition => + `${path.relative(cwd, definition.uri)}:${definition.line}` + ) .join('\n ') const message = ` The following hook/step definitions use generator functions: diff --git a/src/support_code_library_builder/index.js b/src/support_code_library_builder/index.js index 5a437f525..8cd09b27a 100644 --- a/src/support_code_library_builder/index.js +++ b/src/support_code_library_builder/index.js @@ -10,7 +10,7 @@ import { import { wrapDefinitions } from './finalize_helpers' export class SupportCodeLibraryBuilder { - constructor () { + constructor() { this.methods = { defineParameterType: defineParameterType(this), After: defineTestCaseHook(this, 'afterTestCaseHookDefinitions'), @@ -34,7 +34,7 @@ export class SupportCodeLibraryBuilder { this.methods.Given = this.methods.When = this.methods.Then = this.methods.defineStep } - finalize () { + finalize() { wrapDefinitions({ cwd: this.cwd, definitionFunctionWrapper: this.options.definitionFunctionWrapper, @@ -45,7 +45,7 @@ export class SupportCodeLibraryBuilder { 'beforeTestRunHook', 'step' ]) - .map(key => this.options[key + 'Definitions']) + .map(key => this.options[`${key}Definitions`]) .flatten() .value() }) @@ -54,7 +54,7 @@ export class SupportCodeLibraryBuilder { return this.options } - reset (cwd) { + reset(cwd) { this.cwd = cwd this.options = _.cloneDeep({ afterTestCaseHookDefinitions: [], @@ -65,7 +65,7 @@ export class SupportCodeLibraryBuilder { definitionFunctionWrapper: null, stepDefinitions: [], parameterTypeRegistry: TransformLookupBuilder.build(), - World ({ attach, parameters }) { + World({ attach, parameters }) { this.attach = attach this.parameters = parameters } diff --git a/src/support_code_library_builder/index_spec.js b/src/support_code_library_builder/index_spec.js index 4cc934f53..2ef521696 100644 --- a/src/support_code_library_builder/index_spec.js +++ b/src/support_code_library_builder/index_spec.js @@ -1,15 +1,15 @@ import { ParameterTypeRegistry } from 'cucumber-expressions' import supportCodeLibraryBuilder from './' -describe('supportCodeLibraryBuilder', function () { - describe('no support code fns', function () { - beforeEach(function () { +describe('supportCodeLibraryBuilder', () => { + describe('no support code fns', () => { + beforeEach(function() { this.attachFn = sinon.stub() supportCodeLibraryBuilder.reset('path/to/project') this.options = supportCodeLibraryBuilder.finalize() }) - it('returns the default options', function () { + it('returns the default options', function() { expect(this.options.afterTestRunHookDefinitions).to.eql([]) expect(this.options.afterTestCaseHookDefinitions).to.eql([]) expect(this.options.beforeTestRunHookDefinitions).to.eql([]) @@ -28,16 +28,16 @@ describe('supportCodeLibraryBuilder', function () { }) }) - describe('After', function () { - describe('function only', function () { - beforeEach(function () { - this.hook = function () {} + describe('After', () => { + describe('function only', () => { + beforeEach(function() { + this.hook = function() {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.After(this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function () { + it('adds a scenario hook definition', function() { expect(this.options.afterTestCaseHookDefinitions).to.have.lengthOf(1) expect(this.options.afterTestCaseHookDefinitions[0].code).to.eql( this.hook @@ -45,15 +45,15 @@ describe('supportCodeLibraryBuilder', function () { }) }) - describe('tag and function', function () { - beforeEach(function () { - this.hook = function () {} + describe('tag and function', () => { + beforeEach(function() { + this.hook = function() {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.After('@tagA', this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function () { + it('adds a scenario hook definition', function() { expect(this.options.afterTestCaseHookDefinitions).to.have.lengthOf(1) expect( this.options.afterTestCaseHookDefinitions[0].options.tags @@ -64,15 +64,15 @@ describe('supportCodeLibraryBuilder', function () { }) }) - describe('options and function', function () { - beforeEach(function () { - this.hook = function () {} + describe('options and function', () => { + beforeEach(function() { + this.hook = function() {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.After({ tags: '@tagA' }, this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function () { + it('adds a scenario hook definition', function() { expect(this.options.afterTestCaseHookDefinitions).to.have.lengthOf(1) expect( this.options.afterTestCaseHookDefinitions[0].options.tags @@ -83,17 +83,17 @@ describe('supportCodeLibraryBuilder', function () { }) }) - describe('multiple', function () { - beforeEach(function () { - this.hook1 = function hook1 () {} - this.hook2 = function hook2 () {} + describe('multiple', () => { + beforeEach(function() { + this.hook1 = function hook1() {} + this.hook2 = function hook2() {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.After(this.hook1) // eslint-disable-line babel/new-cap supportCodeLibraryBuilder.methods.After(this.hook2) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds the scenario hook definitions in the reverse order of definition', function () { + it('adds the scenario hook definitions in the reverse order of definition', function() { expect(this.options.afterTestCaseHookDefinitions).to.have.lengthOf(2) expect(this.options.afterTestCaseHookDefinitions[0].code).to.eql( this.hook2 @@ -105,16 +105,16 @@ describe('supportCodeLibraryBuilder', function () { }) }) - describe('this.Before', function () { - describe('function only', function () { - beforeEach(function () { - this.hook = function () {} + describe('this.Before', () => { + describe('function only', () => { + beforeEach(function() { + this.hook = function() {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.Before(this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function () { + it('adds a scenario hook definition', function() { expect(this.options.beforeTestCaseHookDefinitions).to.have.lengthOf(1) expect(this.options.beforeTestCaseHookDefinitions[0].code).to.eql( this.hook @@ -122,15 +122,15 @@ describe('supportCodeLibraryBuilder', function () { }) }) - describe('tag and function', function () { - beforeEach(function () { - this.hook = function () {} + describe('tag and function', () => { + beforeEach(function() { + this.hook = function() {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.Before('@tagA', this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function () { + it('adds a scenario hook definition', function() { expect(this.options.beforeTestCaseHookDefinitions).to.have.lengthOf(1) expect( this.options.beforeTestCaseHookDefinitions[0].options.tags @@ -141,15 +141,15 @@ describe('supportCodeLibraryBuilder', function () { }) }) - describe('options and function', function () { - beforeEach(function () { - this.hook = function () {} + describe('options and function', () => { + beforeEach(function() { + this.hook = function() {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.Before({ tags: '@tagA' }, this.hook) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds a scenario hook definition', function () { + it('adds a scenario hook definition', function() { expect(this.options.beforeTestCaseHookDefinitions).to.have.lengthOf(1) expect( this.options.beforeTestCaseHookDefinitions[0].options.tags @@ -160,17 +160,17 @@ describe('supportCodeLibraryBuilder', function () { }) }) - describe('multiple', function () { - beforeEach(function () { - this.hook1 = function hook1 () {} - this.hook2 = function hook2 () {} + describe('multiple', () => { + beforeEach(function() { + this.hook1 = function hook1() {} + this.hook2 = function hook2() {} supportCodeLibraryBuilder.reset('path/to/project') supportCodeLibraryBuilder.methods.Before(this.hook1) // eslint-disable-line babel/new-cap supportCodeLibraryBuilder.methods.Before(this.hook2) // eslint-disable-line babel/new-cap this.options = supportCodeLibraryBuilder.finalize() }) - it('adds the scenario hook definitions in the order of definition', function () { + it('adds the scenario hook definitions in the order of definition', function() { expect(this.options.beforeTestCaseHookDefinitions).to.have.lengthOf(2) expect(this.options.beforeTestCaseHookDefinitions[0].code).to.eql( this.hook1 diff --git a/src/support_code_library_builder/parameter_type_registry_builder.js b/src/support_code_library_builder/parameter_type_registry_builder.js index e7d902aef..1b07dde14 100644 --- a/src/support_code_library_builder/parameter_type_registry_builder.js +++ b/src/support_code_library_builder/parameter_type_registry_builder.js @@ -1,6 +1,6 @@ import { ParameterTypeRegistry } from 'cucumber-expressions' -function build () { +function build() { return new ParameterTypeRegistry() } diff --git a/src/support_code_library_builder/validate_arguments.js b/src/support_code_library_builder/validate_arguments.js index 886e1ce41..26e6437a0 100644 --- a/src/support_code_library_builder/validate_arguments.js +++ b/src/support_code_library_builder/validate_arguments.js @@ -2,7 +2,7 @@ import _ from 'lodash' const optionsValidation = { expectedType: 'object or function', - predicate ({ options }) { + predicate({ options }) { return _.isPlainObject(options) } } @@ -10,14 +10,14 @@ const optionsValidation = { const optionsTimeoutValidation = { identifier: '"options.timeout"', expectedType: 'integer', - predicate ({ options }) { + predicate({ options }) { return !options.timeout || _.isInteger(options.timeout) } } const fnValidation = { expectedType: 'function', - predicate ({ code }) { + predicate({ code }) { return _.isFunction(code) } } @@ -33,7 +33,7 @@ const validations = { { identifier: '"options.tags"', expectedType: 'string', - predicate ({ options }) { + predicate({ options }) { return !options.tags || _.isString(options.tags) } }, @@ -44,7 +44,7 @@ const validations = { { identifier: 'first argument', expectedType: 'string or regular expression', - predicate ({ pattern }) { + predicate({ pattern }) { return _.isRegExp(pattern) || _.isString(pattern) } }, @@ -54,7 +54,7 @@ const validations = { ] } -export default function validateArguments ({ args, fnName, location }) { +export default function validateArguments({ args, fnName, location }) { validations[fnName].forEach(({ identifier, expectedType, predicate }) => { if (!predicate(args)) { throw new Error( diff --git a/src/time.js b/src/time.js index 1c178b244..2583d7f56 100644 --- a/src/time.js +++ b/src/time.js @@ -1,13 +1,13 @@ let previousTimestamp const methods = { - beginTiming () { + beginTiming() { previousTimestamp = getTimestamp() }, clearInterval: clearInterval.bind(global), clearTimeout: clearTimeout.bind(global), Date, - endTiming () { + endTiming() { return getTimestamp() - previousTimestamp }, setInterval: setInterval.bind(global), @@ -19,7 +19,7 @@ if (typeof setImmediate !== 'undefined') { methods.clearImmediate = clearImmediate.bind(global) } -function getTimestamp () { +function getTimestamp() { return new methods.Date().getTime() } diff --git a/src/uncaught_exception_manager.js b/src/uncaught_exception_manager.js index af8b12f62..84068314d 100644 --- a/src/uncaught_exception_manager.js +++ b/src/uncaught_exception_manager.js @@ -1,5 +1,5 @@ export default class UncaughtExceptionManager { - static registerHandler (handler) { + static registerHandler(handler) { if (typeof window === 'undefined') { process.addListener('uncaughtException', handler) } else { @@ -7,7 +7,7 @@ export default class UncaughtExceptionManager { } } - static unregisterHandler (handler) { + static unregisterHandler(handler) { if (typeof window === 'undefined') { process.removeListener('uncaughtException', handler) } else { diff --git a/src/user_code_runner.js b/src/user_code_runner.js index 3a151d562..c4dd2f8d6 100644 --- a/src/user_code_runner.js +++ b/src/user_code_runner.js @@ -4,9 +4,9 @@ import UncaughtExceptionManager from './uncaught_exception_manager' import util from 'util' export default class UserCodeRunner { - static async run ({ argsArray, thisArg, fn, timeoutInMilliseconds }) { - const callbackPromise = new Promise(function (resolve, reject) { - argsArray.push(function (error, result) { + static async run({ argsArray, thisArg, fn, timeoutInMilliseconds }) { + const callbackPromise = new Promise((resolve, reject) => { + argsArray.push((error, result) => { if (error) { reject(error) } else { @@ -44,7 +44,7 @@ export default class UserCodeRunner { } let exceptionHandler - const uncaughtExceptionPromise = new Promise(function (resolve, reject) { + const uncaughtExceptionPromise = new Promise((resolve, reject) => { exceptionHandler = reject UncaughtExceptionManager.registerHandler(exceptionHandler) }) @@ -52,12 +52,9 @@ export default class UserCodeRunner { let timeoutId if (timeoutInMilliseconds >= 0) { - const timeoutPromise = new Promise(function (resolve, reject) { - timeoutId = Time.setTimeout(function () { - const timeoutMessage = - 'function timed out after ' + - timeoutInMilliseconds + - ' milliseconds' + const timeoutPromise = new Promise((resolve, reject) => { + timeoutId = Time.setTimeout(() => { + const timeoutMessage = `function timed out after ${timeoutInMilliseconds} milliseconds` reject(new Error(timeoutMessage)) }, timeoutInMilliseconds) }) diff --git a/src/user_code_runner_spec.js b/src/user_code_runner_spec.js index d602844a0..42c9a321c 100644 --- a/src/user_code_runner_spec.js +++ b/src/user_code_runner_spec.js @@ -1,9 +1,9 @@ import UserCodeRunner from './user_code_runner' import Promise from 'bluebird' -describe('UserCodeRunner', function () { - describe('run()', function () { - beforeEach(function () { +describe('UserCodeRunner', () => { + describe('run()', () => { + beforeEach(function() { this.options = { argsArray: [], thisArg: {}, @@ -11,15 +11,15 @@ describe('UserCodeRunner', function () { } }) - describe('function uses synchronous interface', function () { - describe('function throws serializable error', function () { - beforeEach(function () { - this.options.fn = function () { + describe('function uses synchronous interface', () => { + describe('function throws serializable error', () => { + beforeEach(function() { + this.options.fn = function() { throw 'error' // eslint-disable-line no-throw-literal } }) - it('returns the error', async function () { + it('returns the error', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('error') @@ -27,16 +27,16 @@ describe('UserCodeRunner', function () { }) }) - describe('function throws non-serializable error', function () { - beforeEach(function () { - this.options.fn = function () { + describe('function throws non-serializable error', () => { + beforeEach(function() { + this.options.fn = function() { const error = {} error.error = error throw error } }) - it('returns the error', async function () { + it('returns the error', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('{ error: [Circular] }') @@ -44,14 +44,14 @@ describe('UserCodeRunner', function () { }) }) - describe('function returns', function () { - beforeEach(function () { - this.options.fn = function () { + describe('function returns', () => { + beforeEach(function() { + this.options.fn = function() { return 'result' } }) - it('returns the return value of the function', async function () { + it('returns the return value of the function', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.eql(undefined) expect(result).to.eql('result') @@ -59,21 +59,21 @@ describe('UserCodeRunner', function () { }) }) - describe('function uses callback interface', function () { - describe('function asynchronously throws', function () { + describe('function uses callback interface', () => { + describe('function asynchronously throws', () => { // Cannot unit test because mocha also sets an uncaught exception handler }) - describe('function calls back with serializable error', function () { - beforeEach(function () { - this.options.fn = function (callback) { - setTimeout(function () { + describe('function calls back with serializable error', () => { + beforeEach(function() { + this.options.fn = function(callback) { + setTimeout(() => { callback('error') // eslint-disable-line standard/no-callback-literal }, 25) } }) - it('returns the error', async function () { + it('returns the error', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('error') @@ -81,18 +81,18 @@ describe('UserCodeRunner', function () { }) }) - describe('function calls back with non-serializable rror', function () { - beforeEach(function () { - this.options.fn = function (callback) { + describe('function calls back with non-serializable rror', () => { + beforeEach(function() { + this.options.fn = function(callback) { const error = {} error.error = error - setTimeout(function () { + setTimeout(() => { callback(error) }, 25) } }) - it('returns the error', async function () { + it('returns the error', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('{ error: [Circular] }') @@ -100,32 +100,32 @@ describe('UserCodeRunner', function () { }) }) - describe('function calls back with result', function () { - beforeEach(function () { - this.options.fn = function (callback) { - setTimeout(function () { + describe('function calls back with result', () => { + beforeEach(function() { + this.options.fn = function(callback) { + setTimeout(() => { callback(null, 'result') }, 25) } }) - it('returns the what the function calls back with', async function () { + it('returns the what the function calls back with', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.eql(undefined) expect(result).to.eql('result') }) }) - describe('function times out', function () { - beforeEach(function () { - this.options.fn = function (callback) { - setTimeout(function () { + describe('function times out', () => { + beforeEach(function() { + this.options.fn = function(callback) { + setTimeout(() => { callback(null, 'result') }, 200) } }) - it('returns timeout as an error', async function () { + it('returns timeout as an error', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceof(Error) expect(error.message).to.eql( @@ -135,17 +135,17 @@ describe('UserCodeRunner', function () { }) }) - describe('timeout of -1', function () { - beforeEach(function () { - this.options.fn = function (callback) { - setTimeout(function () { + describe('timeout of -1', () => { + beforeEach(function() { + this.options.fn = function(callback) { + setTimeout(() => { callback(null, 'result') }, 200) } this.options.timeoutInMilliseconds = -1 }) - it('disables timeout protection', async function () { + it('disables timeout protection', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.eql(undefined) expect(result).to.eql('result') @@ -153,33 +153,33 @@ describe('UserCodeRunner', function () { }) }) - describe('function uses promise interface', function () { - describe('function asynchronously throws', function () { + describe('function uses promise interface', () => { + describe('function asynchronously throws', () => { // Cannot unit test because mocha also sets an uncaught exception handler }) - describe('promise resolves', function () { - beforeEach(function () { - this.options.fn = function () { + describe('promise resolves', () => { + beforeEach(function() { + this.options.fn = function() { return Promise.resolve('result') } }) - it('returns what the promise resolves to', async function () { + it('returns what the promise resolves to', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.eql(undefined) expect(result).to.eql('result') }) }) - describe('promise rejects with reason', function () { - beforeEach(function () { - this.options.fn = function () { + describe('promise rejects with reason', () => { + beforeEach(function() { + this.options.fn = function() { return Promise.reject('error') // eslint-disable-line prefer-promise-reject-errors } }) - it('returns what the promise rejects as an error', async function () { + it('returns what the promise rejects as an error', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('error') @@ -187,14 +187,14 @@ describe('UserCodeRunner', function () { }) }) - describe('promise rejects without reason', function () { - beforeEach(function () { - this.options.fn = function () { + describe('promise rejects without reason', () => { + beforeEach(function() { + this.options.fn = function() { return Promise.reject() // eslint-disable-line prefer-promise-reject-errors } }) - it('returns a helpful error message', async function () { + it('returns a helpful error message', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceOf(Error) expect(error.message).to.eql('Promise rejected without a reason') @@ -202,14 +202,14 @@ describe('UserCodeRunner', function () { }) }) - describe('function times out', function () { - beforeEach(function () { - this.options.fn = function () { + describe('function times out', () => { + beforeEach(function() { + this.options.fn = function() { return Promise.resolve('result').delay(200) } }) - it('returns timeout as an error', async function () { + it('returns timeout as an error', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceof(Error) expect(error.message).to.eql( @@ -219,15 +219,15 @@ describe('UserCodeRunner', function () { }) }) - describe('timeout of -1', function () { - beforeEach(function () { - this.options.fn = function () { + describe('timeout of -1', () => { + beforeEach(function() { + this.options.fn = function() { return Promise.resolve('result').delay(200) } this.options.timeoutInMilliseconds = -1 }) - it('disables timeout protection', async function () { + it('disables timeout protection', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.eql(undefined) expect(result).to.eql('result') @@ -235,15 +235,15 @@ describe('UserCodeRunner', function () { }) }) - describe('function uses multiple asynchronous interfaces: callback and promise', function () { - beforeEach(function () { - this.options.fn = function (callback) { + describe('function uses multiple asynchronous interfaces: callback and promise', () => { + beforeEach(function() { + this.options.fn = function(callback) { callback() return Promise.resolve() } }) - it('returns an error that multiple interface are used', async function () { + it('returns an error that multiple interface are used', async function() { const { error, result } = await UserCodeRunner.run(this.options) expect(error).to.be.instanceof(Error) expect(error.message).to.eql( diff --git a/test/listener_helpers.js b/test/listener_helpers.js index 2278d36ae..adf889e6e 100644 --- a/test/listener_helpers.js +++ b/test/listener_helpers.js @@ -1,8 +1,8 @@ -export function expectToHearEvents (listener, expectedEvents) { +export function expectToHearEvents(listener, expectedEvents) { let previousStub = null - let callNumberMapping = {} - expectedEvents.forEach(function ([expectedName, expectedData]) { - const fnName = 'handle' + expectedName + const callNumberMapping = {} + expectedEvents.forEach(([expectedName, expectedData]) => { + const fnName = `handle${expectedName}` if (!callNumberMapping[fnName]) { callNumberMapping[fnName] = 0 } diff --git a/test/test_helper.js b/test/test_helper.js index baf1fa391..4cddba097 100644 --- a/test/test_helper.js +++ b/test/test_helper.js @@ -6,13 +6,11 @@ import sinonChai from 'sinon-chai' chai.use(sinonChai) -function createMock (input) { +function createMock(input) { if (_.isArray(input)) { input = _.zipObject(input) } - return _.mapValues(input, value => { - return sinon.stub().returns(value) - }) + return _.mapValues(input, value => sinon.stub().returns(value)) } _.assign(global, { diff --git a/yarn.lock b/yarn.lock index 8b86d8133..74c4c5c44 100644 --- a/yarn.lock +++ b/yarn.lock @@ -31,11 +31,11 @@ acorn@^5.2.1: version "5.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822" -ajv-keywords@^1.0.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" +ajv-keywords@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" -ajv@^4.7.0, ajv@^4.9.1: +ajv@^4.9.1: version "4.11.8" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" dependencies: @@ -51,6 +51,15 @@ ajv@^5.1.0: json-schema-traverse "^0.3.0" json-stable-stringify "^1.0.1" +ajv@^5.2.3, ajv@^5.3.0: + version "5.5.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -63,9 +72,9 @@ amdefine@>=0.0.4: version "1.0.1" resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" -ansi-escapes@^1.1.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" +ansi-escapes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" ansi-html@^0.0.7: version "0.0.7" @@ -163,13 +172,6 @@ array-unique@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" -array.prototype.find@^2.0.1: - version "2.0.4" - resolved "https://registry.yarnpkg.com/array.prototype.find/-/array.prototype.find-2.0.4.tgz#556a5c5362c08648323ddaeb9de9d14bc1864c90" - dependencies: - define-properties "^1.1.2" - es-abstract "^1.7.0" - arrify@^1.0.0, arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" @@ -271,7 +273,7 @@ babel-code-frame@7.0.0-beta.0: esutils "^2.0.2" js-tokens "^3.0.0" -babel-code-frame@^6.16.0, babel-code-frame@^6.26.0: +babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" dependencies: @@ -1095,7 +1097,7 @@ chai@^4.0.1: pathval "^1.0.0" type-detect "^4.0.0" -chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: +chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: @@ -1113,6 +1115,18 @@ chalk@^2.0.0: escape-string-regexp "^1.0.5" supports-color "^4.0.0" +chalk@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" + dependencies: + ansi-styles "^3.1.0" + escape-string-regexp "^1.0.5" + supports-color "^4.0.0" + +chardet@^0.4.0: + version "0.4.2" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" + check-error@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" @@ -1143,11 +1157,11 @@ circular-json@^0.3.1: version "0.3.3" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" -cli-cursor@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" +cli-cursor@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" dependencies: - restore-cursor "^1.0.1" + restore-cursor "^2.0.0" cli-table@^0.3.1: version "0.3.1" @@ -1232,7 +1246,7 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.5.0, concat-stream@^1.5.2: +concat-stream@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" dependencies: @@ -1335,7 +1349,7 @@ cross-spawn@^4: lru-cache "^4.0.1" which "^1.2.9" -cross-spawn@^5.0.1: +cross-spawn@^5.0.1, cross-spawn@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" dependencies: @@ -1402,17 +1416,17 @@ date-now@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" -debug-log@^1.0.0, debug-log@^1.0.1: +debug-log@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f" -debug@2.6.9, debug@^2.1.1, debug@^2.2.0, debug@^2.6.3, debug@^2.6.8: +debug@2.6.9, debug@^2.2.0, debug@^2.6.3, debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: ms "2.0.0" -debug@3.1.0, debug@^3.0.1: +debug@3.1.0, debug@^3.0.1, debug@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: @@ -1442,28 +1456,10 @@ default-require-extensions@^1.0.0: dependencies: strip-bom "^2.0.0" -define-properties@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" - dependencies: - foreach "^2.0.5" - object-keys "^1.0.8" - defined@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" -deglob@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/deglob/-/deglob-2.1.0.tgz#4d44abe16ef32c779b4972bd141a80325029a14a" - dependencies: - find-root "^1.0.0" - glob "^7.0.5" - ignore "^3.0.9" - pkg-config "^1.1.0" - run-parallel "^1.1.2" - uniq "^1.0.1" - del@^2.0.2: version "2.2.2" resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" @@ -1559,14 +1555,14 @@ docopt@^0.6.0: version "0.6.2" resolved "https://registry.yarnpkg.com/docopt/-/docopt-0.6.2.tgz#b28e9e2220da5ec49f7ea5bb24a47787405eeb11" -doctrine@1.5.0, doctrine@^1.2.2: +doctrine@1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" dependencies: esutils "^2.0.2" isarray "^1.0.0" -doctrine@^2.0.0: +doctrine@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" dependencies: @@ -1615,7 +1611,7 @@ encodeurl@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20" -error-ex@^1.2.0, error-ex@^1.3.1: +error-ex@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" dependencies: @@ -1627,24 +1623,6 @@ error-stack-parser@^2.0.1: dependencies: stackframe "^1.0.3" -es-abstract@^1.7.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.10.0.tgz#1ecb36c197842a00d8ee4c2dfd8646bb97d60864" - dependencies: - es-to-primitive "^1.1.1" - function-bind "^1.1.1" - has "^1.0.1" - is-callable "^1.1.3" - is-regex "^1.0.4" - -es-to-primitive@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d" - dependencies: - is-callable "^1.1.1" - is-date-object "^1.0.1" - is-symbol "^1.0.1" - es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14, es5-ext@~0.10.2: version "0.10.31" resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.31.tgz#7bb938c95a7f1b9f728092dc09c41edcc398eefe" @@ -1652,21 +1630,6 @@ es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14, es5-ext@~0.10.2: es6-iterator "~2.0.1" es6-symbol "~3.1.1" -es5-ext@^0.10.35: - version "0.10.38" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.38.tgz#fa7d40d65bbc9bb8a67e1d3f9cc656a00530eed3" - dependencies: - es6-iterator "~2.0.3" - es6-symbol "~3.1.1" - -es6-iterator@^2.0.1, es6-iterator@~2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" - dependencies: - d "1" - es5-ext "^0.10.35" - es6-symbol "^3.1.1" - es6-iterator@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512" @@ -1675,43 +1638,13 @@ es6-iterator@~2.0.1: es5-ext "^0.10.14" es6-symbol "^3.1" -es6-map@^0.1.3: - version "0.1.5" - resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.5.tgz#9136e0503dcc06a301690f0bb14ff4e364e949f0" - dependencies: - d "1" - es5-ext "~0.10.14" - es6-iterator "~2.0.1" - es6-set "~0.1.5" - es6-symbol "~3.1.1" - event-emitter "~0.3.5" - -es6-set@~0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1" - dependencies: - d "1" - es5-ext "~0.10.14" - es6-iterator "~2.0.1" - es6-symbol "3.1.1" - event-emitter "~0.3.5" - -es6-symbol@3.1.1, es6-symbol@^3.1, es6-symbol@^3.1.1, es6-symbol@~3.1.1: +es6-symbol@^3.1, es6-symbol@~3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" dependencies: d "1" es5-ext "~0.10.14" -es6-weak-map@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" - dependencies: - d "1" - es5-ext "^0.10.14" - es6-iterator "^2.0.1" - es6-symbol "^3.1.1" - escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" @@ -1720,122 +1653,116 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" -escope@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/escope/-/escope-3.6.0.tgz#e01975e812781a163a6dadfdd80398dc64c889c3" +eslint-config-airbnb-base@^12.1.0: + version "12.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-12.1.0.tgz#386441e54a12ccd957b0a92564a4bafebd747944" dependencies: - es6-map "^0.1.3" - es6-weak-map "^2.0.1" - esrecurse "^4.1.0" - estraverse "^4.1.1" - -eslint-config-standard-jsx@4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/eslint-config-standard-jsx/-/eslint-config-standard-jsx-4.0.2.tgz#009e53c4ddb1e9ee70b4650ffe63a7f39f8836e1" + eslint-restricted-globals "^0.1.1" -eslint-config-standard@10.2.1: - version "10.2.1" - resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-10.2.1.tgz#c061e4d066f379dc17cd562c64e819b4dd454591" +eslint-config-prettier@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.9.0.tgz#5ecd65174d486c22dff389fe036febf502d468a3" + dependencies: + get-stdin "^5.0.1" -eslint-import-resolver-node@^0.2.0: - version "0.2.3" - resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.2.3.tgz#5add8106e8c928db2cba232bcd9efa846e3da16c" +eslint-import-resolver-node@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a" dependencies: - debug "^2.2.0" - object-assign "^4.0.1" - resolve "^1.1.6" + debug "^2.6.9" + resolve "^1.5.0" -eslint-module-utils@^2.0.0: +eslint-module-utils@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.1.1.tgz#abaec824177613b8a95b299639e1b6facf473449" dependencies: debug "^2.6.8" pkg-dir "^1.0.0" -eslint-plugin-import@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.2.0.tgz#72ba306fad305d67c4816348a4699a4229ac8b4e" +eslint-plugin-babel@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-babel/-/eslint-plugin-babel-4.1.2.tgz#79202a0e35757dd92780919b2336f1fa2fe53c1e" + +eslint-plugin-import@^2.8.0: + version "2.8.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.8.0.tgz#fa1b6ef31fcb3c501c09859c1b86f1fc5b986894" dependencies: builtin-modules "^1.1.1" contains-path "^0.1.0" - debug "^2.2.0" + debug "^2.6.8" doctrine "1.5.0" - eslint-import-resolver-node "^0.2.0" - eslint-module-utils "^2.0.0" + eslint-import-resolver-node "^0.3.1" + eslint-module-utils "^2.1.1" has "^1.0.1" lodash.cond "^4.3.0" minimatch "^3.0.3" - pkg-up "^1.0.0" + read-pkg-up "^2.0.0" -eslint-plugin-node@~4.2.2: - version "4.2.3" - resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-4.2.3.tgz#c04390ab8dbcbb6887174023d6f3a72769e63b97" +eslint-plugin-prettier@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.5.0.tgz#39a91dd7528eaf19cd42c0ee3f2c1f684606a05f" dependencies: - ignore "^3.0.11" - minimatch "^3.0.2" - object-assign "^4.0.1" - resolve "^1.1.7" - semver "5.3.0" + fast-diff "^1.1.1" + jest-docblock "^21.0.0" -eslint-plugin-promise@~3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.5.0.tgz#78fbb6ffe047201627569e85a6c5373af2a68fca" +eslint-restricted-globals@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz#35f0d5cbc64c2e3ed62e93b4b1a7af05ba7ed4d7" -eslint-plugin-react@~6.10.0: - version "6.10.3" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.10.3.tgz#c5435beb06774e12c7db2f6abaddcbf900cd3f78" +eslint-scope@^3.7.1: + version "3.7.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" dependencies: - array.prototype.find "^2.0.1" - doctrine "^1.2.2" - has "^1.0.1" - jsx-ast-utils "^1.3.4" - object.assign "^4.0.4" - -eslint-plugin-standard@~3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz#34d0c915b45edc6f010393c7eef3823b08565cf2" + esrecurse "^4.1.0" + estraverse "^4.1.1" -eslint@~3.19.0: - version "3.19.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc" - dependencies: - babel-code-frame "^6.16.0" - chalk "^1.1.3" - concat-stream "^1.5.2" - debug "^2.1.1" - doctrine "^2.0.0" - escope "^3.6.0" - espree "^3.4.0" +eslint-visitor-keys@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" + +eslint@^4.16.0: + version "4.16.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.16.0.tgz#934ada9e98715e1d7bbfd6f6f0519ed2fab35cc1" + dependencies: + ajv "^5.3.0" + babel-code-frame "^6.22.0" + chalk "^2.1.0" + concat-stream "^1.6.0" + cross-spawn "^5.1.0" + debug "^3.1.0" + doctrine "^2.1.0" + eslint-scope "^3.7.1" + eslint-visitor-keys "^1.0.0" + espree "^3.5.2" esquery "^1.0.0" - estraverse "^4.2.0" esutils "^2.0.2" file-entry-cache "^2.0.0" - glob "^7.0.3" - globals "^9.14.0" - ignore "^3.2.0" + functional-red-black-tree "^1.0.1" + glob "^7.1.2" + globals "^11.0.1" + ignore "^3.3.3" imurmurhash "^0.1.4" - inquirer "^0.12.0" - is-my-json-valid "^2.10.0" + inquirer "^3.0.6" is-resolvable "^1.0.0" - js-yaml "^3.5.1" - json-stable-stringify "^1.0.0" + js-yaml "^3.9.1" + json-stable-stringify-without-jsonify "^1.0.1" levn "^0.3.0" - lodash "^4.0.0" - mkdirp "^0.5.0" + lodash "^4.17.4" + minimatch "^3.0.2" + mkdirp "^0.5.1" natural-compare "^1.4.0" optionator "^0.8.2" - path-is-inside "^1.0.1" - pluralize "^1.2.1" - progress "^1.1.8" - require-uncached "^1.0.2" - shelljs "^0.7.5" - strip-bom "^3.0.0" + path-is-inside "^1.0.2" + pluralize "^7.0.0" + progress "^2.0.0" + require-uncached "^1.0.3" + semver "^5.3.0" + strip-ansi "^4.0.0" strip-json-comments "~2.0.1" - table "^3.7.8" + table "^4.0.1" text-table "~0.2.0" - user-home "^2.0.0" -espree@^3.4.0: +espree@^3.5.2: version "3.5.2" resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca" dependencies: @@ -1859,7 +1786,7 @@ esrecurse@^4.1.0: estraverse "^4.1.0" object-assign "^4.0.1" -estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: +estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" @@ -1871,13 +1798,6 @@ etag@~1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" -event-emitter@~0.3.5: - version "0.3.5" - resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" - dependencies: - d "1" - es5-ext "~0.10.14" - events@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" @@ -1901,10 +1821,6 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -exit-hook@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" - expand-brackets@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" @@ -1921,6 +1837,14 @@ extend@~3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" +external-editor@^2.0.4: + version "2.1.0" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.1.0.tgz#3d026a21b7f95b5726387d4200ac160d372c3b48" + dependencies: + chardet "^0.4.0" + iconv-lite "^0.4.17" + tmp "^0.0.33" + extglob@^0.3.1: version "0.3.2" resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" @@ -1935,23 +1859,24 @@ fast-deep-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" +fast-diff@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154" + +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + fast-levenshtein@~2.0.4: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" -figures@2.0.0: +figures@2.0.0, figures@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" dependencies: escape-string-regexp "^1.0.5" -figures@^1.3.5: - version "1.7.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" - dependencies: - escape-string-regexp "^1.0.5" - object-assign "^4.1.0" - file-entry-cache@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" @@ -1993,10 +1918,6 @@ find-cache-dir@^0.1.1: mkdirp "^0.5.1" pkg-dir "^1.0.0" -find-root@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4" - find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -2029,10 +1950,6 @@ for-own@^0.1.4: dependencies: for-in "^1.0.1" -foreach@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" - foreground-child@^1.5.3, foreground-child@^1.5.6: version "1.5.6" resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-1.5.6.tgz#4fd71ad2dfde96789b980a5c0a295937cb2f5ce9" @@ -2118,10 +2035,14 @@ fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: mkdirp ">=0.5 0" rimraf "2" -function-bind@^1.0.2, function-bind@^1.1.1: +function-bind@^1.0.2: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" +functional-red-black-tree@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" + gauge@~2.7.3: version "2.7.4" resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" @@ -2135,16 +2056,6 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" -generate-function@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" - -generate-object-property@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" - dependencies: - is-property "^1.0.0" - get-caller-file@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" @@ -2199,7 +2110,11 @@ globals@^10.0.0: version "10.1.0" resolved "https://registry.yarnpkg.com/globals/-/globals-10.1.0.tgz#4425a1881be0d336b4a823a82a7be725d5dd987c" -globals@^9.14.0, globals@^9.18.0: +globals@^11.0.1: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.1.0.tgz#632644457f5f0e3ae711807183700ebf2e4633e4" + +globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" @@ -2268,10 +2183,6 @@ has-flag@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" -has-symbols@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" - has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" @@ -2384,11 +2295,15 @@ https-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" +iconv-lite@^0.4.17: + version "0.4.19" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" + ieee754@^1.1.4: version "1.1.8" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" -ignore@^3.0.11, ignore@^3.0.9, ignore@^3.2.0: +ignore@^3.3.3: version "3.3.7" resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021" @@ -2429,22 +2344,23 @@ inline-source-map@~0.6.0: dependencies: source-map "~0.5.3" -inquirer@^0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.12.0.tgz#1ef2bfd63504df0bc75785fff8c2c41df12f077e" +inquirer@^3.0.6: + version "3.3.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" dependencies: - ansi-escapes "^1.1.0" - ansi-regex "^2.0.0" - chalk "^1.0.0" - cli-cursor "^1.0.1" + ansi-escapes "^3.0.0" + chalk "^2.0.0" + cli-cursor "^2.1.0" cli-width "^2.0.0" - figures "^1.3.5" + external-editor "^2.0.4" + figures "^2.0.0" lodash "^4.3.0" - readline2 "^1.0.1" - run-async "^0.1.0" - rx-lite "^3.1.2" - string-width "^1.0.1" - strip-ansi "^3.0.0" + mute-stream "0.0.7" + run-async "^2.2.0" + rx-lite "^4.0.8" + rx-lite-aggregates "^4.0.8" + string-width "^2.1.0" + strip-ansi "^4.0.0" through "^2.3.6" insert-module-globals@^7.0.0: @@ -2460,10 +2376,6 @@ insert-module-globals@^7.0.0: through2 "^2.0.0" xtend "^4.0.0" -interpret@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" - invariant@^2.2.0, invariant@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" @@ -2494,14 +2406,6 @@ is-builtin-module@^1.0.0: dependencies: builtin-modules "^1.0.0" -is-callable@^1.1.1, is-callable@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2" - -is-date-object@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" - is-dotfile@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" @@ -2546,15 +2450,6 @@ is-glob@^2.0.0, is-glob@^2.0.1: dependencies: is-extglob "^1.0.0" -is-my-json-valid@^2.10.0: - version "2.17.1" - resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.17.1.tgz#3da98914a70a22f0a8563ef1511a246c6fc55471" - dependencies: - generate-function "^2.0.0" - generate-object-property "^1.1.0" - jsonpointer "^4.0.0" - xtend "^4.0.0" - is-number@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" @@ -2591,15 +2486,9 @@ is-primitive@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" -is-property@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" - -is-regex@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" - dependencies: - has "^1.0.1" +is-promise@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" is-resolvable@^1.0.0: version "1.1.0" @@ -2609,10 +2498,6 @@ is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" -is-symbol@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" - is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" @@ -2690,11 +2575,15 @@ istanbul-reports@^1.1.1: dependencies: handlebars "^4.0.3" +jest-docblock@^21.0.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" + js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" -js-yaml@^3.3.1, js-yaml@^3.5.1, js-yaml@^3.6.1: +js-yaml@^3.3.1, js-yaml@^3.6.1, js-yaml@^3.9.1: version "3.10.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" dependencies: @@ -2713,10 +2602,6 @@ jsesc@~0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" -json-parse-better-errors@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.1.tgz#50183cd1b2d25275de069e9e71b467ac9eab973a" - json-schema-traverse@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" @@ -2725,7 +2610,11 @@ json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" -json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + +json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" dependencies: @@ -2765,10 +2654,6 @@ jsonparse@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" -jsonpointer@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" - jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" @@ -2778,10 +2663,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -jsx-ast-utils@^1.3.4: - version "1.4.1" - resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz#3867213e8dd79bf1e8f2300c0cfc1efb182c0df1" - just-extend@^1.1.22: version "1.1.22" resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-1.1.22.tgz#3330af756cab6a542700c64b2e4e4aa062d52fff" @@ -2858,15 +2739,6 @@ load-json-file@^2.0.0: pify "^2.0.0" strip-bom "^3.0.0" -load-json-file@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" - dependencies: - graceful-fs "^4.1.2" - parse-json "^4.0.0" - pify "^3.0.0" - strip-bom "^3.0.0" - locate-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" @@ -2886,7 +2758,7 @@ lodash.memoize@~3.0.3: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" -lodash@^4.0.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: +lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -3013,7 +2885,7 @@ minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" -minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0: +minimist@^1.1.0, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -3070,9 +2942,9 @@ mustache@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/mustache/-/mustache-2.3.0.tgz#4028f7778b17708a489930a6e52ac3bca0da41d0" -mute-stream@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" +mute-stream@0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" mz@^2.4.0: version "2.7.0" @@ -3206,19 +3078,6 @@ object-assign@^4.0.0, object-assign@^4.0.1, object-assign@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" -object-keys@^1.0.11, object-keys@^1.0.8: - version "1.0.11" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" - -object.assign@^4.0.4: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" - dependencies: - define-properties "^1.1.2" - function-bind "^1.1.1" - has-symbols "^1.0.0" - object-keys "^1.0.11" - object.omit@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" @@ -3238,9 +3097,11 @@ once@^1.3.0, once@^1.3.3: dependencies: wrappy "1" -onetime@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" +onetime@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" + dependencies: + mimic-fn "^1.0.0" optimist@^0.6.1: version "0.6.1" @@ -3350,13 +3211,6 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" -parse-json@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" - dependencies: - error-ex "^1.3.1" - json-parse-better-errors "^1.0.1" - parseurl@~1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" @@ -3379,7 +3233,7 @@ path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" -path-is-inside@^1.0.1: +path-is-inside@^1.0.1, path-is-inside@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" @@ -3441,10 +3295,6 @@ pify@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" -pify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" - pinkie-promise@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" @@ -3455,36 +3305,15 @@ pinkie@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" -pkg-conf@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/pkg-conf/-/pkg-conf-2.1.0.tgz#2126514ca6f2abfebd168596df18ba57867f0058" - dependencies: - find-up "^2.0.0" - load-json-file "^4.0.0" - -pkg-config@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/pkg-config/-/pkg-config-1.1.1.tgz#557ef22d73da3c8837107766c52eadabde298fe4" - dependencies: - debug-log "^1.0.0" - find-root "^1.0.0" - xtend "^4.0.1" - pkg-dir@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4" dependencies: find-up "^1.0.0" -pkg-up@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-1.0.0.tgz#3e08fb461525c4421624a33b9f7e6d0af5b05a26" - dependencies: - find-up "^1.0.0" - -pluralize@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" +pluralize@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" prelude-ls@~1.1.2: version "1.1.2" @@ -3494,6 +3323,10 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" +prettier@^1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.10.2.tgz#1af8356d1842276a99a5b5529c82dd9e9ad3cc93" + private@^0.1.6, private@^0.1.7: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -3506,10 +3339,6 @@ process@~0.11.0: version "0.11.10" resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" -progress@^1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" - progress@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" @@ -3650,20 +3479,6 @@ readdirp@^2.0.0: readable-stream "^2.0.2" set-immediate-shim "^1.0.1" -readline2@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/readline2/-/readline2-1.0.1.tgz#41059608ffc154757b715d9989d199ffbf372e35" - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - mute-stream "0.0.5" - -rechoir@^0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" - dependencies: - resolve "^1.1.6" - regenerate@^1.2.1: version "1.3.3" resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.3.tgz#0c336d3980553d755c39b586ae3b20aa49c82b7f" @@ -3788,7 +3603,7 @@ require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" -require-uncached@^1.0.2: +require-uncached@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" dependencies: @@ -3813,18 +3628,18 @@ resolve@^1.1.3, resolve@^1.1.4, resolve@^1.3.3: dependencies: path-parse "^1.0.5" -resolve@^1.1.6, resolve@^1.1.7: +resolve@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" dependencies: path-parse "^1.0.5" -restore-cursor@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" +restore-cursor@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" dependencies: - exit-hook "^1.0.0" - onetime "^1.0.0" + onetime "^2.0.0" + signal-exit "^3.0.2" right-align@^0.1.1: version "0.1.3" @@ -3845,19 +3660,21 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^2.0.0" inherits "^2.0.1" -run-async@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" +run-async@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" dependencies: - once "^1.3.0" + is-promise "^2.1.0" -run-parallel@^1.1.2: - version "1.1.6" - resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.6.tgz#29003c9a2163e01e2d2dfc90575f2c6c1d61a039" +rx-lite-aggregates@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" + dependencies: + rx-lite "*" -rx-lite@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" +rx-lite@*, rx-lite@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.1" @@ -3871,10 +3688,6 @@ samsam@1.x, samsam@^1.1.3: version "5.4.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" -semver@5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" - send@0.16.1: version "0.16.1" resolved "https://registry.yarnpkg.com/send/-/send-0.16.1.tgz#a70e1ca21d1382c11d0d9f6231deb281080d7ab3" @@ -3947,14 +3760,6 @@ shell-quote@^1.6.1: array-reduce "~0.0.0" jsonify "~0.0.0" -shelljs@^0.7.5: - version "0.7.8" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" - dependencies: - glob "^7.0.0" - interpret "^1.0.0" - rechoir "^0.6.2" - signal-exit@^3.0.0, signal-exit@^3.0.1, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" @@ -3982,25 +3787,16 @@ slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" -slice-ansi@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" +slice-ansi@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" + dependencies: + is-fullwidth-code-point "^2.0.0" slide@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" -snazzy@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/snazzy/-/snazzy-7.0.0.tgz#95edaccc4a8d6f80f4ac5cc7b520e8f8f9ac2325" - dependencies: - chalk "^1.1.0" - inherits "^2.0.1" - minimist "^1.1.1" - readable-stream "^2.0.6" - standard-json "^1.0.0" - text-table "^0.2.0" - sntp@1.x.x: version "1.0.9" resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" @@ -4109,35 +3905,6 @@ stacktrace-js@^2.0.0: stack-generator "^2.0.1" stacktrace-gps "^3.0.1" -standard-engine@~7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/standard-engine/-/standard-engine-7.0.0.tgz#ebb77b9c8fc2c8165ffa353bd91ba0dff41af690" - dependencies: - deglob "^2.1.0" - get-stdin "^5.0.1" - minimist "^1.1.0" - pkg-conf "^2.0.0" - -standard-json@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/standard-json/-/standard-json-1.0.2.tgz#82dea4a14c78cd9e35d38cde4b88ac6b62596a23" - dependencies: - concat-stream "^1.5.0" - -standard@^10.0.3: - version "10.0.3" - resolved "https://registry.yarnpkg.com/standard/-/standard-10.0.3.tgz#7869bcbf422bdeeaab689a1ffb1fea9677dd50ea" - dependencies: - eslint "~3.19.0" - eslint-config-standard "10.2.1" - eslint-config-standard-jsx "4.0.2" - eslint-plugin-import "~2.2.0" - eslint-plugin-node "~4.2.2" - eslint-plugin-promise "~3.5.0" - eslint-plugin-react "~6.10.0" - eslint-plugin-standard "~3.0.1" - standard-engine "~7.0.0" - "statuses@>= 1.3.1 < 2", statuses@~1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" @@ -4191,7 +3958,7 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string-width@^2.0.0: +string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" dependencies: @@ -4270,16 +4037,16 @@ syntax-error@^1.1.1: dependencies: acorn "^4.0.3" -table@^3.7.8: - version "3.8.3" - resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" +table@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36" dependencies: - ajv "^4.7.0" - ajv-keywords "^1.0.0" - chalk "^1.1.1" - lodash "^4.0.0" - slice-ansi "0.0.4" - string-width "^2.0.0" + ajv "^5.2.3" + ajv-keywords "^2.1.0" + chalk "^2.1.0" + lodash "^4.17.4" + slice-ansi "1.0.0" + string-width "^2.1.1" tar-pack@^3.4.0: version "3.4.0" @@ -4316,7 +4083,7 @@ text-encoding@0.6.4, text-encoding@^0.6.4: version "0.6.4" resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" -text-table@^0.2.0, text-table@~0.2.0: +text-table@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -4433,10 +4200,6 @@ umd@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/umd/-/umd-3.0.1.tgz#8ae556e11011f63c2596708a8837259f01b3d60e" -uniq@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff" - universalify@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7" @@ -4460,12 +4223,6 @@ user-home@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" -user-home@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f" - dependencies: - os-homedir "^1.0.0" - util-arity@^1.0.2: version "1.1.0" resolved "https://registry.yarnpkg.com/util-arity/-/util-arity-1.1.0.tgz#59d01af1fdb3fede0ac4e632b0ab5f6ce97c9330" @@ -4572,7 +4329,7 @@ write@^0.2.1: dependencies: mkdirp "^0.5.1" -xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: +xtend@^4.0.0, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" From 20ba592cb47e998e1ae3d686dba910ece0f5d4b2 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Tue, 23 Jan 2018 10:30:28 -0800 Subject: [PATCH 06/12] update --- .eslintrc.yml | 15 +-- package.json | 15 ++- src/formatter/rerun_formatter_spec.js | 5 +- yarn.lock | 173 ++++++++++++-------------- 4 files changed, 95 insertions(+), 113 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index df036cb1b..a43e55dd8 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -3,7 +3,7 @@ env: es6: true node: true extends: - - 'eslint:recommended' + - standard - prettier globals: afterEach: false @@ -20,19 +20,6 @@ plugins: - babel - prettier rules: - babel/new-cap: error - complexity: error - eqeqeq: [error, always] - no-await-in-loop: error - no-negated-condition: error - no-nested-ternary: error - no-plusplus: error - no-return-await: error - no-shadow: error - no-unneeded-ternary: [error, {defaultAssignment: false}] - no-unused-expressions: error - no-var: error - object-shorthand: [error, always] prettier/prettier: - error - trailingComma: none diff --git a/package.json b/package.json index d6eba178c..582b749aa 100644 --- a/package.json +++ b/package.json @@ -180,17 +180,20 @@ "connect": "^3.4.0", "coveralls": "^3.0.0", "dependency-lint": "^5.0.1", - "eslint": "^4.16.0", - "eslint-config-airbnb-base": "^12.1.0", - "eslint-config-prettier": "^2.9.0", - "eslint-plugin-babel": "^4.1.2", + "eslint": "^4.1.1", + "eslint-config-prettier": "^2.2.0", + "eslint-config-standard": "^11.0.0-beta.0", + "eslint-plugin-babel": "^4.0.0", "eslint-plugin-import": "^2.8.0", - "eslint-plugin-prettier": "^2.5.0", + "eslint-plugin-node": "^5.2.1", + "eslint-plugin-prettier": "^2.1.2", + "eslint-plugin-promise": "^3.6.0", + "eslint-plugin-standard": "^3.0.1", "fs-extra": "^4.0.2", "mocha": "^4.0.1", "mustache": "^2.3.0", "nyc": "^11.0.2", - "prettier": "^1.10.2", + "prettier": "^1.5.2", "regenerator-runtime": "^0.11.0", "serve-static": "^1.10.0", "sinon": "^4.0.1", diff --git a/src/formatter/rerun_formatter_spec.js b/src/formatter/rerun_formatter_spec.js index b1f6ec10f..a6ecd2ef6 100644 --- a/src/formatter/rerun_formatter_spec.js +++ b/src/formatter/rerun_formatter_spec.js @@ -118,9 +118,8 @@ describe('RerunFormatter', () => { it('outputs the references needed to run the scenarios again', function() { expect(this.output).to.eql( - `${this.feature1Path}:1${separator.expected}${ - this.feature2Path - }:2` + `${this.feature1Path}:1${separator.expected}${this + .feature2Path}:2` ) }) }) diff --git a/yarn.lock b/yarn.lock index 74c4c5c44..0f8e68fc4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -27,13 +27,13 @@ acorn@^4.0.3: version "4.0.13" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787" -acorn@^5.2.1: - version "5.3.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822" +acorn@^5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.2.tgz#911cb53e036807cf0fa778dc5d370fbd864246d7" ajv-keywords@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" + version "2.1.0" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.0.tgz#a296e17f7bfae7c1ce4f7e0de53d29cb32162df0" ajv@^4.9.1: version "4.11.8" @@ -42,7 +42,7 @@ ajv@^4.9.1: co "^4.6.0" json-stable-stringify "^1.0.1" -ajv@^5.1.0: +ajv@^5.1.0, ajv@^5.2.0, ajv@^5.2.3: version "5.2.3" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.2.3.tgz#c06f598778c44c6b161abafe3466b81ad1814ed2" dependencies: @@ -51,15 +51,6 @@ ajv@^5.1.0: json-schema-traverse "^0.3.0" json-stable-stringify "^1.0.1" -ajv@^5.2.3, ajv@^5.3.0: - version "5.5.2" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" - dependencies: - co "^4.6.0" - fast-deep-equal "^1.0.0" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.3.0" - align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -1107,7 +1098,7 @@ chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0: +chalk@^2.0.0, chalk@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" dependencies: @@ -1115,18 +1106,6 @@ chalk@^2.0.0: escape-string-regexp "^1.0.5" supports-color "^4.0.0" -chalk@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" - dependencies: - ansi-styles "^3.1.0" - escape-string-regexp "^1.0.5" - supports-color "^4.0.0" - -chardet@^0.4.0: - version "0.4.2" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" - check-error@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" @@ -1426,7 +1405,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.6.3, debug@^2.6.8, debug@^2.6.9: dependencies: ms "2.0.0" -debug@3.1.0, debug@^3.0.1, debug@^3.1.0: +debug@3.1.0, debug@^3.0.1: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: @@ -1562,11 +1541,12 @@ doctrine@1.5.0: esutils "^2.0.2" isarray "^1.0.0" -doctrine@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" +doctrine@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.0.tgz#c73d8d2909d22291e1a007a395804da8b665fe63" dependencies: esutils "^2.0.2" + isarray "^1.0.0" domain-browser@~1.1.0: version "1.1.7" @@ -1653,18 +1633,16 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" -eslint-config-airbnb-base@^12.1.0: - version "12.1.0" - resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-12.1.0.tgz#386441e54a12ccd957b0a92564a4bafebd747944" - dependencies: - eslint-restricted-globals "^0.1.1" - -eslint-config-prettier@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.9.0.tgz#5ecd65174d486c22dff389fe036febf502d468a3" +eslint-config-prettier@^2.2.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.6.0.tgz#f21db0ebb438ad678fb98946097c4bb198befccc" dependencies: get-stdin "^5.0.1" +eslint-config-standard@^11.0.0-beta.0: + version "11.0.0-beta.0" + resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-11.0.0-beta.0.tgz#f8afe69803d95c685a4b8392b8793188eb03cbb3" + eslint-import-resolver-node@^0.3.1: version "0.3.2" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a" @@ -1679,7 +1657,7 @@ eslint-module-utils@^2.1.1: debug "^2.6.8" pkg-dir "^1.0.0" -eslint-plugin-babel@^4.1.2: +eslint-plugin-babel@^4.0.0: version "4.1.2" resolved "https://registry.yarnpkg.com/eslint-plugin-babel/-/eslint-plugin-babel-4.1.2.tgz#79202a0e35757dd92780919b2336f1fa2fe53c1e" @@ -1698,16 +1676,29 @@ eslint-plugin-import@^2.8.0: minimatch "^3.0.3" read-pkg-up "^2.0.0" -eslint-plugin-prettier@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.5.0.tgz#39a91dd7528eaf19cd42c0ee3f2c1f684606a05f" +eslint-plugin-node@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-5.2.1.tgz#80df3253c4d7901045ec87fa660a284e32bdca29" + dependencies: + ignore "^3.3.6" + minimatch "^3.0.4" + resolve "^1.3.3" + semver "5.3.0" + +eslint-plugin-prettier@^2.1.2: + version "2.3.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.3.1.tgz#e7a746c67e716f335274b88295a9ead9f544e44d" dependencies: fast-diff "^1.1.1" jest-docblock "^21.0.0" -eslint-restricted-globals@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz#35f0d5cbc64c2e3ed62e93b4b1a7af05ba7ed4d7" +eslint-plugin-promise@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.6.0.tgz#54b7658c8f454813dc2a870aff8152ec4969ba75" + +eslint-plugin-standard@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz#34d0c915b45edc6f010393c7eef3823b08565cf2" eslint-scope@^3.7.1: version "3.7.1" @@ -1716,36 +1707,32 @@ eslint-scope@^3.7.1: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-visitor-keys@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" - -eslint@^4.16.0: - version "4.16.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.16.0.tgz#934ada9e98715e1d7bbfd6f6f0519ed2fab35cc1" +eslint@^4.1.1: + version "4.8.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.8.0.tgz#229ef0e354e0e61d837c7a80fdfba825e199815e" dependencies: - ajv "^5.3.0" + ajv "^5.2.0" babel-code-frame "^6.22.0" chalk "^2.1.0" concat-stream "^1.6.0" cross-spawn "^5.1.0" - debug "^3.1.0" - doctrine "^2.1.0" + debug "^3.0.1" + doctrine "^2.0.0" eslint-scope "^3.7.1" - eslint-visitor-keys "^1.0.0" - espree "^3.5.2" + espree "^3.5.1" esquery "^1.0.0" + estraverse "^4.2.0" esutils "^2.0.2" file-entry-cache "^2.0.0" functional-red-black-tree "^1.0.1" glob "^7.1.2" - globals "^11.0.1" + globals "^9.17.0" ignore "^3.3.3" imurmurhash "^0.1.4" inquirer "^3.0.6" is-resolvable "^1.0.0" js-yaml "^3.9.1" - json-stable-stringify-without-jsonify "^1.0.1" + json-stable-stringify "^1.0.1" levn "^0.3.0" lodash "^4.17.4" minimatch "^3.0.2" @@ -1762,11 +1749,11 @@ eslint@^4.16.0: table "^4.0.1" text-table "~0.2.0" -espree@^3.5.2: - version "3.5.2" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca" +espree@^3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.1.tgz#0c988b8ab46db53100a1954ae4ba995ddd27d87e" dependencies: - acorn "^5.2.1" + acorn "^5.1.1" acorn-jsx "^3.0.0" esprima@^4.0.0: @@ -1786,7 +1773,7 @@ esrecurse@^4.1.0: estraverse "^4.1.0" object-assign "^4.0.1" -estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1: +estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" @@ -1838,11 +1825,11 @@ extend@~3.0.0, extend@~3.0.1: resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" external-editor@^2.0.4: - version "2.1.0" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.1.0.tgz#3d026a21b7f95b5726387d4200ac160d372c3b48" + version "2.0.5" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.0.5.tgz#52c249a3981b9ba187c7cacf5beb50bf1d91a6bc" dependencies: - chardet "^0.4.0" iconv-lite "^0.4.17" + jschardet "^1.4.2" tmp "^0.0.33" extglob@^0.3.1: @@ -1863,10 +1850,6 @@ fast-diff@^1.1.1: version "1.1.2" resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154" -fast-json-stable-stringify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" - fast-levenshtein@~2.0.4: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" @@ -2110,11 +2093,7 @@ globals@^10.0.0: version "10.1.0" resolved "https://registry.yarnpkg.com/globals/-/globals-10.1.0.tgz#4425a1881be0d336b4a823a82a7be725d5dd987c" -globals@^11.0.1: - version "11.1.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.1.0.tgz#632644457f5f0e3ae711807183700ebf2e4633e4" - -globals@^9.18.0: +globals@^9.17.0, globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" @@ -2304,6 +2283,10 @@ ieee754@^1.1.4: resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" ignore@^3.3.3: + version "3.3.5" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.5.tgz#c4e715455f6073a8d7e5dae72d2fc9d71663dba6" + +ignore@^3.3.6: version "3.3.7" resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021" @@ -2473,8 +2456,8 @@ is-path-in-cwd@^1.0.0: is-path-inside "^1.0.0" is-path-inside@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.0.tgz#fc06e5a1683fbda13de667aff717bbc10a48f37f" dependencies: path-is-inside "^1.0.1" @@ -2491,8 +2474,10 @@ is-promise@^2.1.0: resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" is-resolvable@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88" + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62" + dependencies: + tryit "^1.0.1" is-stream@^1.1.0: version "1.1.0" @@ -2594,6 +2579,10 @@ jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" +jschardet@^1.4.2: + version "1.5.1" + resolved "https://registry.yarnpkg.com/jschardet/-/jschardet-1.5.1.tgz#c519f629f86b3a5bedba58a88d311309eec097f9" + jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" @@ -2610,10 +2599,6 @@ json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" -json-stable-stringify-without-jsonify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" - json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" @@ -3323,9 +3308,9 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -prettier@^1.10.2: - version "1.10.2" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.10.2.tgz#1af8356d1842276a99a5b5529c82dd9e9ad3cc93" +prettier@^1.5.2: + version "1.7.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.4.tgz#5e8624ae9363c80f95ec644584ecdf55d74f93fa" private@^0.1.6, private@^0.1.7: version "0.1.8" @@ -3688,6 +3673,10 @@ samsam@1.x, samsam@^1.1.3: version "5.4.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" +semver@5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + send@0.16.1: version "0.16.1" resolved "https://registry.yarnpkg.com/send/-/send-0.16.1.tgz#a70e1ca21d1382c11d0d9f6231deb281080d7ab3" @@ -4151,6 +4140,10 @@ trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" +tryit@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" + tty-browserify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" From 08b657e4211c208dc43ebef14e182be07812a08e Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Tue, 23 Jan 2018 10:56:47 -0800 Subject: [PATCH 07/12] update --- dependency-lint.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dependency-lint.yml b/dependency-lint.yml index abb9acb17..c9a84ed36 100644 --- a/dependency-lint.yml +++ b/dependency-lint.yml @@ -36,8 +36,13 @@ ignoreErrors: - coffee-script # features/compiler.feature - coveralls # .travis.yml - eslint-config-prettier # .eslintrc.yml - extends + - eslint-config-standard # .eslintrc.yml - extends - eslint-plugin-babel # .eslintrc.yml - parser + - eslint-plugin-import # peer dependency of eslint-config-standard + - eslint-plugin-node # peer dependency of eslint-config-standard - eslint-plugin-prettier # .eslintrc.yml - plugins + - eslint-plugin-promise # peer dependency of eslint-config-standard + - eslint-plugin-standard # peer dependency of eslint-config-standard - prettier # peer dependency of eslint-plugin-prettier requiredModules: From 5355a2e05e46cad12ac33cbe174d1711dcbea026 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Wed, 24 Jan 2018 15:59:20 -0800 Subject: [PATCH 08/12] remove globals --- .eslintrc.yml | 8 -------- src/cli/configuration_builder_spec.js | 2 ++ src/cli/helpers_spec.js | 3 +++ src/cli/option_splitter_spec.js | 2 ++ src/cli/profile_loader_spec.js | 2 ++ src/formatter/helpers/issue_helpers_spec.js | 3 +++ src/formatter/helpers/keyword_type_spec.js | 2 ++ src/formatter/helpers/summary_helpers_spec.js | 2 ++ .../helpers/usage_helpers/index_spec.js | 2 ++ src/formatter/json_formatter_spec.js | 2 ++ src/formatter/progress_bar_formatter_spec.js | 4 ++++ src/formatter/progress_formatter_spec.js | 2 ++ src/formatter/rerun_formatter_spec.js | 2 ++ .../index_spec.js | 3 +++ .../javascript_snippet_syntax_spec.js | 2 ++ src/formatter/summary_formatter_spec.js | 3 +++ src/formatter/test_helpers.js | 9 +++++++++ src/formatter/usage_formatter_spec.js | 2 ++ src/formatter/usage_json_formatter_spec.js | 2 ++ src/models/data_table_spec.js | 2 ++ src/models/test_case_hook_definition_spec.js | 2 ++ src/pickle_filter_spec.js | 2 ++ src/runtime/attachment_manager/index_spec.js | 3 +++ src/runtime/helpers_spec.js | 2 ++ src/runtime/test_case_runner_spec.js | 3 +++ src/status_spec.js | 2 ++ src/support_code_library_builder/index_spec.js | 3 +++ src/user_code_runner_spec.js | 2 ++ test/listener_helpers.js | 2 ++ test/test_helper.js | 16 ---------------- 30 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 src/formatter/test_helpers.js diff --git a/.eslintrc.yml b/.eslintrc.yml index a43e55dd8..dda553875 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -5,14 +5,6 @@ env: extends: - standard - prettier -globals: - afterEach: false - beforeEach: false - createMock: false - describe: false - expect: false - it: false - sinon: false parser: babel-eslint parserOptions: sourceType: module diff --git a/src/cli/configuration_builder_spec.js b/src/cli/configuration_builder_spec.js index a0c05ead7..5e4066bdf 100644 --- a/src/cli/configuration_builder_spec.js +++ b/src/cli/configuration_builder_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import { promisify } from 'bluebird' import ConfigurationBuilder from './configuration_builder' import fsExtra from 'fs-extra' diff --git a/src/cli/helpers_spec.js b/src/cli/helpers_spec.js index ea33d6fab..9e5569d24 100644 --- a/src/cli/helpers_spec.js +++ b/src/cli/helpers_spec.js @@ -1,3 +1,6 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' +import sinon from 'sinon' import { getTestCasesFromFilesystem } from './helpers' import { promisify } from 'bluebird' import EventEmitter from 'events' diff --git a/src/cli/option_splitter_spec.js b/src/cli/option_splitter_spec.js index 1d414e0a8..5a0fbe6b9 100644 --- a/src/cli/option_splitter_spec.js +++ b/src/cli/option_splitter_spec.js @@ -1,3 +1,5 @@ +import { describe, it } from 'mocha' +import { expect } from 'chai' import OptionSplitter from './option_splitter' describe('OptionSplitter', () => { diff --git a/src/cli/profile_loader_spec.js b/src/cli/profile_loader_spec.js index ae2056fd0..31c36b0d6 100644 --- a/src/cli/profile_loader_spec.js +++ b/src/cli/profile_loader_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import { promisify } from 'bluebird' import fs from 'mz/fs' import path from 'path' diff --git a/src/formatter/helpers/issue_helpers_spec.js b/src/formatter/helpers/issue_helpers_spec.js index 9bb5d9bcb..62c105d09 100644 --- a/src/formatter/helpers/issue_helpers_spec.js +++ b/src/formatter/helpers/issue_helpers_spec.js @@ -1,3 +1,6 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' +import { createMock } from '../test_helpers' import getColorFns from '../get_color_fns' import Status from '../../status' import { formatIssue } from './issue_helpers' diff --git a/src/formatter/helpers/keyword_type_spec.js b/src/formatter/helpers/keyword_type_spec.js index b5774db6a..7199972ec 100644 --- a/src/formatter/helpers/keyword_type_spec.js +++ b/src/formatter/helpers/keyword_type_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import KeywordType, { getStepKeywordType } from './keyword_type' describe('KeywordType', () => { diff --git a/src/formatter/helpers/summary_helpers_spec.js b/src/formatter/helpers/summary_helpers_spec.js index 219013a8c..570b01ac3 100644 --- a/src/formatter/helpers/summary_helpers_spec.js +++ b/src/formatter/helpers/summary_helpers_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import getColorFns from '../get_color_fns' import { formatSummary } from './summary_helpers' import Status from '../../status' diff --git a/src/formatter/helpers/usage_helpers/index_spec.js b/src/formatter/helpers/usage_helpers/index_spec.js index d29e60ff4..6f151cdef 100644 --- a/src/formatter/helpers/usage_helpers/index_spec.js +++ b/src/formatter/helpers/usage_helpers/index_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import { getUsage } from './' import EventEmitter from 'events' import Gherkin from 'gherkin' diff --git a/src/formatter/json_formatter_spec.js b/src/formatter/json_formatter_spec.js index d9c6ff7e5..d77f07971 100644 --- a/src/formatter/json_formatter_spec.js +++ b/src/formatter/json_formatter_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import JsonFormatter from './json_formatter' import Status from '../status' import EventEmitter from 'events' diff --git a/src/formatter/progress_bar_formatter_spec.js b/src/formatter/progress_bar_formatter_spec.js index eaf03875d..b554dfb3b 100644 --- a/src/formatter/progress_bar_formatter_spec.js +++ b/src/formatter/progress_bar_formatter_spec.js @@ -1,3 +1,7 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' +import { createMock } from '../test_helpers' +import sinon from 'sinon' import getColorFns from './get_color_fns' import ProgressBarFormatter from './progress_bar_formatter' import Status from '../status' diff --git a/src/formatter/progress_formatter_spec.js b/src/formatter/progress_formatter_spec.js index b32dcf34e..397a474ef 100644 --- a/src/formatter/progress_formatter_spec.js +++ b/src/formatter/progress_formatter_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import getColorFns from './get_color_fns' import ProgressFormatter from './progress_formatter' import Status from '../status' diff --git a/src/formatter/rerun_formatter_spec.js b/src/formatter/rerun_formatter_spec.js index a6ecd2ef6..1c0c93631 100644 --- a/src/formatter/rerun_formatter_spec.js +++ b/src/formatter/rerun_formatter_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import _ from 'lodash' import path from 'path' import RerunFormatter from './rerun_formatter' diff --git a/src/formatter/step_definition_snippet_builder/index_spec.js b/src/formatter/step_definition_snippet_builder/index_spec.js index ab1e81418..3ce822740 100644 --- a/src/formatter/step_definition_snippet_builder/index_spec.js +++ b/src/formatter/step_definition_snippet_builder/index_spec.js @@ -1,3 +1,6 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' +import { createMock } from '../test_helpers' import { KeywordType } from '../helpers' import StepDefinitionSnippetBuilder from './' import TransformLookupBuilder from '../../support_code_library_builder/parameter_type_registry_builder' diff --git a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js index 3700b5147..6563fe785 100644 --- a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js +++ b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import JavascriptSnippetSyntax from './javascript_snippet_syntax' describe('JavascriptSnippetSyntax', () => { diff --git a/src/formatter/summary_formatter_spec.js b/src/formatter/summary_formatter_spec.js index 8dba3468d..7084473d6 100644 --- a/src/formatter/summary_formatter_spec.js +++ b/src/formatter/summary_formatter_spec.js @@ -1,3 +1,6 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' +import { createMock } from '../test_helpers' import getColorFns from './get_color_fns' import Status from '../status' import SummaryFormatter from './summary_formatter' diff --git a/src/formatter/test_helpers.js b/src/formatter/test_helpers.js new file mode 100644 index 000000000..f021cb2a5 --- /dev/null +++ b/src/formatter/test_helpers.js @@ -0,0 +1,9 @@ +import _ from 'lodash' +import sinon from 'sinon' + +export function createMock(input) { + if (_.isArray(input)) { + input = _.zipObject(input) + } + return _.mapValues(input, value => sinon.stub().returns(value)) +} diff --git a/src/formatter/usage_formatter_spec.js b/src/formatter/usage_formatter_spec.js index bb9093b14..df1cdb305 100644 --- a/src/formatter/usage_formatter_spec.js +++ b/src/formatter/usage_formatter_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import UsageFormatter from './usage_formatter' import EventEmitter from 'events' import Gherkin from 'gherkin' diff --git a/src/formatter/usage_json_formatter_spec.js b/src/formatter/usage_json_formatter_spec.js index 0a43d8b2b..a5ee0a010 100644 --- a/src/formatter/usage_json_formatter_spec.js +++ b/src/formatter/usage_json_formatter_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import UsageJsonFormatter from './usage_json_formatter' import EventEmitter from 'events' import Gherkin from 'gherkin' diff --git a/src/models/data_table_spec.js b/src/models/data_table_spec.js index 2e0205be8..7c741ab92 100644 --- a/src/models/data_table_spec.js +++ b/src/models/data_table_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import DataTable from './data_table' describe('DataTable', () => { diff --git a/src/models/test_case_hook_definition_spec.js b/src/models/test_case_hook_definition_spec.js index 6ecca1149..2a78149b3 100644 --- a/src/models/test_case_hook_definition_spec.js +++ b/src/models/test_case_hook_definition_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import TestCaseHookDefinition from './test_case_hook_definition' describe('TestCaseHookDefinition', () => { diff --git a/src/pickle_filter_spec.js b/src/pickle_filter_spec.js index 97876fa25..b9e136a2b 100644 --- a/src/pickle_filter_spec.js +++ b/src/pickle_filter_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import PickleFilter from './pickle_filter' describe('PickleFilter', () => { diff --git a/src/runtime/attachment_manager/index_spec.js b/src/runtime/attachment_manager/index_spec.js index db89a137e..ad26c56b8 100644 --- a/src/runtime/attachment_manager/index_spec.js +++ b/src/runtime/attachment_manager/index_spec.js @@ -1,3 +1,6 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' +import sinon from 'sinon' import AttachmentManager from './' import stream from 'stream' diff --git a/src/runtime/helpers_spec.js b/src/runtime/helpers_spec.js index 3dce5c0cb..58ff6dc73 100644 --- a/src/runtime/helpers_spec.js +++ b/src/runtime/helpers_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import { getAmbiguousStepException } from './helpers' describe('Helpers', () => { diff --git a/src/runtime/test_case_runner_spec.js b/src/runtime/test_case_runner_spec.js index 38a12be84..931ccac35 100644 --- a/src/runtime/test_case_runner_spec.js +++ b/src/runtime/test_case_runner_spec.js @@ -1,3 +1,6 @@ +import { afterEach, beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' +import sinon from 'sinon' import TestCaseHookDefinition from '../models/test_case_hook_definition' import TestCaseRunner from './test_case_runner' import Status from '../status' diff --git a/src/status_spec.js b/src/status_spec.js index 4ad611bae..6f17534e0 100644 --- a/src/status_spec.js +++ b/src/status_spec.js @@ -1,3 +1,5 @@ +import { describe, it } from 'mocha' +import { expect } from 'chai' import Status, { getStatusMapping } from './status' describe('Status', () => { diff --git a/src/support_code_library_builder/index_spec.js b/src/support_code_library_builder/index_spec.js index 2ef521696..bf3b6d74b 100644 --- a/src/support_code_library_builder/index_spec.js +++ b/src/support_code_library_builder/index_spec.js @@ -1,3 +1,6 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' +import sinon from 'sinon' import { ParameterTypeRegistry } from 'cucumber-expressions' import supportCodeLibraryBuilder from './' diff --git a/src/user_code_runner_spec.js b/src/user_code_runner_spec.js index 42c9a321c..d5f65cc12 100644 --- a/src/user_code_runner_spec.js +++ b/src/user_code_runner_spec.js @@ -1,3 +1,5 @@ +import { beforeEach, describe, it } from 'mocha' +import { expect } from 'chai' import UserCodeRunner from './user_code_runner' import Promise from 'bluebird' diff --git a/test/listener_helpers.js b/test/listener_helpers.js index adf889e6e..abdfcbe2e 100644 --- a/test/listener_helpers.js +++ b/test/listener_helpers.js @@ -1,3 +1,5 @@ +import { expect } from 'chai' + export function expectToHearEvents(listener, expectedEvents) { let previousStub = null const callNumberMapping = {} diff --git a/test/test_helper.js b/test/test_helper.js index 4cddba097..fef3b28cc 100644 --- a/test/test_helper.js +++ b/test/test_helper.js @@ -1,21 +1,5 @@ -import _ from 'lodash' import 'regenerator-runtime/runtime' import chai from 'chai' -import sinon from 'sinon' import sinonChai from 'sinon-chai' chai.use(sinonChai) - -function createMock(input) { - if (_.isArray(input)) { - input = _.zipObject(input) - } - return _.mapValues(input, value => sinon.stub().returns(value)) -} - -_.assign(global, { - chai, - createMock, - expect: chai.expect, - sinon -}) From 7ef837bf22ca6b32131b1e5d82fbd495a3b9ef3f Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Wed, 24 Jan 2018 16:03:33 -0800 Subject: [PATCH 09/12] fix --- src/formatter/progress_bar_formatter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/formatter/progress_bar_formatter_spec.js b/src/formatter/progress_bar_formatter_spec.js index eaf03875d..5ef51be7f 100644 --- a/src/formatter/progress_bar_formatter_spec.js +++ b/src/formatter/progress_bar_formatter_spec.js @@ -290,7 +290,7 @@ describe('ProgressBarFormatter', () => { it('prints the warning', function() { expect( this.progressBarFormatter.progressBar.interrupt - ).to.have.callCount(0) + ).to.have.callCount(1) }) }) }) From 15363ec73fed0328db07195c9812888bf91c9d38 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Wed, 24 Jan 2018 16:09:58 -0800 Subject: [PATCH 10/12] trailing comma --- .eslintrc.yml | 2 +- example/index.js | 6 +- .../step_definitions/json_output_steps.js | 26 +-- features/support/json_output_helpers.js | 2 +- features/support/world.js | 4 +- src/cli/argv_parser.js | 2 +- src/cli/configuration_builder.js | 8 +- src/cli/configuration_builder_spec.js | 27 +-- src/cli/helpers.js | 6 +- src/cli/helpers_spec.js | 14 +- src/cli/i18n.js | 10 +- src/cli/index.js | 14 +- src/cli/install_validator.js | 2 +- src/cli/option_splitter_spec.js | 12 +- src/cli/run.js | 2 +- src/formatter/builder.js | 6 +- src/formatter/event_protocol_formatter.js | 2 +- src/formatter/get_color_fns.js | 2 +- src/formatter/helpers/error_helpers.js | 4 +- src/formatter/helpers/event_data_collector.js | 2 +- src/formatter/helpers/issue_helpers.js | 22 +-- src/formatter/helpers/issue_helpers_spec.js | 28 +-- src/formatter/helpers/keyword_type.js | 2 +- src/formatter/helpers/keyword_type_spec.js | 16 +- src/formatter/helpers/pickle_parser.js | 2 +- src/formatter/helpers/step_result_helpers.js | 6 +- src/formatter/helpers/summary_helpers.js | 6 +- src/formatter/helpers/summary_helpers_spec.js | 58 +++--- src/formatter/helpers/usage_helpers/index.js | 6 +- .../helpers/usage_helpers/index_spec.js | 12 +- src/formatter/index.js | 2 +- src/formatter/json_formatter.js | 26 +-- src/formatter/json_formatter_spec.js | 116 ++++++------ src/formatter/progress_bar_formatter.js | 8 +- src/formatter/progress_bar_formatter_spec.js | 90 +++++----- src/formatter/progress_formatter.js | 2 +- src/formatter/progress_formatter_spec.js | 18 +- src/formatter/rerun_formatter_spec.js | 20 +-- src/formatter/snippets_formatter.js | 12 +- .../step_definition_snippet_builder/index.js | 4 +- .../index_spec.js | 6 +- .../javascript_snippet_syntax_spec.js | 40 ++--- src/formatter/summary_formatter.js | 6 +- src/formatter/summary_formatter_spec.js | 60 +++---- src/formatter/usage_formatter.js | 6 +- src/formatter/usage_formatter_spec.js | 46 ++--- src/formatter/usage_json_formatter.js | 2 +- src/formatter/usage_json_formatter_spec.js | 42 ++--- src/index.js | 2 +- src/models/data_table_spec.js | 26 +-- src/models/step_definition.js | 2 +- src/models/test_case_hook_definition.js | 2 +- src/models/test_case_hook_definition_spec.js | 10 +- src/pickle_filter_spec.js | 26 +-- src/runtime/attachment_manager/index.js | 2 +- src/runtime/attachment_manager/index_spec.js | 6 +- src/runtime/helpers.js | 6 +- src/runtime/helpers_spec.js | 4 +- src/runtime/index.js | 6 +- src/runtime/parallel/command_types.js | 2 +- src/runtime/parallel/master.js | 10 +- src/runtime/parallel/run_slave.js | 2 +- src/runtime/parallel/slave.js | 8 +- src/runtime/step_runner.js | 6 +- src/runtime/test_case_runner.js | 26 +-- src/runtime/test_case_runner_spec.js | 166 +++++++++--------- src/status.js | 2 +- src/status_spec.js | 4 +- .../define_helpers.js | 14 +- .../finalize_helpers.js | 2 +- src/support_code_library_builder/index.js | 10 +- .../index_spec.js | 2 +- .../validate_arguments.js | 18 +- src/time.js | 2 +- src/user_code_runner.js | 2 +- src/user_code_runner_spec.js | 2 +- 76 files changed, 595 insertions(+), 592 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index dda553875..d005c409e 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -14,6 +14,6 @@ plugins: rules: prettier/prettier: - error - - trailingComma: none + - trailingComma: es5 singleQuote: true semi: false diff --git a/example/index.js b/example/index.js index 57effff16..0ecff37c6 100644 --- a/example/index.js +++ b/example/index.js @@ -18,7 +18,7 @@ function runFeature() { eventBroadcaster, pickleFilter: new Cucumber.PickleFilter({}), source: featureSource, - uri: '/feature' + uri: '/feature', }) Cucumber.supportCodeLibraryBuilder.reset('') @@ -33,7 +33,7 @@ function runFeature() { log(data) { appendToOutput(ansiHTML(data)) }, - supportCodeLibrary + supportCodeLibrary, } Cucumber.FormatterBuilder.build('progress', formatterOptions) @@ -41,7 +41,7 @@ function runFeature() { eventBroadcaster, options: {}, testCases, - supportCodeLibrary + supportCodeLibrary, }) return runtime.start() } diff --git a/features/step_definitions/json_output_steps.js b/features/step_definitions/json_output_steps.js index 2cfa56c35..12952679c 100644 --- a/features/step_definitions/json_output_steps.js +++ b/features/step_definitions/json_output_steps.js @@ -7,7 +7,7 @@ import { getScenarioNames, getSteps, findScenario, - findStep + findStep, } from '../support/json_output_helpers' Then(/^it runs (\d+) scenarios$/, function(count) { @@ -33,7 +33,7 @@ Then(/^it runs the scenarios:$/, function(table) { Then(/^the scenario "([^"]*)" has the steps$/, function(name, table) { const scenario = findScenario({ features: this.lastRun.jsonOutput, - scenarioPredicate: ['name', name] + scenarioPredicate: ['name', name], }) const expectedNames = table.rows().map(row => row[0]) const actualNames = scenario.steps.map(step => @@ -45,7 +45,7 @@ Then(/^the scenario "([^"]*)" has the steps$/, function(name, table) { Then(/^the step "([^"]*)" failed with:$/, function(name, errorMessage) { const step = findStep({ features: this.lastRun.jsonOutput, - stepPredicate: ['name', name] + stepPredicate: ['name', name], }) expect(step.result.status).to.eql('failed') expect(step.result.error_message).to.include(errorMessage) @@ -64,7 +64,7 @@ Then(/^all steps have status "([^"]*)"$/, function(status) { Then(/^the step "([^"]*)" has status "([^"]*)"$/, function(name, status) { const step = findStep({ features: this.lastRun.jsonOutput, - stepPredicate: ['name', name] + stepPredicate: ['name', name], }) expect(step.result.status).to.eql(status) }) @@ -72,7 +72,7 @@ Then(/^the step "([^"]*)" has status "([^"]*)"$/, function(name, status) { Then(/^the "([^"]*)" hook has status "([^"]*)"$/, function(keyword, status) { const step = findStep({ features: this.lastRun.jsonOutput, - stepPredicate: ['keyword', keyword] + stepPredicate: ['keyword', keyword], }) expect(step.result.status).to.eql(status) }) @@ -80,12 +80,12 @@ Then(/^the "([^"]*)" hook has status "([^"]*)"$/, function(keyword, status) { Then('the step {string} has the attachment', function(name, table) { const step = findStep({ features: this.lastRun.jsonOutput, - stepPredicate: ['name', name] + stepPredicate: ['name', name], }) const tableRowData = table.hashes()[0] const expectedAttachment = { data: tableRowData.DATA, - mime_type: tableRowData['MIME TYPE'] + mime_type: tableRowData['MIME TYPE'], } expect(step.embeddings[0]).to.eql(expectedAttachment) }) @@ -93,12 +93,12 @@ Then('the step {string} has the attachment', function(name, table) { Then('the {string} hook has the attachment', function(keyword, table) { const hook = findStep({ features: this.lastRun.jsonOutput, - stepPredicate: ['keyword', keyword] + stepPredicate: ['keyword', keyword], }) const tableRowData = table.hashes()[0] const expectedAttachment = { data: tableRowData.DATA, - mime_type: tableRowData['MIME TYPE'] + mime_type: tableRowData['MIME TYPE'], } expect(hook.embeddings[0]).to.eql(expectedAttachment) }) @@ -107,7 +107,7 @@ Then(/^the (first|second) scenario has the steps$/, function(cardinal, table) { const scenarioIndex = cardinal === 'first' ? 0 : 1 const scenario = findScenario({ features: this.lastRun.jsonOutput, - scenarioPredicate: (element, index) => index === scenarioIndex + scenarioPredicate: (element, index) => index === scenarioIndex, }) const stepNames = scenario.steps.map(step => [step.name]) expect(stepNames).to.eql(table.rows()) @@ -122,7 +122,7 @@ Then( scenarioPredicate(element, index) { return index === scenarioIndex }, - stepPredicate: ['name', name] + stepPredicate: ['name', name], }) expect(step.arguments[0].content).to.eql(docString) } @@ -137,7 +137,7 @@ Then( scenarioPredicate(element, index) { return index === scenarioIndex }, - stepPredicate: ['name', name] + stepPredicate: ['name', name], }) const expected = table.raw().map(row => ({ cells: row })) expect(step.arguments[0].rows).to.eql(expected) @@ -153,7 +153,7 @@ Then(/^the (first|second) scenario has the name "([^"]*)"$/, function( features: this.lastRun.jsonOutput, scenarioPredicate(element, index) { return index === scenarioIndex - } + }, }) expect(scenario.name).to.eql(name) }) diff --git a/features/support/json_output_helpers.js b/features/support/json_output_helpers.js index b093e4b37..0407b9252 100644 --- a/features/support/json_output_helpers.js +++ b/features/support/json_output_helpers.js @@ -48,7 +48,7 @@ export function findStep({ features, stepPredicate, scenarioPredicate }) { } throw new Error( `Could not find step matching predicate: ${util.inspect(features, { - depth: null + depth: null, })}` ) } diff --git a/features/support/world.js b/features/support/world.js index 86798a28a..11cfd5b2b 100644 --- a/features/support/world.js +++ b/features/support/world.js @@ -34,7 +34,7 @@ class World { const cli = new Cli({ argv: args, cwd, - stdout + stdout, }) let error, stderr try { @@ -67,7 +67,7 @@ class World { error: result.error, errorOutput: result.stderr, jsonOutput, - output: colors.strip(result.stdout) + output: colors.strip(result.stdout), } this.verifiedLastRunError = false expect(this.lastRun.output).to.not.include('Unhandled rejection') diff --git a/src/cli/argv_parser.js b/src/cli/argv_parser.js index b900c6785..0fe87b412 100644 --- a/src/cli/argv_parser.js +++ b/src/cli/argv_parser.js @@ -131,7 +131,7 @@ export default class ArgvParser { return { options: program.opts(), - args: program.args + args: program.args, } } } diff --git a/src/cli/configuration_builder.js b/src/cli/configuration_builder.js index d865436ae..5ee940e07 100644 --- a/src/cli/configuration_builder.js +++ b/src/cli/configuration_builder.js @@ -51,18 +51,18 @@ export default class ConfigurationBuilder { pickleFilterOptions: { featurePaths: unexpandedFeaturePaths, names: this.options.name, - tagExpression: this.options.tags + tagExpression: this.options.tags, }, runtimeOptions: { dryRun: !!this.options.dryRun, failFast: !!this.options.failFast, filterStacktraces: !this.options.backtrace, strict: !!this.options.strict, - worldParameters: this.options.worldParameters + worldParameters: this.options.worldParameters, }, shouldExitImmediately: !!this.options.exit, supportCodePaths, - supportCodeRequiredModules: this.options.requireModule + supportCodeRequiredModules: this.options.requireModule, } } @@ -72,7 +72,7 @@ export default class ConfigurationBuilder { async unexpandedPath => { const matches = await globP(unexpandedPath, { absolute: true, - cwd: this.cwd + cwd: this.cwd, }) return Promise.map(matches, async match => { if (path.extname(match) === '') { diff --git a/src/cli/configuration_builder_spec.js b/src/cli/configuration_builder_spec.js index 5e4066bdf..87d3ed426 100644 --- a/src/cli/configuration_builder_spec.js +++ b/src/cli/configuration_builder_spec.js @@ -15,7 +15,7 @@ describe('Configuration', () => { this.argv = ['path/to/node', 'path/to/cucumber.js'] this.configurationOptions = { argv: this.argv, - cwd: this.tmpDir + cwd: this.tmpDir, } }) @@ -30,7 +30,7 @@ describe('Configuration', () => { featurePaths: [], formatOptions: { colorsEnabled: true, - cwd: this.tmpDir + cwd: this.tmpDir, }, formats: [{ outputTo: '', type: 'progress' }], listI18nKeywordsFor: '', @@ -39,7 +39,7 @@ describe('Configuration', () => { pickleFilterOptions: { featurePaths: ['features/**/*.feature'], names: [], - tagExpression: '' + tagExpression: '', }, profiles: [], runtimeOptions: { @@ -47,11 +47,11 @@ describe('Configuration', () => { failFast: false, filterStacktraces: true, strict: true, - worldParameters: {} + worldParameters: {}, }, shouldExitImmediately: false, supportCodePaths: [], - supportCodeRequiredModules: [] + supportCodeRequiredModules: [], }) }) }) @@ -71,11 +71,11 @@ describe('Configuration', () => { const { featurePaths, pickleFilterOptions, - supportCodePaths + supportCodePaths, } = this.result expect(featurePaths).to.eql([this.featurePath]) expect(pickleFilterOptions.featurePaths).to.eql([ - this.relativeFeaturePath + this.relativeFeaturePath, ]) expect(supportCodePaths).to.eql([this.supportCodePath]) }) @@ -96,11 +96,11 @@ describe('Configuration', () => { const { featurePaths, pickleFilterOptions, - supportCodePaths + supportCodePaths, } = this.result expect(featurePaths).to.eql([this.featurePath]) expect(pickleFilterOptions.featurePaths).to.eql([ - this.relativeFeaturePath + this.relativeFeaturePath, ]) expect(supportCodePaths).to.eql([this.supportCodePath]) }) @@ -118,7 +118,7 @@ describe('Configuration', () => { expect(formats).to.eql([ { outputTo: '', type: 'progress' }, - { outputTo: '../formatter/output.txt', type: '../custom/formatter' } + { outputTo: '../formatter/output.txt', type: '../custom/formatter' }, ]) }) @@ -128,7 +128,7 @@ describe('Configuration', () => { expect(formats).to.eql([ { outputTo: '', type: 'progress' }, - { outputTo: '/formatter/output.txt', type: '/custom/formatter' } + { outputTo: '/formatter/output.txt', type: '/custom/formatter' }, ]) }) @@ -138,7 +138,10 @@ describe('Configuration', () => { expect(formats).to.eql([ { outputTo: '', type: 'progress' }, - { outputTo: 'D:\\formatter\\output.txt', type: 'C:\\custom\\formatter' } + { + outputTo: 'D:\\formatter\\output.txt', + type: 'C:\\custom\\formatter', + }, ]) }) diff --git a/src/cli/helpers.js b/src/cli/helpers.js index eaf2fec1a..316194c56 100644 --- a/src/cli/helpers.js +++ b/src/cli/helpers.js @@ -21,7 +21,7 @@ export async function getTestCasesFromFilesystem({ eventBroadcaster, featureDefaultLanguage, featurePaths, - pickleFilter + pickleFilter, }) { let result = [] await Promise.each(featurePaths, async featurePath => { @@ -32,7 +32,7 @@ export async function getTestCasesFromFilesystem({ language: featureDefaultLanguage, source, pickleFilter, - uri: path.relative(cwd, featurePath) + uri: path.relative(cwd, featurePath), }) ) }) @@ -44,7 +44,7 @@ export async function getTestCases({ language, pickleFilter, source, - uri + uri, }) { const result = [] const events = Gherkin.generateEvents(source, uri, {}, language) diff --git a/src/cli/helpers_spec.js b/src/cli/helpers_spec.js index 9e5569d24..0d66aa2f7 100644 --- a/src/cli/helpers_spec.js +++ b/src/cli/helpers_spec.js @@ -35,7 +35,7 @@ describe('helpers', () => { cwd: this.tmpDir, eventBroadcaster: this.eventBroadcaster, featurePaths: [featurePath], - pickleFilter: new PickleFilter({}) + pickleFilter: new PickleFilter({}), }) }) @@ -48,7 +48,7 @@ describe('helpers', () => { expect(this.onSource).to.have.been.calledWith({ data: '', media: { encoding: 'utf-8', type: 'text/x.cucumber.gherkin+plain' }, - uri: this.relativeFeaturePath + uri: this.relativeFeaturePath, }) }) @@ -80,8 +80,8 @@ describe('helpers', () => { eventBroadcaster: this.eventBroadcaster, featurePaths: [featurePath], pickleFilter: new PickleFilter({ - featurePaths: [`${this.relativeFeaturePath}:5`] - }) + featurePaths: [`${this.relativeFeaturePath}:5`], + }), }) }) @@ -94,7 +94,7 @@ describe('helpers', () => { expect(this.onSource).to.have.been.calledWith({ data: 'Feature: a\nScenario: b\nGiven a step', media: { encoding: 'utf-8', type: 'text/x.cucumber.gherkin+plain' }, - uri: this.relativeFeaturePath + uri: this.relativeFeaturePath, }) }) @@ -119,7 +119,7 @@ describe('helpers', () => { cwd: this.tmpDir, eventBroadcaster: this.eventBroadcaster, featurePaths: [featurePath], - pickleFilter: new PickleFilter({}) + pickleFilter: new PickleFilter({}), }) }) @@ -134,7 +134,7 @@ describe('helpers', () => { expect(this.onSource).to.have.been.calledWith({ data: 'Feature: a\nScenario: b\nGiven a step', media: { encoding: 'utf-8', type: 'text/x.cucumber.gherkin+plain' }, - uri: this.relativeFeaturePath + uri: this.relativeFeaturePath, }) }) diff --git a/src/cli/i18n.js b/src/cli/i18n.js index db96aad20..451ee1b81 100644 --- a/src/cli/i18n.js +++ b/src/cli/i18n.js @@ -13,7 +13,7 @@ const keywords = [ 'when', 'then', 'and', - 'but' + 'but', ] function getAsTable(header, rows) { @@ -33,13 +33,13 @@ function getAsTable(header, rows) { top: '', 'top-left': '', 'top-mid': '', - 'top-right': '' + 'top-right': '', }, style: { border: [], 'padding-left': 0, - 'padding-right': 0 - } + 'padding-right': 0, + }, }) table.push(header) table.push(...rows) @@ -50,7 +50,7 @@ export function getLanguages() { const rows = _.map(Gherkin.DIALECTS, (data, isoCode) => [ isoCode, data.name, - data.native + data.native, ]) return getAsTable(['ISO 639-1', 'ENGLISH NAME', 'NATIVE NAME'], rows) } diff --git a/src/cli/index.js b/src/cli/index.js index 2886f131b..189554c9f 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -29,7 +29,7 @@ export default class Cli { eventBroadcaster, formatOptions, formats, - supportCodeLibrary + supportCodeLibrary, }) { const streamsToClose = [] const eventDataCollector = new EventDataCollector(eventBroadcaster) @@ -46,7 +46,7 @@ export default class Cli { log: ::stream.write, stream, supportCodeLibrary, - ...formatOptions + ...formatOptions, } return FormatterBuilder.build(type, typeOptions) }) @@ -81,14 +81,14 @@ export default class Cli { eventBroadcaster, formatOptions: configuration.formatOptions, formats: configuration.formats, - supportCodeLibrary + supportCodeLibrary, }) const testCases = await getTestCasesFromFilesystem({ cwd: this.cwd, eventBroadcaster, featureDefaultLanguage: configuration.featureDefaultLanguage, featurePaths: configuration.featurePaths, - pickleFilter: new PickleFilter(configuration.pickleFilterOptions) + pickleFilter: new PickleFilter(configuration.pickleFilterOptions), }) let success if (configuration.parallel) { @@ -97,7 +97,7 @@ export default class Cli { options: configuration.runtimeOptions, supportCodePaths: configuration.supportCodePaths, supportCodeRequiredModules: configuration.supportCodeRequiredModules, - testCases + testCases, }) await new Promise(resolve => { parallelRuntimeMaster.run(configuration.parallel, s => { @@ -110,14 +110,14 @@ export default class Cli { eventBroadcaster, options: configuration.runtimeOptions, supportCodeLibrary, - testCases + testCases, }) success = await runtime.start() } await cleanup() return { shouldExitImmediately: configuration.shouldExitImmediately, - success + success, } } } diff --git a/src/cli/install_validator.js b/src/cli/install_validator.js index 1387ce86e..afcd52119 100644 --- a/src/cli/install_validator.js +++ b/src/cli/install_validator.js @@ -10,7 +10,7 @@ export async function validateInstall(cwd) { } const currentCucumberPath = require.resolve(projectPath) let localCucumberPath = await promisify(resolve)('cucumber', { - basedir: cwd + basedir: cwd, }) localCucumberPath = await fs.realpath(localCucumberPath) if (localCucumberPath !== currentCucumberPath) { diff --git a/src/cli/option_splitter_spec.js b/src/cli/option_splitter_spec.js index 5a0fbe6b9..dbeba7532 100644 --- a/src/cli/option_splitter_spec.js +++ b/src/cli/option_splitter_spec.js @@ -7,28 +7,28 @@ describe('OptionSplitter', () => { { description: "doesn't split when nothing to split on", input: '../custom/formatter', - output: ['../custom/formatter'] + output: ['../custom/formatter'], }, { description: 'splits relative unix paths', input: '../custom/formatter:../formatter/output.txt', - output: ['../custom/formatter', '../formatter/output.txt'] + output: ['../custom/formatter', '../formatter/output.txt'], }, { description: 'splits absolute unix paths', input: '/custom/formatter:/formatter/output.txt', - output: ['/custom/formatter', '/formatter/output.txt'] + output: ['/custom/formatter', '/formatter/output.txt'], }, { description: 'splits absolute windows paths', input: 'C:\\custom\\formatter:C:\\formatter\\output.txt', - output: ['C:\\custom\\formatter', 'C:\\formatter\\output.txt'] + output: ['C:\\custom\\formatter', 'C:\\formatter\\output.txt'], }, { description: 'does not split a single absolute windows paths', input: 'C:\\custom\\formatter', - output: ['C:\\custom\\formatter'] - } + output: ['C:\\custom\\formatter'], + }, ] examples.forEach(({ description, input, output }) => { diff --git a/src/cli/run.js b/src/cli/run.js index 37eb56757..c2b53daa3 100644 --- a/src/cli/run.js +++ b/src/cli/run.js @@ -11,7 +11,7 @@ export default async function run() { const cli = new Cli({ argv: process.argv, cwd, - stdout: process.stdout + stdout: process.stdout, }) let result diff --git a/src/formatter/builder.js b/src/formatter/builder.js index e2b041603..053345388 100644 --- a/src/formatter/builder.js +++ b/src/formatter/builder.js @@ -18,7 +18,7 @@ export default class FormatterBuilder { const extendedOptions = { colorFns: getColorFns(options.colorsEnabled), snippetBuilder: FormatterBuilder.getStepDefinitionSnippetBuilder(options), - ...options + ...options, } return new Formatter(extendedOptions) } @@ -52,7 +52,7 @@ export default class FormatterBuilder { cwd, snippetInterface, snippetSyntax, - supportCodeLibrary + supportCodeLibrary, }) { if (!snippetInterface) { snippetInterface = 'callback' @@ -64,7 +64,7 @@ export default class FormatterBuilder { } return new StepDefinitionSnippetBuilder({ snippetSyntax: new Syntax(snippetInterface), - parameterTypeRegistry: supportCodeLibrary.parameterTypeRegistry + parameterTypeRegistry: supportCodeLibrary.parameterTypeRegistry, }) } diff --git a/src/formatter/event_protocol_formatter.js b/src/formatter/event_protocol_formatter.js index 921b60f32..b66d2c671 100644 --- a/src/formatter/event_protocol_formatter.js +++ b/src/formatter/event_protocol_formatter.js @@ -16,7 +16,7 @@ const EVENT_NAMES = [ 'test-step-attachment', 'test-step-finished', 'test-case-finished', - 'test-run-finished' + 'test-run-finished', ] export default class EventProtocolFormatter extends Formatter { diff --git a/src/formatter/get_color_fns.js b/src/formatter/get_color_fns.js index 6a6291d85..77f27f064 100644 --- a/src/formatter/get_color_fns.js +++ b/src/formatter/get_color_fns.js @@ -11,7 +11,7 @@ export default function getColorFns(enabled) { [Status.SKIPPED]: 'cyan', [Status.UNDEFINED]: 'yellow', location: 'grey', - tag: 'cyan' + tag: 'cyan', }) return colors } diff --git a/src/formatter/helpers/error_helpers.js b/src/formatter/helpers/error_helpers.js index 4ab7f0130..8bcd34452 100644 --- a/src/formatter/helpers/error_helpers.js +++ b/src/formatter/helpers/error_helpers.js @@ -6,7 +6,7 @@ export function formatError(error, colorFns) { diffAdded: colorFns.red, diffRemoved: colorFns.green, errorMessage: colorFns.red, - errorStack: colorFns.gray - } + errorStack: colorFns.gray, + }, }) } diff --git a/src/formatter/helpers/event_data_collector.js b/src/formatter/helpers/event_data_collector.js index aa30f1172..8db588783 100644 --- a/src/formatter/helpers/event_data_collector.js +++ b/src/formatter/helpers/event_data_collector.js @@ -23,7 +23,7 @@ export default class EventDataCollector { return { gherkinDocument: this.gherkinDocumentMap[sourceLocation.uri], pickle: this.pickleMap[this.getTestCaseKey(sourceLocation)], - testCase: this.testCaseMap[this.getTestCaseKey(sourceLocation)] + testCase: this.testCaseMap[this.getTestCaseKey(sourceLocation)], } } diff --git a/src/formatter/helpers/issue_helpers.js b/src/formatter/helpers/issue_helpers.js index 587b46b68..8701da07a 100644 --- a/src/formatter/helpers/issue_helpers.js +++ b/src/formatter/helpers/issue_helpers.js @@ -16,7 +16,7 @@ const CHARACTERS = { [Status.PASSED]: figures.tick, [Status.PENDING]: '?', [Status.SKIPPED]: '-', - [Status.UNDEFINED]: '?' + [Status.UNDEFINED]: '?', } const IS_ISSUE = { @@ -25,7 +25,7 @@ const IS_ISSUE = { [Status.PASSED]: false, [Status.PENDING]: true, [Status.SKIPPED]: false, - [Status.UNDEFINED]: true + [Status.UNDEFINED]: true, } function formatDataTable(arg) { @@ -50,13 +50,13 @@ function formatDataTable(arg) { top: '', 'top-left': '', 'top-mid': '', - 'top-right': '' + 'top-right': '', }, style: { border: [], 'padding-left': 1, - 'padding-right': 1 - } + 'padding-right': 1, + }, }) table.push(...rows) return table.toString() @@ -73,7 +73,7 @@ function formatStep({ keywordType, pickleStep, snippetBuilder, - testStep + testStep, }) { const { status } = testStep.result const colorFn = colorFns[status] @@ -97,7 +97,7 @@ function formatStep({ let str const iterator = buildStepArgumentIterator({ dataTable: arg => (str = formatDataTable(arg)), - docString: arg => (str = formatDocString(arg)) + docString: arg => (str = formatDocString(arg)), }) _.each(pickleStep.arguments, iterator) if (str) { @@ -109,7 +109,7 @@ function formatStep({ keywordType, pickleStep, snippetBuilder, - testStep + testStep, }) if (message) { text += `${indentString(message, 4)}\n` @@ -127,7 +127,7 @@ export function formatIssue({ number, pickle, snippetBuilder, - testCase + testCase, }) { const prefix = `${number}) ` let text = prefix @@ -146,7 +146,7 @@ export function formatIssue({ keywordType = getStepKeywordType({ keyword, language: gherkinDocument.feature.language, - previousKeywordType + previousKeywordType, }) } const formattedStep = formatStep({ @@ -156,7 +156,7 @@ export function formatIssue({ keywordType, pickleStep, snippetBuilder, - testStep + testStep, }) text += indentString(formattedStep, prefix.length) previousKeywordType = keywordType diff --git a/src/formatter/helpers/issue_helpers_spec.js b/src/formatter/helpers/issue_helpers_spec.js index 62c105d09..275c0ab49 100644 --- a/src/formatter/helpers/issue_helpers_spec.js +++ b/src/formatter/helpers/issue_helpers_spec.js @@ -20,19 +20,19 @@ describe('IssueHelpers', () => { this.testCase = { sourceLocation: { uri: 'a.feature', - line: 2 + line: 2, }, steps: [ { actionLocation: { line: 2, uri: 'steps.js' }, - sourceLocation: { line: 3, uri: 'a.feature' } + sourceLocation: { line: 3, uri: 'a.feature' }, }, {}, { actionLocation: { line: 4, uri: 'steps.js' }, - sourceLocation: { line: 5, uri: 'a.feature' } - } - ] + sourceLocation: { line: 5, uri: 'a.feature' }, + }, + ], } this.options = { colorFns: getColorFns(false), @@ -40,7 +40,7 @@ describe('IssueHelpers', () => { number: 1, pickle, snippetBuilder: createMock({ build: 'snippet' }), - testCase: this.testCase + testCase: this.testCase, } this.passedStepResult = { duration: 0, status: Status.PASSED } this.skippedStepResult = { status: Status.SKIPPED } @@ -55,8 +55,8 @@ describe('IssueHelpers', () => { sourceLocation: { line: 4, uri: 'a.feature' }, result: { exception: 'error', - status: Status.FAILED - } + status: Status.FAILED, + }, } this.testCase.steps[2].result = this.skippedStepResult this.formattedIssue = formatIssue(this.options) @@ -84,8 +84,8 @@ describe('IssueHelpers', () => { 'Multiple step definitions match:\n' + ' pattern1 - steps.js:5\n' + ' longer pattern2 - steps.js:6', - status: Status.FAILED - } + status: Status.FAILED, + }, } this.testCase.steps[2].result = this.skippedStepResult this.formattedIssue = formatIssue(this.options) @@ -109,7 +109,7 @@ describe('IssueHelpers', () => { this.testCase.steps[0].result = this.passedStepResult this.testCase.steps[1] = { sourceLocation: { line: 4, uri: 'a.feature' }, - result: { status: Status.UNDEFINED } + result: { status: Status.UNDEFINED }, } this.testCase.steps[2].result = this.skippedStepResult this.formattedIssue = formatIssue(this.options) @@ -135,7 +135,7 @@ describe('IssueHelpers', () => { this.testCase.steps[1] = { actionLocation: { line: 3, uri: 'steps.js' }, sourceLocation: { line: 4, uri: 'a.feature' }, - result: { status: Status.PENDING } + result: { status: Status.PENDING }, } this.testCase.steps[2].result = this.skippedStepResult this.formattedIssue = formatIssue(this.options) @@ -171,7 +171,7 @@ describe('IssueHelpers', () => { this.testCase.steps[1] = { actionLocation: { line: 3, uri: 'steps.js' }, sourceLocation: { line: 4, uri: 'a.feature' }, - result: { status: Status.PENDING } + result: { status: Status.PENDING }, } this.testCase.steps[2].result = this.skippedStepResult this.formattedIssue = formatIssue(this.options) @@ -213,7 +213,7 @@ describe('IssueHelpers', () => { this.testCase.steps[1] = { actionLocation: { line: 3, uri: 'steps.js' }, sourceLocation: { line: 4, uri: 'a.feature' }, - result: { status: Status.PENDING } + result: { status: Status.PENDING }, } this.testCase.steps[2].result = this.skippedStepResult this.formattedIssue = formatIssue(this.options) diff --git a/src/formatter/helpers/keyword_type.js b/src/formatter/helpers/keyword_type.js index d6a379ad7..3a461ed64 100644 --- a/src/formatter/helpers/keyword_type.js +++ b/src/formatter/helpers/keyword_type.js @@ -4,7 +4,7 @@ import Gherkin from 'gherkin' const types = { EVENT: 'event', OUTCOME: 'outcome', - PRECONDITION: 'precondition' + PRECONDITION: 'precondition', } export default types diff --git a/src/formatter/helpers/keyword_type_spec.js b/src/formatter/helpers/keyword_type_spec.js index 7199972ec..30b87a552 100644 --- a/src/formatter/helpers/keyword_type_spec.js +++ b/src/formatter/helpers/keyword_type_spec.js @@ -14,7 +14,7 @@ describe('KeywordType', () => { beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'Given ', - language: 'en' + language: 'en', }) }) @@ -27,7 +27,7 @@ describe('KeywordType', () => { beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'When ', - language: 'en' + language: 'en', }) }) @@ -40,7 +40,7 @@ describe('KeywordType', () => { beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'Then ', - language: 'en' + language: 'en', }) }) @@ -53,7 +53,7 @@ describe('KeywordType', () => { beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'And ', - language: 'en' + language: 'en', }) }) @@ -67,7 +67,7 @@ describe('KeywordType', () => { this.keywordType = getStepKeywordType({ keyword: 'And ', language: 'en', - previousKeywordType: KeywordType.EVENT + previousKeywordType: KeywordType.EVENT, }) }) @@ -80,7 +80,7 @@ describe('KeywordType', () => { beforeEach(function() { this.keywordType = getStepKeywordType({ keyword: 'But ', - language: 'en' + language: 'en', }) }) @@ -94,7 +94,7 @@ describe('KeywordType', () => { this.keywordType = getStepKeywordType({ keyword: 'But ', language: 'en', - previousKeywordType: KeywordType.OUTCOME + previousKeywordType: KeywordType.OUTCOME, }) }) @@ -108,7 +108,7 @@ describe('KeywordType', () => { this.keywordType = getStepKeywordType({ index: 0, language: 'en', - stepKeywords: ['other '] + stepKeywords: ['other '], }) }) diff --git a/src/formatter/helpers/pickle_parser.js b/src/formatter/helpers/pickle_parser.js index 856abaf43..d282b7218 100644 --- a/src/formatter/helpers/pickle_parser.js +++ b/src/formatter/helpers/pickle_parser.js @@ -2,7 +2,7 @@ import _ from 'lodash' export function getScenarioDescription({ pickle, - scenarioLineToDescriptionMap + scenarioLineToDescriptionMap, }) { return _.chain(pickle.locations) .map(({ line }) => scenarioLineToDescriptionMap[line]) diff --git a/src/formatter/helpers/step_result_helpers.js b/src/formatter/helpers/step_result_helpers.js index 92668b394..05765ff57 100644 --- a/src/formatter/helpers/step_result_helpers.js +++ b/src/formatter/helpers/step_result_helpers.js @@ -19,7 +19,7 @@ export function getStepMessage({ keywordType, snippetBuilder, testStep, - pickleStep + pickleStep, }) { switch (testStep.result.status) { case Status.AMBIGUOUS: @@ -31,7 +31,7 @@ export function getStepMessage({ colorFns, keywordType, snippetBuilder, - pickleStep + pickleStep, }) case Status.PENDING: return getPendingStepResultMessage({ colorFns }) @@ -42,7 +42,7 @@ function getUndefinedStepResultMessage({ colorFns, keywordType, snippetBuilder, - pickleStep + pickleStep, }) { const snippet = snippetBuilder.build({ keywordType, pickleStep }) const message = `${'Undefined. Implement with the following snippet:' + diff --git a/src/formatter/helpers/summary_helpers.js b/src/formatter/helpers/summary_helpers.js index 9032bf696..8512f5315 100644 --- a/src/formatter/helpers/summary_helpers.js +++ b/src/formatter/helpers/summary_helpers.js @@ -8,7 +8,7 @@ const STATUS_REPORT_ORDER = [ Status.UNDEFINED, Status.PENDING, Status.SKIPPED, - Status.PASSED + Status.PASSED, ] export function formatSummary({ colorFns, testCaseMap, testRun }) { @@ -25,12 +25,12 @@ export function formatSummary({ colorFns, testCaseMap, testRun }) { const scenarioSummary = getCountSummary({ colorFns, objects: testCaseResults, - type: 'scenario' + type: 'scenario', }) const stepSummary = getCountSummary({ colorFns, objects: testStepResults, - type: 'step' + type: 'step', }) const durationSummary = getDuration(testRun.result.duration) return [scenarioSummary, stepSummary, durationSummary].join('\n') diff --git a/src/formatter/helpers/summary_helpers_spec.js b/src/formatter/helpers/summary_helpers_spec.js index 570b01ac3..fb56c9151 100644 --- a/src/formatter/helpers/summary_helpers_spec.js +++ b/src/formatter/helpers/summary_helpers_spec.js @@ -12,7 +12,7 @@ describe('SummaryHelpers', () => { this.options = { colorFns: getColorFns(false), testCaseMap: this.testCaseMap, - testRun: this.testRun + testRun: this.testRun, } }) @@ -34,10 +34,10 @@ describe('SummaryHelpers', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 2 }, - result: { status: Status.PASSED } - } + result: { status: Status.PASSED }, + }, ], - result: { status: Status.PASSED } + result: { status: Status.PASSED }, } this.result = formatSummary(this.options) }) @@ -56,10 +56,10 @@ describe('SummaryHelpers', () => { { result: { status: Status.PASSED } }, { sourceLocation: { uri: 'a.feature', line: 2 }, - result: { status: Status.PASSED } - } + result: { status: Status.PASSED }, + }, ], - result: { status: Status.PASSED } + result: { status: Status.PASSED }, } this.result = formatSummary(this.options) }) @@ -77,14 +77,14 @@ describe('SummaryHelpers', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 2 }, - result: { status: Status.PASSED } + result: { status: Status.PASSED }, }, { sourceLocation: { uri: 'a.feature', line: 3 }, - result: { status: Status.PASSED } - } + result: { status: Status.PASSED }, + }, ], - result: { status: Status.PASSED } + result: { status: Status.PASSED }, } this.result = formatSummary(this.options) }) @@ -102,55 +102,55 @@ describe('SummaryHelpers', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 2 }, - result: { status: Status.AMBIGUOUS } - } + result: { status: Status.AMBIGUOUS }, + }, ], - result: { status: Status.AMBIGUOUS } + result: { status: Status.AMBIGUOUS }, } this.testCaseMap['a.feature:3'] = { steps: [ { sourceLocation: { uri: 'a.feature', line: 4 }, - result: { status: Status.FAILED } - } + result: { status: Status.FAILED }, + }, ], - result: { status: Status.FAILED } + result: { status: Status.FAILED }, } this.testCaseMap['a.feature:5'] = { steps: [ { sourceLocation: { uri: 'a.feature', line: 6 }, - result: { status: Status.PENDING } - } + result: { status: Status.PENDING }, + }, ], - result: { status: Status.PENDING } + result: { status: Status.PENDING }, } this.testCaseMap['a.feature:7'] = { steps: [ { sourceLocation: { uri: 'a.feature', line: 8 }, - result: { status: Status.PASSED } - } + result: { status: Status.PASSED }, + }, ], - result: { status: Status.PASSED } + result: { status: Status.PASSED }, } this.testCaseMap['a.feature:9'] = { steps: [ { sourceLocation: { uri: 'a.feature', line: 10 }, - result: { status: Status.SKIPPED } - } + result: { status: Status.SKIPPED }, + }, ], - result: { status: Status.SKIPPED } + result: { status: Status.SKIPPED }, } this.testCaseMap['a.feature:11'] = { steps: [ { sourceLocation: { uri: 'a.feature', line: 12 }, - result: { status: Status.UNDEFINED } - } + result: { status: Status.UNDEFINED }, + }, ], - result: { status: Status.UNDEFINED } + result: { status: Status.UNDEFINED }, } this.result = formatSummary(this.options) }) diff --git a/src/formatter/helpers/usage_helpers/index.js b/src/formatter/helpers/usage_helpers/index.js index e36d17824..f4f09be03 100644 --- a/src/formatter/helpers/usage_helpers/index.js +++ b/src/formatter/helpers/usage_helpers/index.js @@ -10,7 +10,7 @@ function buildEmptyMapping(stepDefinitions) { line: stepDefinition.line, pattern: stepDefinition.pattern, matches: [], - uri: stepDefinition.uri + uri: stepDefinition.uri, } }) return mapping @@ -30,7 +30,7 @@ function buildMapping({ stepDefinitions, eventDataCollector }) { const match = { line: sourceLocation.line, text: stepLineToPickledStepMap[sourceLocation.line].text, - uri: sourceLocation.uri + uri: sourceLocation.uri, } if (isFinite(duration)) { match.duration = duration @@ -59,7 +59,7 @@ function buildResult(mapping) { .map(({ line, matches, pattern, uri }) => { const sortedMatches = _.sortBy(matches, [ invertNumber('duration'), - 'text' + 'text', ]) const result = { line, matches: sortedMatches, pattern, uri } const meanDuration = _.meanBy(matches, 'duration') diff --git a/src/formatter/helpers/usage_helpers/index_spec.js b/src/formatter/helpers/usage_helpers/index_spec.js index 6f151cdef..8d8c27113 100644 --- a/src/formatter/helpers/usage_helpers/index_spec.js +++ b/src/formatter/helpers/usage_helpers/index_spec.js @@ -14,7 +14,7 @@ describe('Usage Helpers', () => { this.getResult = () => getUsage({ eventDataCollector: this.eventDataCollector, - stepDefinitions: this.stepDefinitions + stepDefinitions: this.stepDefinitions, }) }) @@ -41,7 +41,7 @@ describe('Usage Helpers', () => { this.eventBroadcaster.emit('pickle-accepted', { type: 'pickle-accepted', pickle: event.pickle, - uri: event.uri + uri: event.uri, }) } }) @@ -50,18 +50,18 @@ describe('Usage Helpers', () => { ...testCase, steps: [ { sourceLocation: { uri: 'a.feature', line: 3 } }, - { sourceLocation: { uri: 'a.feature', line: 4 } } - ] + { sourceLocation: { uri: 'a.feature', line: 4 } }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase, - result: {} + result: {}, }) this.eventBroadcaster.emit('test-step-finished', { index: 1, testCase, - result: {} + result: {}, }) this.eventBroadcaster.emit('test-run-finished') }) diff --git a/src/formatter/index.js b/src/formatter/index.js index fd823848d..af7dde13a 100644 --- a/src/formatter/index.js +++ b/src/formatter/index.js @@ -11,7 +11,7 @@ export default class Formatter { 'log', 'snippetBuilder', 'stream', - 'supportCodeLibrary' + 'supportCodeLibrary', ]) ) } diff --git a/src/formatter/json_formatter.js b/src/formatter/json_formatter.js index fefc4d013..f90f68e1a 100644 --- a/src/formatter/json_formatter.js +++ b/src/formatter/json_formatter.js @@ -7,13 +7,13 @@ import { format } from 'assertion-error-formatter' const { getStepLineToKeywordMap, - getScenarioLineToDescriptionMap + getScenarioLineToDescriptionMap, } = GherkinDocumentParser const { getScenarioDescription, getStepLineToPickledStepMap, - getStepKeyword + getStepKeyword, } = PickleParser export default class JsonFormatter extends Formatter { @@ -28,21 +28,21 @@ export default class JsonFormatter extends Formatter { formatDataTable(dataTable) { return { - rows: dataTable.rows.map(row => ({ cells: _.map(row.cells, 'value') })) + rows: dataTable.rows.map(row => ({ cells: _.map(row.cells, 'value') })), } } formatDocString(docString) { return { content: docString.content, - line: docString.location.line + line: docString.location.line, } } formatStepArguments(stepArguments) { const iterator = buildStepArgumentIterator({ dataTable: this.formatDataTable.bind(this), - docString: this.formatDocString.bind(this) + docString: this.formatDocString.bind(this), }) return _.map(stepArguments, iterator) } @@ -70,7 +70,7 @@ export default class JsonFormatter extends Formatter { const scenarioData = this.getScenarioData({ featureId: featureData.id, pickle, - scenarioLineToDescriptionMap + scenarioLineToDescriptionMap, }) const stepLineToPickledStepMap = getStepLineToPickledStepMap(pickle) let isBeforeHook = true @@ -80,7 +80,7 @@ export default class JsonFormatter extends Formatter { isBeforeHook, stepLineToKeywordMap, stepLineToPickledStepMap, - testStep + testStep, }) }) return scenarioData @@ -98,14 +98,14 @@ export default class JsonFormatter extends Formatter { line: feature.location.line, id: this.convertNameToId(feature), tags: this.getTags(feature), - uri + uri, } } getScenarioData({ featureId, pickle, scenarioLineToDescriptionMap }) { const description = getScenarioDescription({ pickle, - scenarioLineToDescriptionMap + scenarioLineToDescriptionMap, }) return { description, @@ -114,7 +114,7 @@ export default class JsonFormatter extends Formatter { line: pickle.locations[0].line, name: pickle.name, tags: this.getTags(pickle), - type: 'scenario' + type: 'scenario', } } @@ -122,7 +122,7 @@ export default class JsonFormatter extends Formatter { isBeforeHook, stepLineToKeywordMap, stepLineToPickledStepMap, - testStep + testStep, }) { const data = {} if (testStep.sourceLocation) { @@ -152,7 +152,7 @@ export default class JsonFormatter extends Formatter { if (_.size(testStep.attachments) > 0) { data.embeddings = testStep.attachments.map(attachment => ({ data: attachment.data, - mime_type: attachment.media.type + mime_type: attachment.media.type, })) } return data @@ -161,7 +161,7 @@ export default class JsonFormatter extends Formatter { getTags(obj) { return _.map(obj.tags, tagData => ({ name: tagData.name, - line: tagData.location.line + line: tagData.location.line, })) } } diff --git a/src/formatter/json_formatter_spec.js b/src/formatter/json_formatter_spec.js index d77f07971..00ba20de2 100644 --- a/src/formatter/json_formatter_spec.js +++ b/src/formatter/json_formatter_spec.js @@ -16,7 +16,7 @@ describe('JsonFormatter', () => { this.jsonFormatter = new JsonFormatter({ eventBroadcaster: this.eventBroadcaster, eventDataCollector: new EventDataCollector(this.eventBroadcaster), - log: logFn + log: logFn, }) }) @@ -47,7 +47,7 @@ describe('JsonFormatter', () => { this.eventBroadcaster.emit('pickle-accepted', { type: 'pickle-accepted', pickle: event.pickle, - uri: event.uri + uri: event.uri, }) } }) @@ -60,18 +60,18 @@ describe('JsonFormatter', () => { sourceLocation: this.testCase.sourceLocation, steps: [ { - sourceLocation: { uri: 'a.feature', line: 6 } - } - ] + sourceLocation: { uri: 'a.feature', line: 6 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { duration: 1, status: Status.PASSED } + result: { duration: 1, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { duration: 1, status: Status.PASSED } + result: { duration: 1, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -96,20 +96,20 @@ describe('JsonFormatter', () => { name: 'my step', result: { status: 'passed', - duration: 1000000 - } - } + duration: 1000000, + }, + }, ], - tags: [{ name: '@tag1', line: 1 }, { name: '@tag2', line: 1 }] - } + tags: [{ name: '@tag1', line: 1 }, { name: '@tag2', line: 1 }], + }, ], id: 'my-feature', keyword: 'Feature', line: 2, name: 'my feature', tags: [{ name: '@tag1', line: 1 }, { name: '@tag2', line: 1 }], - uri: 'a.feature' - } + uri: 'a.feature', + }, ]) }) }) @@ -120,18 +120,18 @@ describe('JsonFormatter', () => { sourceLocation: this.testCase.sourceLocation, steps: [ { - sourceLocation: { uri: 'a.feature', line: 6 } - } - ] + sourceLocation: { uri: 'a.feature', line: 6 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { duration: 1, exception: 'my error', status: Status.FAILED } + result: { duration: 1, exception: 'my error', status: Status.FAILED }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { duration: 1, status: Status.FAILED } + result: { duration: 1, status: Status.FAILED }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -141,7 +141,7 @@ describe('JsonFormatter', () => { expect(features[0].elements[0].steps[0].result).to.eql({ status: 'failed', error_message: 'my error', - duration: 1000000 + duration: 1000000, }) }) }) @@ -153,18 +153,18 @@ describe('JsonFormatter', () => { steps: [ { actionLocation: { uri: 'steps.js', line: 10 }, - sourceLocation: { uri: 'a.feature', line: 6 } - } - ] + sourceLocation: { uri: 'a.feature', line: 6 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { duration: 1, status: Status.PASSED } + result: { duration: 1, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { duration: 1, status: Status.PASSED } + result: { duration: 1, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -172,7 +172,7 @@ describe('JsonFormatter', () => { it('outputs the step with a match attribute', function() { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].match).to.eql({ - location: 'steps.js:10' + location: 'steps.js:10', }) }) }) @@ -183,20 +183,20 @@ describe('JsonFormatter', () => { sourceLocation: this.testCase.sourceLocation, steps: [ { - actionLocation: { uri: 'steps.js', line: 10 } + actionLocation: { uri: 'steps.js', line: 10 }, }, { sourceLocation: { uri: 'a.feature', line: 6 }, - actionLocation: { uri: 'steps.js', line: 11 } + actionLocation: { uri: 'steps.js', line: 11 }, }, { - actionLocation: { uri: 'steps.js', line: 12 } - } - ] + actionLocation: { uri: 'steps.js', line: 12 }, + }, + ], }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { duration: 1, status: Status.PASSED } + result: { duration: 1, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -225,29 +225,29 @@ describe('JsonFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 6 }, - actionLocation: { uri: 'steps.js', line: 11 } - } - ] + actionLocation: { uri: 'steps.js', line: 11 }, + }, + ], }) this.eventBroadcaster.emit('test-step-attachment', { testCase: { - sourceLocation: this.testCase.sourceLocation + sourceLocation: this.testCase.sourceLocation, }, index: 0, data: 'first data', - media: { type: 'first media type' } + media: { type: 'first media type' }, }) this.eventBroadcaster.emit('test-step-attachment', { testCase: { - sourceLocation: this.testCase.sourceLocation + sourceLocation: this.testCase.sourceLocation, }, index: 0, data: 'second data', - media: { type: 'second media type' } + media: { type: 'second media type' }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { duration: 1, status: Status.PASSED } + result: { duration: 1, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -256,7 +256,7 @@ describe('JsonFormatter', () => { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].embeddings).to.eql([ { data: 'first data', mime_type: 'first media type' }, - { data: 'second data', mime_type: 'second media type' } + { data: 'second data', mime_type: 'second media type' }, ]) }) }) @@ -279,7 +279,7 @@ describe('JsonFormatter', () => { this.eventBroadcaster.emit('pickle-accepted', { type: 'pickle-accepted', pickle: event.pickle, - uri: event.uri + uri: event.uri, }) } }) @@ -289,18 +289,18 @@ describe('JsonFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 3 }, - actionLocation: { uri: 'steps.js', line: 10 } - } - ] + actionLocation: { uri: 'steps.js', line: 10 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { duration: 1, status: Status.PASSED } + result: { duration: 1, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-case-finished', { ...this.testCase, - result: { duration: 1, status: Status.PASSED } + result: { duration: 1, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -310,8 +310,8 @@ describe('JsonFormatter', () => { expect(features[0].elements[0].steps[0].arguments).to.eql([ { line: 4, - content: 'This is a DocString' - } + content: 'This is a DocString', + }, ]) }) }) @@ -333,7 +333,7 @@ describe('JsonFormatter', () => { this.eventBroadcaster.emit('pickle-accepted', { type: 'pickle-accepted', pickle: event.pickle, - uri: event.uri + uri: event.uri, }) } }) @@ -343,18 +343,18 @@ describe('JsonFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 3 }, - actionLocation: { uri: 'steps.js', line: 10 } - } - ] + actionLocation: { uri: 'steps.js', line: 10 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { duration: 1, status: Status.PASSED } + result: { duration: 1, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-case-finished', { ...this.testCase, - result: { duration: 1, status: Status.PASSED } + result: { duration: 1, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -366,9 +366,9 @@ describe('JsonFormatter', () => { rows: [ { cells: ['aaa', 'b', 'c'] }, { cells: ['d', 'e', 'ff'] }, - { cells: ['gg', 'h', 'iii'] } - ] - } + { cells: ['gg', 'h', 'iii'] }, + ], + }, ]) }) }) diff --git a/src/formatter/progress_bar_formatter.js b/src/formatter/progress_bar_formatter.js index 521fe706a..08c5cd75a 100644 --- a/src/formatter/progress_bar_formatter.js +++ b/src/formatter/progress_bar_formatter.js @@ -26,7 +26,7 @@ export default class ProgressBarFormatter extends Formatter { incomplete: ' ', stream: this.stream, total: this.numberOfSteps, - width: this.stream.columns || 80 + width: this.stream.columns || 80, }) } @@ -43,7 +43,7 @@ export default class ProgressBarFormatter extends Formatter { const { gherkinDocument, pickle, - testCase + testCase, } = this.eventDataCollector.getTestCaseData(sourceLocation) this.progressBar.interrupt( formatIssue({ @@ -52,7 +52,7 @@ export default class ProgressBarFormatter extends Formatter { number: this.issueCount, pickle, snippetBuilder: this.snippetBuilder, - testCase + testCase, }) ) } @@ -63,7 +63,7 @@ export default class ProgressBarFormatter extends Formatter { formatSummary({ colorFns: this.colorFns, testCaseMap: this.eventDataCollector.testCaseMap, - testRun + testRun, }) ) } diff --git a/src/formatter/progress_bar_formatter_spec.js b/src/formatter/progress_bar_formatter_spec.js index 8a43bcd68..d56cfc5fa 100644 --- a/src/formatter/progress_bar_formatter_spec.js +++ b/src/formatter/progress_bar_formatter_spec.js @@ -24,7 +24,7 @@ describe('ProgressBarFormatter', () => { eventDataCollector: new EventDataCollector(this.eventBroadcaster), log: logFn, snippetBuilder: createMock({ build: 'snippet' }), - stream: {} + stream: {}, }) }) @@ -32,11 +32,11 @@ describe('ProgressBarFormatter', () => { beforeEach(function() { this.eventBroadcaster.emit('pickle-accepted', { pickle: { locations: [{ line: 2 }], steps: [1, 2, 3] }, - uri: 'path/to/feature' + uri: 'path/to/feature', }) this.eventBroadcaster.emit('pickle-accepted', { pickle: { locations: [{ line: 7 }], steps: [4, 5] }, - uri: 'path/to/feature' + uri: 'path/to/feature', }) this.eventBroadcaster.emit('test-case-started') }) @@ -50,7 +50,7 @@ describe('ProgressBarFormatter', () => { beforeEach(function() { this.progressBarFormatter.progressBar = { interrupt: sinon.stub(), - tick: sinon.stub() + tick: sinon.stub(), } this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: { line: 2, uri: 'path/to/feature' }, @@ -58,9 +58,9 @@ describe('ProgressBarFormatter', () => { { actionLocation: { line: 2, uri: 'path/to/steps' } }, { actionLocation: { line: 2, uri: 'path/to/steps' }, - sourceLocation: { line: 3, uri: 'path/to/feature' } - } - ] + sourceLocation: { line: 3, uri: 'path/to/feature' }, + }, + ], }) }) @@ -69,9 +69,9 @@ describe('ProgressBarFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: { - sourceLocation: { line: 2, uri: 'path/to/feature' } + sourceLocation: { line: 2, uri: 'path/to/feature' }, }, - result: { status: Status.PASSED } + result: { status: Status.PASSED }, }) }) @@ -85,9 +85,9 @@ describe('ProgressBarFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 1, testCase: { - sourceLocation: { line: 2, uri: 'path/to/feature' } + sourceLocation: { line: 2, uri: 'path/to/feature' }, }, - result: { status: Status.PASSED } + result: { status: Status.PASSED }, }) }) @@ -101,7 +101,7 @@ describe('ProgressBarFormatter', () => { beforeEach(function() { this.progressBarFormatter.progressBar = { interrupt: sinon.stub(), - tick: sinon.stub() + tick: sinon.stub(), } const events = Gherkin.generateEvents( 'Feature: a\nScenario: b\nGiven a step', @@ -113,7 +113,7 @@ describe('ProgressBarFormatter', () => { this.eventBroadcaster.emit('pickle-accepted', { type: 'pickle-accepted', pickle: event.pickle, - uri: event.uri + uri: event.uri, }) } }) @@ -126,9 +126,9 @@ describe('ProgressBarFormatter', () => { sourceLocation: this.testCase.sourceLocation, steps: [ { - sourceLocation: { uri: 'a.feature', line: 3 } - } - ] + sourceLocation: { uri: 'a.feature', line: 3 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, @@ -138,12 +138,12 @@ describe('ProgressBarFormatter', () => { 'Multiple step definitions match:\n' + ' pattern1 - steps.js:3\n' + ' longer pattern2 - steps.js:4', - status: Status.AMBIGUOUS - } + status: Status.AMBIGUOUS, + }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { status: Status.AMBIGUOUS } + result: { status: Status.AMBIGUOUS }, }) }) @@ -161,18 +161,18 @@ describe('ProgressBarFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 3 }, - actionLocation: { uri: 'steps.js', line: 4 } - } - ] + actionLocation: { uri: 'steps.js', line: 4 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { exception: 'error', status: Status.FAILED } + result: { exception: 'error', status: Status.FAILED }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { status: Status.FAILED } + result: { status: Status.FAILED }, }) }) @@ -190,18 +190,18 @@ describe('ProgressBarFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 3 }, - actionLocation: { uri: 'steps.js', line: 4 } - } - ] + actionLocation: { uri: 'steps.js', line: 4 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { status: Status.PASSED } + result: { status: Status.PASSED }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { status: Status.PASSED } + result: { status: Status.PASSED }, }) }) @@ -219,18 +219,18 @@ describe('ProgressBarFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 3 }, - actionLocation: { uri: 'steps.js', line: 4 } - } - ] + actionLocation: { uri: 'steps.js', line: 4 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { status: Status.PENDING } + result: { status: Status.PENDING }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { status: Status.PENDING } + result: { status: Status.PENDING }, }) }) @@ -248,18 +248,18 @@ describe('ProgressBarFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 3 }, - actionLocation: { uri: 'steps.js', line: 4 } - } - ] + actionLocation: { uri: 'steps.js', line: 4 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { status: Status.SKIPPED } + result: { status: Status.SKIPPED }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { status: Status.SKIPPED } + result: { status: Status.SKIPPED }, }) }) @@ -276,18 +276,18 @@ describe('ProgressBarFormatter', () => { sourceLocation: this.testCase.sourceLocation, steps: [ { - sourceLocation: { uri: 'a.feature', line: 3 } - } - ] + sourceLocation: { uri: 'a.feature', line: 3 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { status: Status.UNDEFINED } + result: { status: Status.UNDEFINED }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { status: Status.UNDEFINED } + result: { status: Status.UNDEFINED }, }) }) @@ -302,7 +302,7 @@ describe('ProgressBarFormatter', () => { describe('test-run-finished', () => { beforeEach(function() { this.eventBroadcaster.emit('test-run-finished', { - result: { duration: 0 } + result: { duration: 0 }, }) }) diff --git a/src/formatter/progress_formatter.js b/src/formatter/progress_formatter.js index c2d096d69..9ec7cc70b 100644 --- a/src/formatter/progress_formatter.js +++ b/src/formatter/progress_formatter.js @@ -7,7 +7,7 @@ const STATUS_CHARACTER_MAPPING = { [Status.PASSED]: '.', [Status.PENDING]: 'P', [Status.SKIPPED]: '-', - [Status.UNDEFINED]: 'U' + [Status.UNDEFINED]: 'U', } export default class ProgressFormatter extends SummaryFormatter { diff --git a/src/formatter/progress_formatter_spec.js b/src/formatter/progress_formatter_spec.js index 397a474ef..3910d1ee2 100644 --- a/src/formatter/progress_formatter_spec.js +++ b/src/formatter/progress_formatter_spec.js @@ -18,7 +18,7 @@ describe('ProgressFormatter', () => { colorFns, eventBroadcaster: this.eventBroadcaster, eventDataCollector: new EventDataCollector(this.eventBroadcaster), - log: logFn + log: logFn, }) }) @@ -27,7 +27,7 @@ describe('ProgressFormatter', () => { this.testCase = { sourceLocation: { uri: 'path/to/feature', line: 1 } } this.eventBroadcaster.emit('test-case-prepared', { sourceLocation: this.testCase.sourceLocation, - steps: [{}] + steps: [{}], }) }) @@ -36,7 +36,7 @@ describe('ProgressFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.AMBIGUOUS }, - testCase: this.testCase + testCase: this.testCase, }) }) @@ -50,7 +50,7 @@ describe('ProgressFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.FAILED }, - testCase: this.testCase + testCase: this.testCase, }) }) @@ -64,7 +64,7 @@ describe('ProgressFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.PASSED }, - testCase: this.testCase + testCase: this.testCase, }) }) @@ -78,7 +78,7 @@ describe('ProgressFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.PENDING }, - testCase: this.testCase + testCase: this.testCase, }) }) @@ -92,7 +92,7 @@ describe('ProgressFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.SKIPPED }, - testCase: this.testCase + testCase: this.testCase, }) }) @@ -106,7 +106,7 @@ describe('ProgressFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, result: { status: Status.UNDEFINED }, - testCase: this.testCase + testCase: this.testCase, }) }) @@ -119,7 +119,7 @@ describe('ProgressFormatter', () => { describe('test run finished', () => { beforeEach(function() { this.eventBroadcaster.emit('test-run-finished', { - result: { duration: 0 } + result: { duration: 0 }, }) }) diff --git a/src/formatter/rerun_formatter_spec.js b/src/formatter/rerun_formatter_spec.js index 1c0c93631..a17b63317 100644 --- a/src/formatter/rerun_formatter_spec.js +++ b/src/formatter/rerun_formatter_spec.js @@ -17,7 +17,7 @@ function prepareFormatter(options = {}) { this.rerunFormatter = new RerunFormatter({ ...options, eventBroadcaster: this.eventBroadcaster, - log: logFn + log: logFn, }) } @@ -39,7 +39,7 @@ describe('RerunFormatter', () => { beforeEach(function() { this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature1Path, line: 1 }, - result: { status } + result: { status }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -56,14 +56,14 @@ describe('RerunFormatter', () => { Status.FAILED, Status.PENDING, Status.SKIPPED, - Status.UNDEFINED + Status.UNDEFINED, ], status => { describe(`with one ${status} scenario`, () => { beforeEach(function() { this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature1Path, line: 1 }, - result: { status } + result: { status }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -79,11 +79,11 @@ describe('RerunFormatter', () => { beforeEach(function() { this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature1Path, line: 1 }, - result: { status: Status.FAILED } + result: { status: Status.FAILED }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature1Path, line: 2 }, - result: { status: Status.FAILED } + result: { status: Status.FAILED }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -97,23 +97,23 @@ describe('RerunFormatter', () => { [ { separator: { opt: undefined, expected: '\n' }, label: 'default' }, { separator: { opt: '\n', expected: '\n' }, label: 'newline' }, - { separator: { opt: ' ', expected: ' ' }, label: 'space' } + { separator: { opt: ' ', expected: ' ' }, label: 'space' }, ], ({ separator, label }) => { describe(`using ${label} separator`, () => { describe('with two failing scenarios in different files', () => { beforeEach(function() { prepareFormatter.apply(this, [ - { rerun: { separator: separator.opt } } + { rerun: { separator: separator.opt } }, ]) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature1Path, line: 1 }, - result: { status: Status.FAILED } + result: { status: Status.FAILED }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: { uri: this.feature2Path, line: 2 }, - result: { status: Status.FAILED } + result: { status: Status.FAILED }, }) this.eventBroadcaster.emit('test-run-finished') }) diff --git a/src/formatter/snippets_formatter.js b/src/formatter/snippets_formatter.js index fa9362d08..139651554 100644 --- a/src/formatter/snippets_formatter.js +++ b/src/formatter/snippets_formatter.js @@ -15,21 +15,21 @@ export default class SnippetsFormatter extends Formatter { if (result.status === Status.UNDEFINED) { const { gherkinDocument, - testCase + testCase, } = this.eventDataCollector.getTestCaseData(sourceLocation) const { pickleStep, - gherkinKeyword + gherkinKeyword, } = this.eventDataCollector.getTestStepData({ testCase, index }) const previousKeywordType = this.getPreviousKeywordType({ gherkinDocument, testCase, - index + index, }) const keywordType = getStepKeywordType({ keyword: gherkinKeyword, language: gherkinDocument.feature.language, - previousKeywordType + previousKeywordType, }) const snippet = this.snippetBuilder.build({ keywordType, pickleStep }) this.log(`${snippet}\n\n`) @@ -41,12 +41,12 @@ export default class SnippetsFormatter extends Formatter { for (let i = 0; i < index; i += 1) { const { gherkinKeyword } = this.eventDataCollector.getTestStepData({ testCase, - index: i + index: i, }) previousKeywordType = getStepKeywordType({ keyword: gherkinKeyword, language: gherkinDocument.feature.language, - previousKeywordType + previousKeywordType, }) } return previousKeywordType diff --git a/src/formatter/step_definition_snippet_builder/index.js b/src/formatter/step_definition_snippet_builder/index.js index 66acdd624..3084285fe 100644 --- a/src/formatter/step_definition_snippet_builder/index.js +++ b/src/formatter/step_definition_snippet_builder/index.js @@ -23,7 +23,7 @@ export default class StepDefinitionSnippetBuilder { comment, functionName, generatedExpressions, - stepParameterNames + stepParameterNames, }) } @@ -41,7 +41,7 @@ export default class StepDefinitionSnippetBuilder { getStepParameterNames(step) { const iterator = buildStepArgumentIterator({ dataTable: () => 'dataTable', - docString: () => 'docString' + docString: () => 'docString', }) return step.arguments.map(iterator) } diff --git a/src/formatter/step_definition_snippet_builder/index_spec.js b/src/formatter/step_definition_snippet_builder/index_spec.js index 3ce822740..2b7f1dfd5 100644 --- a/src/formatter/step_definition_snippet_builder/index_spec.js +++ b/src/formatter/step_definition_snippet_builder/index_spec.js @@ -11,7 +11,7 @@ describe('StepDefinitionSnippetBuilder', () => { this.transformsLookup = TransformLookupBuilder.build() this.snippetBuilder = new StepDefinitionSnippetBuilder({ snippetSyntax: this.snippetSyntax, - parameterTypeRegistry: this.transformsLookup + parameterTypeRegistry: this.transformsLookup, }) }) @@ -21,8 +21,8 @@ describe('StepDefinitionSnippetBuilder', () => { keywordType: KeywordType.PRECONDITION, pickleStep: { arguments: [], - text: '' - } + text: '', + }, } }) diff --git a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js index 6563fe785..3fa47b7c0 100644 --- a/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js +++ b/src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js @@ -16,10 +16,10 @@ describe('JavascriptSnippetSyntax', () => { generatedExpressions: [ { source: 'pattern', - parameterNames: ['arg1', 'arg2'] - } + parameterNames: ['arg1', 'arg2'], + }, ], - stepParameterNames: [] + stepParameterNames: [], }) const expected = "functionName('pattern', function (arg1, arg2, callback) {\n" + @@ -42,10 +42,10 @@ describe('JavascriptSnippetSyntax', () => { generatedExpressions: [ { source: 'pattern', - parameterNames: ['arg1', 'arg2'] - } + parameterNames: ['arg1', 'arg2'], + }, ], - stepParameterNames: [] + stepParameterNames: [], }) const expected = "functionName('pattern', function *(arg1, arg2) {\n" + @@ -68,10 +68,10 @@ describe('JavascriptSnippetSyntax', () => { generatedExpressions: [ { source: 'pattern', - parameterNames: ['arg1', 'arg2'] - } + parameterNames: ['arg1', 'arg2'], + }, ], - stepParameterNames: [] + stepParameterNames: [], }) const expected = "functionName('pattern', function (arg1, arg2) {\n" + @@ -94,10 +94,10 @@ describe('JavascriptSnippetSyntax', () => { generatedExpressions: [ { source: 'pattern', - parameterNames: ['arg1', 'arg2'] - } + parameterNames: ['arg1', 'arg2'], + }, ], - stepParameterNames: [] + stepParameterNames: [], }) const expected = "functionName('pattern', function (arg1, arg2) {\n" + @@ -120,10 +120,10 @@ describe('JavascriptSnippetSyntax', () => { generatedExpressions: [ { source: "pattern'", - parameterNames: ['arg1', 'arg2'] - } + parameterNames: ['arg1', 'arg2'], + }, ], - stepParameterNames: [] + stepParameterNames: [], }) const expected = "functionName('pattern\\'', function (arg1, arg2) {\n" + @@ -146,18 +146,18 @@ describe('JavascriptSnippetSyntax', () => { generatedExpressions: [ { parameterNames: ['argA', 'argB'], - source: 'pattern1' + source: 'pattern1', }, { parameterNames: ['argC', 'argD'], - source: 'pattern2' + source: 'pattern2', }, { parameterNames: ['argE', 'argF'], - source: 'pattern3' - } + source: 'pattern3', + }, ], - stepParameterNames: [] + stepParameterNames: [], }) const expected = "functionName('pattern1', function (argA, argB) {\n" + diff --git a/src/formatter/summary_formatter.js b/src/formatter/summary_formatter.js index 9729456ee..40a5f39a3 100644 --- a/src/formatter/summary_formatter.js +++ b/src/formatter/summary_formatter.js @@ -40,7 +40,7 @@ export default class SummaryFormatter extends Formatter { formatSummary({ colorFns: this.colorFns, testCaseMap: this.eventDataCollector.testCaseMap, - testRun + testRun, }) ) } @@ -50,7 +50,7 @@ export default class SummaryFormatter extends Formatter { issues.forEach((testCase, index) => { const { gherkinDocument, - pickle + pickle, } = this.eventDataCollector.getTestCaseData(testCase.sourceLocation) this.log( formatIssue({ @@ -59,7 +59,7 @@ export default class SummaryFormatter extends Formatter { number: index + 1, pickle, snippetBuilder: this.snippetBuilder, - testCase + testCase, }) ) }) diff --git a/src/formatter/summary_formatter_spec.js b/src/formatter/summary_formatter_spec.js index 7084473d6..51d2fb39f 100644 --- a/src/formatter/summary_formatter_spec.js +++ b/src/formatter/summary_formatter_spec.js @@ -21,7 +21,7 @@ describe('SummaryFormatter', () => { eventBroadcaster: this.eventBroadcaster, eventDataCollector: new EventDataCollector(this.eventBroadcaster), log: logFn, - snippetBuilder: createMock({ build: 'snippet' }) + snippetBuilder: createMock({ build: 'snippet' }), }) }) @@ -37,7 +37,7 @@ describe('SummaryFormatter', () => { this.eventBroadcaster.emit('pickle-accepted', { type: 'pickle-accepted', pickle: event.pickle, - uri: event.uri + uri: event.uri, }) } }) @@ -51,21 +51,21 @@ describe('SummaryFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 3 }, - actionLocation: { uri: 'steps.js', line: 4 } - } - ] + actionLocation: { uri: 'steps.js', line: 4 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { exception: 'error', status: Status.FAILED } + result: { exception: 'error', status: Status.FAILED }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { status: Status.FAILED } + result: { status: Status.FAILED }, }) this.eventBroadcaster.emit('test-run-finished', { - result: { duration: 0 } + result: { duration: 0 }, }) }) @@ -90,9 +90,9 @@ describe('SummaryFormatter', () => { sourceLocation: this.testCase.sourceLocation, steps: [ { - sourceLocation: { uri: 'a.feature', line: 3 } - } - ] + sourceLocation: { uri: 'a.feature', line: 3 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, @@ -102,15 +102,15 @@ describe('SummaryFormatter', () => { 'Multiple step definitions match:\n' + ' pattern1 - steps.js:3\n' + ' longer pattern2 - steps.js:4', - status: Status.AMBIGUOUS - } + status: Status.AMBIGUOUS, + }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { status: Status.AMBIGUOUS } + result: { status: Status.AMBIGUOUS }, }) this.eventBroadcaster.emit('test-run-finished', { - result: { duration: 0 } + result: { duration: 0 }, }) }) @@ -137,21 +137,21 @@ describe('SummaryFormatter', () => { sourceLocation: this.testCase.sourceLocation, steps: [ { - sourceLocation: { uri: 'a.feature', line: 3 } - } - ] + sourceLocation: { uri: 'a.feature', line: 3 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { status: Status.UNDEFINED } + result: { status: Status.UNDEFINED }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { status: Status.UNDEFINED } + result: { status: Status.UNDEFINED }, }) this.eventBroadcaster.emit('test-run-finished', { - result: { duration: 0 } + result: { duration: 0 }, }) }) @@ -180,21 +180,21 @@ describe('SummaryFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 3 }, - actionLocation: { uri: 'steps.js', line: 4 } - } - ] + actionLocation: { uri: 'steps.js', line: 4 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { status: Status.PENDING } + result: { status: Status.PENDING }, }) this.eventBroadcaster.emit('test-case-finished', { sourceLocation: this.testCase.sourceLocation, - result: { status: Status.PENDING } + result: { status: Status.PENDING }, }) this.eventBroadcaster.emit('test-run-finished', { - result: { duration: 0 } + result: { duration: 0 }, }) }) @@ -217,7 +217,7 @@ describe('SummaryFormatter', () => { describe('with a duration of 123 milliseconds', () => { beforeEach(function() { this.eventBroadcaster.emit('test-run-finished', { - result: { duration: 123 } + result: { duration: 123 }, }) }) @@ -229,7 +229,7 @@ describe('SummaryFormatter', () => { describe('with a duration of 12.3 seconds', () => { beforeEach(function() { this.eventBroadcaster.emit('test-run-finished', { - result: { duration: 123 * 100 } + result: { duration: 123 * 100 }, }) }) @@ -241,7 +241,7 @@ describe('SummaryFormatter', () => { describe('with a duration of 120.3 seconds', () => { beforeEach(function() { this.eventBroadcaster.emit('test-run-finished', { - result: { duration: 123 * 1000 } + result: { duration: 123 * 1000 }, }) }) diff --git a/src/formatter/usage_formatter.js b/src/formatter/usage_formatter.js index 3e37bf742..86f968674 100644 --- a/src/formatter/usage_formatter.js +++ b/src/formatter/usage_formatter.js @@ -12,7 +12,7 @@ export default class UsageFormatter extends Formatter { logUsage() { const usage = getUsage({ stepDefinitions: this.supportCodeLibrary.stepDefinitions, - eventDataCollector: this.eventDataCollector + eventDataCollector: this.eventDataCollector, }) if (usage.length === 0) { this.log('No step definitions') @@ -22,8 +22,8 @@ export default class UsageFormatter extends Formatter { head: ['Pattern / Text', 'Duration', 'Location'], style: { border: [], - head: [] - } + head: [], + }, }) usage.forEach(({ line, matches, meanDuration, pattern, uri }) => { const col1 = [pattern.toString()] diff --git a/src/formatter/usage_formatter_spec.js b/src/formatter/usage_formatter_spec.js index df1cdb305..2e0def3c5 100644 --- a/src/formatter/usage_formatter_spec.js +++ b/src/formatter/usage_formatter_spec.js @@ -14,13 +14,13 @@ describe('UsageFormatter', () => { this.output += data } this.supportCodeLibrary = { - stepDefinitions: [] + stepDefinitions: [], } this.usageFormatter = new UsageFormatter({ eventBroadcaster: this.eventBroadcaster, eventDataCollector: new EventDataCollector(this.eventBroadcaster), log: logFn, - supportCodeLibrary: this.supportCodeLibrary + supportCodeLibrary: this.supportCodeLibrary, }) }) @@ -39,7 +39,7 @@ describe('UsageFormatter', () => { this.stepDefinition = { line: 1, pattern: '/^abc?$/', - uri: 'steps.js' + uri: 'steps.js', } this.supportCodeLibrary.stepDefinitions = [this.stepDefinition] }) @@ -72,7 +72,7 @@ describe('UsageFormatter', () => { this.eventBroadcaster.emit('pickle-accepted', { type: 'pickle-accepted', pickle: event.pickle, - uri: event.uri + uri: event.uri, }) } }) @@ -82,13 +82,13 @@ describe('UsageFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 3 }, - actionLocation: { uri: 'steps.js', line: 1 } + actionLocation: { uri: 'steps.js', line: 1 }, }, { sourceLocation: { uri: 'a.feature', line: 4 }, - actionLocation: { uri: 'steps.js', line: 1 } - } - ] + actionLocation: { uri: 'steps.js', line: 1 }, + }, + ], }) }) @@ -97,12 +97,12 @@ describe('UsageFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: {} + result: {}, }) this.eventBroadcaster.emit('test-step-finished', { index: 1, testCase: this.testCase, - result: {} + result: {}, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -125,12 +125,12 @@ describe('UsageFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { duration: 1 } + result: { duration: 1 }, }) this.eventBroadcaster.emit('test-step-finished', { index: 1, testCase: this.testCase, - result: { duration: 0 } + result: { duration: 0 }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -156,18 +156,18 @@ describe('UsageFormatter', () => { { line: 1, pattern: '/abc/', - uri: 'steps.js' + uri: 'steps.js', }, { line: 2, pattern: '/def/', - uri: 'steps.js' + uri: 'steps.js', }, { line: 3, pattern: '/ghi/', - uri: 'steps.js' - } + uri: 'steps.js', + }, ] const events = Gherkin.generateEvents( 'Feature: a\nScenario: b\nGiven abc\nWhen def', @@ -179,7 +179,7 @@ describe('UsageFormatter', () => { this.eventBroadcaster.emit('pickle-accepted', { type: 'pickle-accepted', pickle: event.pickle, - uri: event.uri + uri: event.uri, }) } }) @@ -189,23 +189,23 @@ describe('UsageFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 3 }, - actionLocation: { uri: 'steps.js', line: 1 } + actionLocation: { uri: 'steps.js', line: 1 }, }, { sourceLocation: { uri: 'a.feature', line: 4 }, - actionLocation: { uri: 'steps.js', line: 2 } - } - ] + actionLocation: { uri: 'steps.js', line: 2 }, + }, + ], }) this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase, - result: { duration: 1 } + result: { duration: 1 }, }) this.eventBroadcaster.emit('test-step-finished', { index: 1, testCase, - result: { duration: 2 } + result: { duration: 2 }, }) this.eventBroadcaster.emit('test-run-finished') }) diff --git a/src/formatter/usage_json_formatter.js b/src/formatter/usage_json_formatter.js index 81a8c3b00..6c3802e54 100644 --- a/src/formatter/usage_json_formatter.js +++ b/src/formatter/usage_json_formatter.js @@ -10,7 +10,7 @@ export default class UsageJsonFormatter extends Formatter { logUsage() { const usage = getUsage({ stepDefinitions: this.supportCodeLibrary.stepDefinitions, - eventDataCollector: this.eventDataCollector + eventDataCollector: this.eventDataCollector, }) this.log(JSON.stringify(usage, null, 2)) } diff --git a/src/formatter/usage_json_formatter_spec.js b/src/formatter/usage_json_formatter_spec.js index a5ee0a010..ba8a91e4b 100644 --- a/src/formatter/usage_json_formatter_spec.js +++ b/src/formatter/usage_json_formatter_spec.js @@ -18,25 +18,25 @@ describe('UsageJsonFormatter', () => { { line: 1, pattern: '/abc/', - uri: 'steps.js' + uri: 'steps.js', }, { line: 2, pattern: '/def/', - uri: 'steps.js' + uri: 'steps.js', }, { line: 3, pattern: '/ghi/', - uri: 'steps.js' - } - ] + uri: 'steps.js', + }, + ], } this.usageJsonFormatter = new UsageJsonFormatter({ eventBroadcaster, eventDataCollector: new EventDataCollector(eventBroadcaster), log: logFn, - supportCodeLibrary + supportCodeLibrary, }) const events = Gherkin.generateEvents( 'Feature: a\nScenario: b\nGiven abc\nWhen def', @@ -48,7 +48,7 @@ describe('UsageJsonFormatter', () => { eventBroadcaster.emit('pickle-accepted', { type: 'pickle-accepted', pickle: event.pickle, - uri: event.uri + uri: event.uri, }) } }) @@ -58,23 +58,23 @@ describe('UsageJsonFormatter', () => { steps: [ { sourceLocation: { uri: 'a.feature', line: 3 }, - actionLocation: { uri: 'steps.js', line: 1 } + actionLocation: { uri: 'steps.js', line: 1 }, }, { sourceLocation: { uri: 'a.feature', line: 4 }, - actionLocation: { uri: 'steps.js', line: 2 } - } - ] + actionLocation: { uri: 'steps.js', line: 2 }, + }, + ], }) eventBroadcaster.emit('test-step-finished', { index: 0, testCase, - result: { duration: 1 } + result: { duration: 1 }, }) eventBroadcaster.emit('test-step-finished', { index: 1, testCase, - result: { duration: 2 } + result: { duration: 2 }, }) eventBroadcaster.emit('test-run-finished') }) @@ -89,12 +89,12 @@ describe('UsageJsonFormatter', () => { duration: 2, line: 4, text: 'def', - uri: 'a.feature' - } + uri: 'a.feature', + }, ], meanDuration: 2, pattern: '/def/', - uri: 'steps.js' + uri: 'steps.js', }, { line: 1, @@ -103,19 +103,19 @@ describe('UsageJsonFormatter', () => { duration: 1, line: 3, text: 'abc', - uri: 'a.feature' - } + uri: 'a.feature', + }, ], meanDuration: 1, pattern: '/abc/', - uri: 'steps.js' + uri: 'steps.js', }, { line: 3, matches: [], pattern: '/ghi/', - uri: 'steps.js' - } + uri: 'steps.js', + }, ]) }) }) diff --git a/src/index.js b/src/index.js index 716575e8a..8b4b62a2a 100644 --- a/src/index.js +++ b/src/index.js @@ -8,7 +8,7 @@ export { default as PickleFilter } from './pickle_filter' export { default as Runtime } from './runtime' export { default as Status } from './status' export { - default as supportCodeLibraryBuilder + default as supportCodeLibraryBuilder, } from './support_code_library_builder' // Formatters diff --git a/src/models/data_table_spec.js b/src/models/data_table_spec.js index 7c741ab92..c63a65b2f 100644 --- a/src/models/data_table_spec.js +++ b/src/models/data_table_spec.js @@ -8,15 +8,15 @@ describe('DataTable', () => { this.dataTable = new DataTable({ rows: [ { - cells: [{ value: 'header 1' }, { value: 'header 2' }] + cells: [{ value: 'header 1' }, { value: 'header 2' }], }, { - cells: [{ value: 'row 1 col 1' }, { value: 'row 1 col 2' }] + cells: [{ value: 'row 1 col 1' }, { value: 'row 1 col 2' }], }, { - cells: [{ value: 'row 2 col 1' }, { value: 'row 2 col 2' }] - } - ] + cells: [{ value: 'row 2 col 1' }, { value: 'row 2 col 2' }], + }, + ], }) }) @@ -24,7 +24,7 @@ describe('DataTable', () => { it('returns a 2-D array without the header', function() { expect(this.dataTable.rows()).to.eql([ ['row 1 col 1', 'row 1 col 2'], - ['row 2 col 1', 'row 2 col 2'] + ['row 2 col 1', 'row 2 col 2'], ]) }) }) @@ -33,7 +33,7 @@ describe('DataTable', () => { it('returns an array of object where the keys are the headers', function() { expect(this.dataTable.hashes()).to.eql([ { 'header 1': 'row 1 col 1', 'header 2': 'row 1 col 2' }, - { 'header 1': 'row 2 col 1', 'header 2': 'row 2 col 2' } + { 'header 1': 'row 2 col 1', 'header 2': 'row 2 col 2' }, ]) }) }) @@ -44,12 +44,12 @@ describe('DataTable', () => { this.dataTable = new DataTable({ rows: [ { - cells: [{ value: 'row 1 col 1' }, { value: 'row 1 col 2' }] + cells: [{ value: 'row 1 col 1' }, { value: 'row 1 col 2' }], }, { - cells: [{ value: 'row 2 col 1' }, { value: 'row 2 col 2' }] - } - ] + cells: [{ value: 'row 2 col 1' }, { value: 'row 2 col 2' }], + }, + ], }) }) @@ -57,7 +57,7 @@ describe('DataTable', () => { it('returns a 2-D array', function() { expect(this.dataTable.raw()).to.eql([ ['row 1 col 1', 'row 1 col 2'], - ['row 2 col 1', 'row 2 col 2'] + ['row 2 col 1', 'row 2 col 2'], ]) }) }) @@ -66,7 +66,7 @@ describe('DataTable', () => { it('returns an object where the keys are the first column', function() { expect(this.dataTable.rowsHash()).to.eql({ 'row 1 col 1': 'row 1 col 2', - 'row 2 col 1': 'row 2 col 2' + 'row 2 col 1': 'row 2 col 2', }) }) }) diff --git a/src/models/step_definition.js b/src/models/step_definition.js index 7e6cbec9e..2ea6eeb99 100644 --- a/src/models/step_definition.js +++ b/src/models/step_definition.js @@ -33,7 +33,7 @@ export default class StepDefinition { .map(arg => arg.getValue(world)) const iterator = buildStepArgumentIterator({ dataTable: arg => new DataTable(arg), - docString: arg => arg.content + docString: arg => arg.content, }) const stepArgumentParameters = step.arguments.map(iterator) return stepNameParameters.concat(stepArgumentParameters) diff --git a/src/models/test_case_hook_definition.js b/src/models/test_case_hook_definition.js index 2d3ca9d2a..1b82b6507 100644 --- a/src/models/test_case_hook_definition.js +++ b/src/models/test_case_hook_definition.js @@ -5,7 +5,7 @@ export default class TestCaseHookDefinition extends StepDefinition { constructor(data) { super(data) this.pickleFilter = new PickleFilter({ - tagExpression: this.options.tags + tagExpression: this.options.tags, }) } diff --git a/src/models/test_case_hook_definition_spec.js b/src/models/test_case_hook_definition_spec.js index 2a78149b3..916a9fe28 100644 --- a/src/models/test_case_hook_definition_spec.js +++ b/src/models/test_case_hook_definition_spec.js @@ -7,16 +7,16 @@ describe('TestCaseHookDefinition', () => { beforeEach(function() { this.input = { pickle: { - tags: [] + tags: [], }, - uri: '' + uri: '', } }) describe('no tags', () => { beforeEach(function() { this.testCaseHookDefinition = new TestCaseHookDefinition({ - options: {} + options: {}, }) }) @@ -31,7 +31,7 @@ describe('TestCaseHookDefinition', () => { beforeEach(function() { this.input.pickle.tags = [{ name: '@tagA' }] this.testCaseHookDefinition = new TestCaseHookDefinition({ - options: { tags: '@tagA' } + options: { tags: '@tagA' }, }) }) @@ -45,7 +45,7 @@ describe('TestCaseHookDefinition', () => { describe('tags do not match', () => { beforeEach(function() { this.testCaseHookDefinition = new TestCaseHookDefinition({ - options: { tags: '@tagA' } + options: { tags: '@tagA' }, }) }) diff --git a/src/pickle_filter_spec.js b/src/pickle_filter_spec.js index b9e136a2b..1a3d8d076 100644 --- a/src/pickle_filter_spec.js +++ b/src/pickle_filter_spec.js @@ -9,9 +9,9 @@ describe('PickleFilter', () => { pickle: { locations: [], name: '', - tags: [] + tags: [], }, - uri: '' + uri: '', } }) @@ -20,7 +20,7 @@ describe('PickleFilter', () => { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], - tagExpressions: [] + tagExpressions: [], }) }) @@ -34,7 +34,7 @@ describe('PickleFilter', () => { this.pickleFilter = new PickleFilter({ featurePaths: ['features/a.feature', 'features/b.feature:1:2'], names: [], - tagExpressions: [] + tagExpressions: [], }) }) @@ -107,7 +107,7 @@ describe('PickleFilter', () => { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: ['nameA'], - tagExpressions: [] + tagExpressions: [], }) }) @@ -137,7 +137,7 @@ describe('PickleFilter', () => { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: ['nameA', 'nameB'], - tagExpressions: [] + tagExpressions: [], }) }) @@ -179,7 +179,7 @@ describe('PickleFilter', () => { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], - tagExpression: '@tagA' + tagExpression: '@tagA', }) }) @@ -205,7 +205,7 @@ describe('PickleFilter', () => { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], - tagExpression: 'not @tagA' + tagExpression: 'not @tagA', }) }) @@ -231,7 +231,7 @@ describe('PickleFilter', () => { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], - tagExpression: '@tagA and @tagB' + tagExpression: '@tagA and @tagB', }) }) @@ -277,7 +277,7 @@ describe('PickleFilter', () => { this.pickleFilter = new PickleFilter({ featurePaths: ['features'], names: [], - tagExpression: '@tagA or @tagB' + tagExpression: '@tagA or @tagB', }) }) @@ -329,7 +329,7 @@ describe('PickleFilter', () => { this.pickleFilter = new PickleFilter({ featurePaths: ['features/b.feature:1:2'], names: ['nameA'], - tagExpressions: ['@tagA'] + tagExpressions: ['@tagA'], }) this.input.pickle.locations = [{ line: 1 }] this.input.pickle.name = 'nameA descriptionA' @@ -346,7 +346,7 @@ describe('PickleFilter', () => { this.pickleFilter = new PickleFilter({ featurePaths: ['features/b.feature:1:2'], names: ['nameA'], - tagExpressions: ['tagA'] + tagExpressions: ['tagA'], }) this.input.pickle.locations = [{ line: 1 }] }) @@ -361,7 +361,7 @@ describe('PickleFilter', () => { this.pickleFilter = new PickleFilter({ featurePaths: ['features/b.feature:1:2'], names: ['nameA'], - tagExpression: '@tagA' + tagExpression: '@tagA', }) this.input.pickle.locations = [{ line: 1 }] }) diff --git a/src/runtime/attachment_manager/index.js b/src/runtime/attachment_manager/index.js index 31b24a9d4..36baa2551 100644 --- a/src/runtime/attachment_manager/index.js +++ b/src/runtime/attachment_manager/index.js @@ -32,7 +32,7 @@ export default class AttachmentManager { createBufferAttachment(data, mediaType) { this.createStringAttachment(data.toString('base64'), { encoding: 'base64', - type: mediaType + type: mediaType, }) } diff --git a/src/runtime/attachment_manager/index_spec.js b/src/runtime/attachment_manager/index_spec.js index ad26c56b8..ea0358cee 100644 --- a/src/runtime/attachment_manager/index_spec.js +++ b/src/runtime/attachment_manager/index_spec.js @@ -29,7 +29,7 @@ describe('AttachmentManager', () => { expect(decodedData).to.eql('my string') expect(attachment.media).to.eql({ encoding: 'base64', - type: 'text/special' + type: 'text/special', }) }) }) @@ -72,7 +72,7 @@ describe('AttachmentManager', () => { expect(decodedData).to.eql('my string') expect(attachment.media).to.eql({ encoding: 'base64', - type: 'text/special' + type: 'text/special', }) }) }) @@ -104,7 +104,7 @@ describe('AttachmentManager', () => { expect(decodedData).to.eql('my string') expect(attachment.media).to.eql({ encoding: 'base64', - type: 'text/special' + type: 'text/special', }) }) }) diff --git a/src/runtime/helpers.js b/src/runtime/helpers.js index ec61cbb9d..a0a1323b3 100644 --- a/src/runtime/helpers.js +++ b/src/runtime/helpers.js @@ -19,13 +19,13 @@ export function getAmbiguousStepException(stepDefinitions) { top: '', 'top-left': '', 'top-mid': '', - 'top-right': '' + 'top-right': '', }, style: { border: [], 'padding-left': 0, - 'padding-right': 0 - } + 'padding-right': 0, + }, }) table.push( ...stepDefinitions.map(stepDefinition => { diff --git a/src/runtime/helpers_spec.js b/src/runtime/helpers_spec.js index 58ff6dc73..576ea2579 100644 --- a/src/runtime/helpers_spec.js +++ b/src/runtime/helpers_spec.js @@ -10,8 +10,8 @@ describe('Helpers', () => { { line: 4, pattern: 'longer pattern2', - uri: 'steps2.js' - } + uri: 'steps2.js', + }, ]) }) diff --git a/src/runtime/index.js b/src/runtime/index.js index 82b96e86e..53097c94e 100644 --- a/src/runtime/index.js +++ b/src/runtime/index.js @@ -17,7 +17,7 @@ export default class Runtime { this.testCases = testCases || [] this.result = { duration: 0, - success: true + success: true, } } @@ -29,7 +29,7 @@ export default class Runtime { thisArg: null, timeoutInMilliseconds: hookDefinition.options.timeout || - this.supportCodeLibrary.defaultTimeout + this.supportCodeLibrary.defaultTimeout, }) if (error) { const location = formatLocation(hookDefinition) @@ -49,7 +49,7 @@ export default class Runtime { skip, supportCodeLibrary: this.supportCodeLibrary, testCase, - worldParameters: this.options.worldParameters + worldParameters: this.options.worldParameters, }) const testCaseResult = await testCaseRunner.run() if (testCaseResult.duration) { diff --git a/src/runtime/parallel/command_types.js b/src/runtime/parallel/command_types.js index 70ec34d8d..736f5c8f6 100644 --- a/src/runtime/parallel/command_types.js +++ b/src/runtime/parallel/command_types.js @@ -3,7 +3,7 @@ const commandTypes = { RUN: 'run', READY: 'ready', FINALIZE: 'finalize', - EVENT: 'event' + EVENT: 'event', } export default commandTypes diff --git a/src/runtime/parallel/master.js b/src/runtime/parallel/master.js index 222f47e28..e1b62e8cb 100644 --- a/src/runtime/parallel/master.js +++ b/src/runtime/parallel/master.js @@ -21,7 +21,7 @@ export default class Master { options, supportCodePaths, supportCodeRequiredModules, - testCases + testCases, }) { this.eventBroadcaster = eventBroadcaster this.options = options || {} @@ -32,7 +32,7 @@ export default class Master { this.testCasesCompleted = 0 this.result = { duration: 0, - success: true + success: true, } this.slaves = {} } @@ -59,9 +59,9 @@ export default class Master { env: _.assign({}, process.env, { CUCUMBER_PARALLEL: 'true', CUCUMBER_TOTAL_SLAVES: total, - CUCUMBER_SLAVE_ID: id + CUCUMBER_SLAVE_ID: id, }), - stdio: ['pipe', 'pipe', process.stderr] + stdio: ['pipe', 'pipe', process.stderr], }) const rl = readline.createInterface({ input: slaveProcess.stdout }) const slave = { process: slaveProcess } @@ -79,7 +79,7 @@ export default class Master { filterStacktraces: this.options.filterStacktraces, supportCodePaths: this.supportCodePaths, supportCodeRequiredModules: this.supportCodeRequiredModules, - worldParameters: this.options.worldParameters + worldParameters: this.options.worldParameters, }) + '\n' ) } diff --git a/src/runtime/parallel/run_slave.js b/src/runtime/parallel/run_slave.js index 140f6d8bd..ea8350849 100644 --- a/src/runtime/parallel/run_slave.js +++ b/src/runtime/parallel/run_slave.js @@ -4,7 +4,7 @@ export default async function run() { const slave = new Slave({ stdin: process.stdin, stdout: process.stdout, - cwd: process.cwd() + cwd: process.cwd(), }) await slave.run() } diff --git a/src/runtime/parallel/slave.js b/src/runtime/parallel/slave.js index c22d20c79..c9798864d 100644 --- a/src/runtime/parallel/slave.js +++ b/src/runtime/parallel/slave.js @@ -15,7 +15,7 @@ const EVENTS = [ 'test-step-started', 'test-step-attachment', 'test-step-finished', - 'test-case-finished' + 'test-case-finished', ] export default class Slave { @@ -39,7 +39,7 @@ export default class Slave { filterStacktraces, supportCodeRequiredModules, supportCodePaths, - worldParameters + worldParameters, }) { supportCodeRequiredModules.map(module => require(module)) supportCodeLibraryBuilder.reset(this.cwd) @@ -86,7 +86,7 @@ export default class Slave { skip, supportCodeLibrary: this.supportCodeLibrary, testCase, - worldParameters: this.worldParameters + worldParameters: this.worldParameters, }) await testCaseRunner.run() this.stdout.write(JSON.stringify({ command: commandTypes.READY }) + '\n') @@ -100,7 +100,7 @@ export default class Slave { thisArg: null, timeoutInMilliseconds: hookDefinition.options.timeout || - this.supportCodeLibrary.defaultTimeout + this.supportCodeLibrary.defaultTimeout, }) if (error) { const location = formatLocation(hookDefinition) diff --git a/src/runtime/step_runner.js b/src/runtime/step_runner.js index cb750c96a..8142b3d5c 100644 --- a/src/runtime/step_runner.js +++ b/src/runtime/step_runner.js @@ -12,7 +12,7 @@ async function run({ parameterTypeRegistry, step, stepDefinition, - world + world, }) { beginTiming() let error, result, parameters @@ -23,7 +23,7 @@ async function run({ hookParameter, parameterTypeRegistry, step, - world + world, }) ) } catch (err) { @@ -40,7 +40,7 @@ async function run({ argsArray: parameters, fn: stepDefinition.code, thisArg: world, - timeoutInMilliseconds + timeoutInMilliseconds, }) error = data.error result = data.result diff --git a/src/runtime/test_case_runner.js b/src/runtime/test_case_runner.js index f236ffb6e..7708ddf50 100644 --- a/src/runtime/test_case_runner.js +++ b/src/runtime/test_case_runner.js @@ -11,13 +11,13 @@ export default class TestCaseRunner { skip, testCase, supportCodeLibrary, - worldParameters + worldParameters, }) { const attachmentManager = new AttachmentManager(({ data, media }) => { this.emit('test-step-attachment', { index: this.testStepIndex, data, - media + media, }) }) this.eventBroadcaster = eventBroadcaster @@ -26,18 +26,18 @@ export default class TestCaseRunner { this.supportCodeLibrary = supportCodeLibrary this.world = new supportCodeLibrary.World({ attach: ::attachmentManager.create, - parameters: worldParameters + parameters: worldParameters, }) this.beforeHookDefinitions = this.getBeforeHookDefinitions() this.afterHookDefinitions = this.getAfterHookDefinitions() this.testStepIndex = 0 this.result = { duration: 0, - status: this.skip ? Status.SKIPPED : Status.PASSED + status: this.skip ? Status.SKIPPED : Status.PASSED, } this.testCaseSourceLocation = { uri: this.testCase.uri, - line: this.testCase.pickle.locations[0].line + line: this.testCase.pickle.locations[0].line, } } @@ -60,11 +60,11 @@ export default class TestCaseRunner { this.testCase.pickle.steps.forEach(step => { const actionLocations = this.getStepDefinitions(step).map(definition => ({ uri: definition.uri, - line: definition.line + line: definition.line, })) const sourceLocation = { uri: this.testCase.uri, - line: _.last(step.locations).line + line: _.last(step.locations).line, } const data = { sourceLocation } if (actionLocations.length === 1) { @@ -95,7 +95,7 @@ export default class TestCaseRunner { return this.supportCodeLibrary.stepDefinitions.filter(stepDefinition => stepDefinition.matchesStepName({ stepName: step.text, - parameterTypeRegistry: this.supportCodeLibrary.parameterTypeRegistry + parameterTypeRegistry: this.supportCodeLibrary.parameterTypeRegistry, }) ) } @@ -107,7 +107,7 @@ export default class TestCaseRunner { parameterTypeRegistry: this.supportCodeLibrary.parameterTypeRegistry, step, stepDefinition, - world: this.world + world: this.world, }) } @@ -145,7 +145,7 @@ export default class TestCaseRunner { } this.emit('test-step-finished', { index: this.testStepIndex, - result: testStepResult + result: testStepResult, }) this.testStepIndex += 1 } @@ -155,13 +155,13 @@ export default class TestCaseRunner { this.emit('test-case-started', {}) await this.runHooks(this.beforeHookDefinitions, { sourceLocation: this.testCaseSourceLocation, - pickle: this.testCase.pickle + pickle: this.testCase.pickle, }) await this.runSteps() await this.runHooks(this.afterHookDefinitions, { sourceLocation: this.testCaseSourceLocation, pickle: this.testCase.pickle, - result: this.result + result: this.result, }) this.emit('test-case-finished', { result: this.result }) return this.result @@ -189,7 +189,7 @@ export default class TestCaseRunner { } else if (stepDefinitions.length > 1) { return { exception: getAmbiguousStepException(stepDefinitions), - status: Status.AMBIGUOUS + status: Status.AMBIGUOUS, } } else if (this.isSkippingSteps()) { return { status: Status.SKIPPED } diff --git a/src/runtime/test_case_runner_spec.js b/src/runtime/test_case_runner_spec.js index 931ccac35..2ea3ab834 100644 --- a/src/runtime/test_case_runner_spec.js +++ b/src/runtime/test_case_runner_spec.js @@ -23,9 +23,9 @@ describe('TestCaseRunner', () => { this.testCase = { pickle: { steps: [], - locations: [{ line: 1 }] + locations: [{ line: 1 }], }, - uri: 'path/to/feature' + uri: 'path/to/feature', } this.supportCodeLibrary = { afterTestCaseHookDefinitions: [], @@ -33,7 +33,7 @@ describe('TestCaseRunner', () => { defaultTimeout: 5000, stepDefinitions: [], parameterTypeRegistry: {}, - World() {} + World() {}, } sinon.stub(StepRunner, 'run') }) @@ -49,7 +49,7 @@ describe('TestCaseRunner', () => { eventBroadcaster: this.eventBroadcaster, skip: false, testCase: this.testCase, - supportCodeLibrary: this.supportCodeLibrary + supportCodeLibrary: this.supportCodeLibrary, }) await scenarioRunner.run() }) @@ -58,14 +58,14 @@ describe('TestCaseRunner', () => { expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [], - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) @@ -73,7 +73,7 @@ describe('TestCaseRunner', () => { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.PASSED }, - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) }) @@ -83,12 +83,12 @@ describe('TestCaseRunner', () => { this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } this.stepResult = { duration: 1, - status: Status.PASSED + status: Status.PASSED, } const stepDefinition = { uri: 'path/to/steps', line: 3, - matchesStepName: sinon.stub().returns(true) + matchesStepName: sinon.stub().returns(true), } StepRunner.run.resolves(this.stepResult) this.supportCodeLibrary.stepDefinitions = [stepDefinition] @@ -97,7 +97,7 @@ describe('TestCaseRunner', () => { eventBroadcaster: this.eventBroadcaster, skip: false, testCase: this.testCase, - supportCodeLibrary: this.supportCodeLibrary + supportCodeLibrary: this.supportCodeLibrary, }) await scenarioRunner.run() }) @@ -108,17 +108,17 @@ describe('TestCaseRunner', () => { steps: [ { actionLocation: { line: 3, uri: 'path/to/steps' }, - sourceLocation: { line: 2, uri: 'path/to/feature' } - } + sourceLocation: { line: 2, uri: 'path/to/feature' }, + }, ], - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) @@ -126,7 +126,7 @@ describe('TestCaseRunner', () => { expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, - testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } + testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, }) }) @@ -135,7 +135,7 @@ describe('TestCaseRunner', () => { expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, - result: { duration: 1, status: Status.PASSED } + result: { duration: 1, status: Status.PASSED }, }) }) @@ -143,7 +143,7 @@ describe('TestCaseRunner', () => { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 1, status: Status.PASSED }, - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) }) @@ -155,12 +155,12 @@ describe('TestCaseRunner', () => { this.stepResult = { duration: 1, status: Status.FAILED, - exception: this.error + exception: this.error, } const stepDefinition = { uri: 'path/to/steps', line: 3, - matchesStepName: sinon.stub().returns(true) + matchesStepName: sinon.stub().returns(true), } StepRunner.run.resolves(this.stepResult) this.supportCodeLibrary.stepDefinitions = [stepDefinition] @@ -169,7 +169,7 @@ describe('TestCaseRunner', () => { eventBroadcaster: this.eventBroadcaster, skip: false, testCase: this.testCase, - supportCodeLibrary: this.supportCodeLibrary + supportCodeLibrary: this.supportCodeLibrary, }) await scenarioRunner.run() }) @@ -180,17 +180,17 @@ describe('TestCaseRunner', () => { steps: [ { actionLocation: { line: 3, uri: 'path/to/steps' }, - sourceLocation: { line: 2, uri: 'path/to/feature' } - } + sourceLocation: { line: 2, uri: 'path/to/feature' }, + }, ], - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) @@ -198,7 +198,7 @@ describe('TestCaseRunner', () => { expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, - testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } + testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, }) }) @@ -210,8 +210,8 @@ describe('TestCaseRunner', () => { result: { duration: 1, status: Status.FAILED, - exception: this.error - } + exception: this.error, + }, }) }) @@ -221,9 +221,9 @@ describe('TestCaseRunner', () => { result: { duration: 1, status: Status.FAILED, - exception: this.error + exception: this.error, }, - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) }) @@ -235,24 +235,24 @@ describe('TestCaseRunner', () => { pattern: 'pattern1', uri: 'path/to/steps', line: 3, - matchesStepName: sinon.stub().returns(true) + matchesStepName: sinon.stub().returns(true), } const stepDefinition2 = { pattern: 'pattern2', uri: 'path/to/steps', line: 4, - matchesStepName: sinon.stub().returns(true) + matchesStepName: sinon.stub().returns(true), } this.supportCodeLibrary.stepDefinitions = [ stepDefinition1, - stepDefinition2 + stepDefinition2, ] this.testCase.pickle.steps = [this.step] const scenarioRunner = new TestCaseRunner({ eventBroadcaster: this.eventBroadcaster, skip: false, testCase: this.testCase, - supportCodeLibrary: this.supportCodeLibrary + supportCodeLibrary: this.supportCodeLibrary, }) await scenarioRunner.run() }) @@ -262,17 +262,17 @@ describe('TestCaseRunner', () => { expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [ { - sourceLocation: { line: 2, uri: 'path/to/feature' } - } + sourceLocation: { line: 2, uri: 'path/to/feature' }, + }, ], - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) @@ -280,7 +280,7 @@ describe('TestCaseRunner', () => { expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, - testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } + testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, }) }) @@ -294,8 +294,8 @@ describe('TestCaseRunner', () => { 'Multiple step definitions match:\n' + ' pattern1 - path/to/steps:3\n' + ' pattern2 - path/to/steps:4', - status: Status.AMBIGUOUS - } + status: Status.AMBIGUOUS, + }, }) }) @@ -308,9 +308,9 @@ describe('TestCaseRunner', () => { exception: 'Multiple step definitions match:\n' + ' pattern1 - path/to/steps:3\n' + - ' pattern2 - path/to/steps:4' + ' pattern2 - path/to/steps:4', }, - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) }) @@ -323,7 +323,7 @@ describe('TestCaseRunner', () => { eventBroadcaster: this.eventBroadcaster, skip: false, testCase: this.testCase, - supportCodeLibrary: this.supportCodeLibrary + supportCodeLibrary: this.supportCodeLibrary, }) await scenarioRunner.run() }) @@ -332,14 +332,14 @@ describe('TestCaseRunner', () => { expect(this.onTestCasePrepared).to.have.callCount(1) expect(this.onTestCasePrepared).to.have.been.calledWith({ steps: [{ sourceLocation: { line: 2, uri: 'path/to/feature' } }], - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) @@ -347,7 +347,7 @@ describe('TestCaseRunner', () => { expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, - testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } + testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, }) }) @@ -356,7 +356,7 @@ describe('TestCaseRunner', () => { expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, - result: { status: Status.UNDEFINED } + result: { status: Status.UNDEFINED }, }) }) @@ -364,7 +364,7 @@ describe('TestCaseRunner', () => { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.UNDEFINED }, - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) }) @@ -375,7 +375,7 @@ describe('TestCaseRunner', () => { const stepDefinition = { uri: 'path/to/steps', line: 3, - matchesStepName: sinon.stub().returns(true) + matchesStepName: sinon.stub().returns(true), } this.supportCodeLibrary.stepDefinitions = [stepDefinition] this.testCase.pickle.steps = [this.step] @@ -383,7 +383,7 @@ describe('TestCaseRunner', () => { eventBroadcaster: this.eventBroadcaster, skip: true, testCase: this.testCase, - supportCodeLibrary: this.supportCodeLibrary + supportCodeLibrary: this.supportCodeLibrary, }) await scenarioRunner.run() }) @@ -394,17 +394,17 @@ describe('TestCaseRunner', () => { steps: [ { actionLocation: { line: 3, uri: 'path/to/steps' }, - sourceLocation: { line: 2, uri: 'path/to/feature' } - } + sourceLocation: { line: 2, uri: 'path/to/feature' }, + }, ], - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) @@ -412,7 +412,7 @@ describe('TestCaseRunner', () => { expect(this.onTestStepStarted).to.have.callCount(1) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, - testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } + testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, }) }) @@ -421,7 +421,7 @@ describe('TestCaseRunner', () => { expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, - result: { status: Status.SKIPPED } + result: { status: Status.SKIPPED }, }) }) @@ -429,7 +429,7 @@ describe('TestCaseRunner', () => { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.SKIPPED }, - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) }) @@ -442,16 +442,16 @@ describe('TestCaseRunner', () => { }, line: 4, options: {}, - uri: 'path/to/hooks' + uri: 'path/to/hooks', }) this.supportCodeLibrary.beforeTestCaseHookDefinitions = [ - testCaseHookDefinition + testCaseHookDefinition, ] this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } const stepDefinition = { uri: 'path/to/steps', line: 3, - matchesStepName: sinon.stub().returns(true) + matchesStepName: sinon.stub().returns(true), } this.supportCodeLibrary.stepDefinitions = [stepDefinition] this.testCase.pickle.steps = [this.step] @@ -459,7 +459,7 @@ describe('TestCaseRunner', () => { eventBroadcaster: this.eventBroadcaster, skip: true, testCase: this.testCase, - supportCodeLibrary: this.supportCodeLibrary + supportCodeLibrary: this.supportCodeLibrary, }) await scenarioRunner.run() }) @@ -471,17 +471,17 @@ describe('TestCaseRunner', () => { { actionLocation: { line: 4, uri: 'path/to/hooks' } }, { actionLocation: { line: 3, uri: 'path/to/steps' }, - sourceLocation: { line: 2, uri: 'path/to/feature' } - } + sourceLocation: { line: 2, uri: 'path/to/feature' }, + }, ], - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) @@ -489,11 +489,11 @@ describe('TestCaseRunner', () => { expect(this.onTestStepStarted).to.have.callCount(2) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, - testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } + testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, }) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 1, - testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } + testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, }) }) @@ -502,12 +502,12 @@ describe('TestCaseRunner', () => { expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, - result: { status: Status.SKIPPED } + result: { status: Status.SKIPPED }, }) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 1, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, - result: { status: Status.SKIPPED } + result: { status: Status.SKIPPED }, }) }) @@ -515,7 +515,7 @@ describe('TestCaseRunner', () => { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.SKIPPED }, - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) }) @@ -528,16 +528,16 @@ describe('TestCaseRunner', () => { }, line: 4, options: {}, - uri: 'path/to/hooks' + uri: 'path/to/hooks', }) this.supportCodeLibrary.afterTestCaseHookDefinitions = [ - testCaseHookDefinition + testCaseHookDefinition, ] this.step = { uri: 'path/to/feature', locations: [{ line: 2 }] } const stepDefinition = { uri: 'path/to/steps', line: 3, - matchesStepName: sinon.stub().returns(true) + matchesStepName: sinon.stub().returns(true), } this.supportCodeLibrary.stepDefinitions = [stepDefinition] this.testCase.pickle.steps = [this.step] @@ -545,7 +545,7 @@ describe('TestCaseRunner', () => { eventBroadcaster: this.eventBroadcaster, skip: true, testCase: this.testCase, - supportCodeLibrary: this.supportCodeLibrary + supportCodeLibrary: this.supportCodeLibrary, }) await scenarioRunner.run() }) @@ -556,18 +556,18 @@ describe('TestCaseRunner', () => { steps: [ { actionLocation: { line: 3, uri: 'path/to/steps' }, - sourceLocation: { line: 2, uri: 'path/to/feature' } + sourceLocation: { line: 2, uri: 'path/to/feature' }, }, - { actionLocation: { line: 4, uri: 'path/to/hooks' } } + { actionLocation: { line: 4, uri: 'path/to/hooks' } }, ], - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) it('emits test-case-started', function() { expect(this.onTestCaseStarted).to.have.callCount(1) expect(this.onTestCaseStarted).to.have.been.calledWith({ - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) @@ -575,11 +575,11 @@ describe('TestCaseRunner', () => { expect(this.onTestStepStarted).to.have.callCount(2) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 0, - testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } + testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, }) expect(this.onTestStepStarted).to.have.been.calledWith({ index: 1, - testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } } + testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, }) }) @@ -588,12 +588,12 @@ describe('TestCaseRunner', () => { expect(this.onTestStepFinished).to.have.been.calledWith({ index: 0, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, - result: { status: Status.SKIPPED } + result: { status: Status.SKIPPED }, }) expect(this.onTestStepFinished).to.have.been.calledWith({ index: 1, testCase: { sourceLocation: { line: 1, uri: 'path/to/feature' } }, - result: { status: Status.SKIPPED } + result: { status: Status.SKIPPED }, }) }) @@ -601,7 +601,7 @@ describe('TestCaseRunner', () => { expect(this.onTestCaseFinished).to.have.callCount(1) expect(this.onTestCaseFinished).to.have.been.calledWith({ result: { duration: 0, status: Status.SKIPPED }, - sourceLocation: { line: 1, uri: 'path/to/feature' } + sourceLocation: { line: 1, uri: 'path/to/feature' }, }) }) }) diff --git a/src/status.js b/src/status.js index e37370bd6..428d33197 100644 --- a/src/status.js +++ b/src/status.js @@ -6,7 +6,7 @@ const statuses = { PASSED: 'passed', PENDING: 'pending', SKIPPED: 'skipped', - UNDEFINED: 'undefined' + UNDEFINED: 'undefined', } export default statuses diff --git a/src/status_spec.js b/src/status_spec.js index 6f17534e0..4283b1b10 100644 --- a/src/status_spec.js +++ b/src/status_spec.js @@ -11,7 +11,7 @@ describe('Status', () => { 'PASSED', 'PENDING', 'SKIPPED', - 'UNDEFINED' + 'UNDEFINED', ]) }) }) @@ -25,7 +25,7 @@ describe('Status', () => { [Status.PASSED]: 0, [Status.PENDING]: 0, [Status.SKIPPED]: 0, - [Status.UNDEFINED]: 0 + [Status.UNDEFINED]: 0, }) }) }) diff --git a/src/support_code_library_builder/define_helpers.js b/src/support_code_library_builder/define_helpers.js index ee998e986..f68d0cfd2 100644 --- a/src/support_code_library_builder/define_helpers.js +++ b/src/support_code_library_builder/define_helpers.js @@ -21,13 +21,13 @@ export function defineTestCaseHook(builder, collectionName) { validateArguments({ args: { code, options }, fnName: 'defineTestCaseHook', - location: formatLocation({ line, uri }) + location: formatLocation({ line, uri }), }) const hookDefinition = new TestCaseHookDefinition({ code, line, options, - uri + uri, }) builder.options[collectionName].push(hookDefinition) } @@ -45,13 +45,13 @@ export function defineTestRunHook(builder, collectionName) { validateArguments({ args: { code, options }, fnName: 'defineTestRunHook', - location: formatLocation({ line, uri }) + location: formatLocation({ line, uri }), }) const hookDefinition = new TestRunHookDefinition({ code, line, options, - uri + uri, }) builder.options[collectionName].push(hookDefinition) } @@ -67,14 +67,14 @@ export function defineStep(builder) { validateArguments({ args: { code, pattern, options }, fnName: 'defineStep', - location: formatLocation({ line, uri }) + location: formatLocation({ line, uri }), }) const stepDefinition = new StepDefinition({ code, line, options, pattern, - uri + uri, }) builder.options.stepDefinitions.push(stepDefinition) } @@ -112,7 +112,7 @@ export function defineParameterType(builder) { regexp, transformer, useForSnippets, - preferForRegexpMatch + preferForRegexpMatch, }) => { const getTypeName = deprecate( () => typeName, diff --git a/src/support_code_library_builder/finalize_helpers.js b/src/support_code_library_builder/finalize_helpers.js index 6b647e41a..3d097c2bd 100644 --- a/src/support_code_library_builder/finalize_helpers.js +++ b/src/support_code_library_builder/finalize_helpers.js @@ -6,7 +6,7 @@ import path from 'path' export function wrapDefinitions({ cwd, definitionFunctionWrapper, - definitions + definitions, }) { if (definitionFunctionWrapper) { definitions.forEach(definition => { diff --git a/src/support_code_library_builder/index.js b/src/support_code_library_builder/index.js index 8cd09b27a..e1cd6c875 100644 --- a/src/support_code_library_builder/index.js +++ b/src/support_code_library_builder/index.js @@ -5,7 +5,7 @@ import { defineTestRunHook, defineParameterType, defineTestCaseHook, - defineStep + defineStep, } from './define_helpers' import { wrapDefinitions } from './finalize_helpers' @@ -29,7 +29,7 @@ export class SupportCodeLibraryBuilder { }, setWorldConstructor: fn => { this.options.World = fn - } + }, } this.methods.Given = this.methods.When = this.methods.Then = this.methods.defineStep } @@ -43,11 +43,11 @@ export class SupportCodeLibraryBuilder { 'afterTestRunHook', 'beforeTestCaseHook', 'beforeTestRunHook', - 'step' + 'step', ]) .map(key => this.options[`${key}Definitions`]) .flatten() - .value() + .value(), }) this.options.afterTestCaseHookDefinitions.reverse() this.options.afterTestRunHookDefinitions.reverse() @@ -68,7 +68,7 @@ export class SupportCodeLibraryBuilder { World({ attach, parameters }) { this.attach = attach this.parameters = parameters - } + }, }) } } diff --git a/src/support_code_library_builder/index_spec.js b/src/support_code_library_builder/index_spec.js index bf3b6d74b..8631e0121 100644 --- a/src/support_code_library_builder/index_spec.js +++ b/src/support_code_library_builder/index_spec.js @@ -24,7 +24,7 @@ describe('supportCodeLibraryBuilder', () => { ) const worldInstance = new this.options.World({ attach: this.attachFn, - parameters: { some: 'data' } + parameters: { some: 'data' }, }) expect(worldInstance.attach).to.eql(this.attachFn) expect(worldInstance.parameters).to.eql({ some: 'data' }) diff --git a/src/support_code_library_builder/validate_arguments.js b/src/support_code_library_builder/validate_arguments.js index 26e6437a0..c3772d7da 100644 --- a/src/support_code_library_builder/validate_arguments.js +++ b/src/support_code_library_builder/validate_arguments.js @@ -4,7 +4,7 @@ const optionsValidation = { expectedType: 'object or function', predicate({ options }) { return _.isPlainObject(options) - } + }, } const optionsTimeoutValidation = { @@ -12,21 +12,21 @@ const optionsTimeoutValidation = { expectedType: 'integer', predicate({ options }) { return !options.timeout || _.isInteger(options.timeout) - } + }, } const fnValidation = { expectedType: 'function', predicate({ code }) { return _.isFunction(code) - } + }, } const validations = { defineTestRunHook: [ { identifier: 'first argument', ...optionsValidation }, optionsTimeoutValidation, - { identifier: 'second argument', ...fnValidation } + { identifier: 'second argument', ...fnValidation }, ], defineTestCaseHook: [ { identifier: 'first argument', ...optionsValidation }, @@ -35,10 +35,10 @@ const validations = { expectedType: 'string', predicate({ options }) { return !options.tags || _.isString(options.tags) - } + }, }, optionsTimeoutValidation, - { identifier: 'second argument', ...fnValidation } + { identifier: 'second argument', ...fnValidation }, ], defineStep: [ { @@ -46,12 +46,12 @@ const validations = { expectedType: 'string or regular expression', predicate({ pattern }) { return _.isRegExp(pattern) || _.isString(pattern) - } + }, }, { identifier: 'second argument', ...optionsValidation }, optionsTimeoutValidation, - { identifier: 'third argument', ...fnValidation } - ] + { identifier: 'third argument', ...fnValidation }, + ], } export default function validateArguments({ args, fnName, location }) { diff --git a/src/time.js b/src/time.js index 2583d7f56..d0f11538d 100644 --- a/src/time.js +++ b/src/time.js @@ -11,7 +11,7 @@ const methods = { return getTimestamp() - previousTimestamp }, setInterval: setInterval.bind(global), - setTimeout: setTimeout.bind(global) + setTimeout: setTimeout.bind(global), } if (typeof setImmediate !== 'undefined') { diff --git a/src/user_code_runner.js b/src/user_code_runner.js index c4dd2f8d6..f03477302 100644 --- a/src/user_code_runner.js +++ b/src/user_code_runner.js @@ -33,7 +33,7 @@ export default class UserCodeRunner { 'function uses multiple asynchronous interfaces: callback and promise\n' + 'to use the callback interface: do not return a promise\n' + 'to use the promise interface: remove the last argument to the function' - ) + ), } } else if (callbackInterface) { racingPromises.push(callbackPromise) diff --git a/src/user_code_runner_spec.js b/src/user_code_runner_spec.js index d5f65cc12..08759111e 100644 --- a/src/user_code_runner_spec.js +++ b/src/user_code_runner_spec.js @@ -9,7 +9,7 @@ describe('UserCodeRunner', () => { this.options = { argsArray: [], thisArg: {}, - timeoutInMilliseconds: 100 + timeoutInMilliseconds: 100, } }) From b32d6ac139669e0f8a9e6d75006ff5bb267b76d8 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Wed, 24 Jan 2018 16:20:20 -0800 Subject: [PATCH 11/12] update --- dependency-lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/dependency-lint.yml b/dependency-lint.yml index c9a84ed36..928bcedc4 100644 --- a/dependency-lint.yml +++ b/dependency-lint.yml @@ -51,6 +51,7 @@ requiredModules: - '{features,scripts,test}/**/*' - '**/*_spec.js' - 'example/index.js' + - '**/test_helpers.js' ignore: - 'dist/**/*' - 'node_modules/**/*' From 6471141639143e8c86cbe9d1666c20f4a6c38076 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Wed, 24 Jan 2018 17:44:15 -0800 Subject: [PATCH 12/12] update --- src/formatter/progress_bar_formatter_spec.js | 2 +- src/formatter/summary_formatter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/formatter/progress_bar_formatter_spec.js b/src/formatter/progress_bar_formatter_spec.js index 8a43bcd68..d175762a9 100644 --- a/src/formatter/progress_bar_formatter_spec.js +++ b/src/formatter/progress_bar_formatter_spec.js @@ -1,6 +1,6 @@ import { beforeEach, describe, it } from 'mocha' import { expect } from 'chai' -import { createMock } from '../test_helpers' +import { createMock } from './test_helpers' import sinon from 'sinon' import getColorFns from './get_color_fns' import ProgressBarFormatter from './progress_bar_formatter' diff --git a/src/formatter/summary_formatter_spec.js b/src/formatter/summary_formatter_spec.js index 7084473d6..34f5d05ab 100644 --- a/src/formatter/summary_formatter_spec.js +++ b/src/formatter/summary_formatter_spec.js @@ -1,6 +1,6 @@ import { beforeEach, describe, it } from 'mocha' import { expect } from 'chai' -import { createMock } from '../test_helpers' +import { createMock } from './test_helpers' import getColorFns from './get_color_fns' import Status from '../status' import SummaryFormatter from './summary_formatter'