@cucumber/cucumber 8.4.0 → 8.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/api/convert_configuration.js.map +1 -1
- package/lib/api/formatters.d.ts +3 -1
- package/lib/api/formatters.js +1 -36
- package/lib/api/formatters.js.map +1 -1
- package/lib/api/plugins.d.ts +4 -0
- package/lib/api/plugins.js +19 -0
- package/lib/api/plugins.js.map +1 -0
- package/lib/api/run_cucumber.js +9 -4
- package/lib/api/run_cucumber.js.map +1 -1
- package/lib/api/runtime.d.ts +1 -0
- package/lib/api/types.d.ts +6 -7
- package/lib/api/types.js.map +1 -1
- package/lib/cli/helpers.d.ts +3 -0
- package/lib/cli/index.js +1 -1
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/install_validator.d.ts +1 -1
- package/lib/cli/install_validator.js +8 -30
- package/lib/cli/install_validator.js.map +1 -1
- package/lib/formatter/builder.d.ts +3 -0
- package/lib/formatter/get_color_fns.d.ts +1 -0
- package/lib/formatter/helpers/duration_helpers.d.ts +2 -0
- package/lib/formatter/helpers/duration_helpers.js +9 -0
- package/lib/formatter/helpers/duration_helpers.js.map +1 -0
- package/lib/formatter/index.d.ts +9 -7
- package/lib/formatter/index.js.map +1 -1
- package/lib/formatter/json_formatter.js +2 -2
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/plugin/index.d.ts +2 -0
- package/lib/plugin/index.js +19 -0
- package/lib/plugin/index.js.map +1 -0
- package/lib/plugin/plugin_manager.d.ts +13 -0
- package/lib/plugin/plugin_manager.js +36 -0
- package/lib/plugin/plugin_manager.js.map +1 -0
- package/lib/plugin/types.d.ts +14 -0
- package/lib/plugin/types.js +3 -0
- package/lib/plugin/types.js.map +1 -0
- package/lib/{formatter → publish}/http_stream.d.ts +2 -0
- package/lib/{formatter → publish}/http_stream.js +0 -0
- package/lib/publish/http_stream.js.map +1 -0
- package/lib/publish/index.d.ts +2 -0
- package/lib/publish/index.js +5 -0
- package/lib/publish/index.js.map +1 -0
- package/lib/publish/publish_plugin.d.ts +2 -0
- package/lib/publish/publish_plugin.js +48 -0
- package/lib/publish/publish_plugin.js.map +1 -0
- package/lib/runtime/attachment_manager/index.d.ts +1 -0
- package/lib/runtime/parallel/coordinator.d.ts +2 -0
- package/lib/runtime/parallel/coordinator.js +8 -8
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/support_code_library_builder/index.js +22 -1
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/time.d.ts +7 -1
- package/lib/time.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +25 -22
- package/lib/formatter/http_stream.js.map +0 -1
- package/lib/formatter/publish.d.ts +0 -1
- package/lib/formatter/publish.js +0 -5
- package/lib/formatter/publish.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/support_code_library_builder/index.ts"],"names":[],"mappings":";;;;;;AAAA,iEAA2D;AAC3D,+EAAuE;AAGvE,oGAAwE;AACxE,oGAAwE;AACxE,kGAAsE;AACtE,gFAAsD;AACtD,kDAAqD;AACrD,8EAAoD;AACpD,+BAAgC;AAChC,4DAA8B;AAE9B,yEAIuC;AACvC,oDAAgD;AAgBhD,oDAA2B;AAkCd,QAAA,qBAAqB,GAAG;IACnC,YAAY;IACZ,YAAY;IACZ,MAAM;IACN,QAAQ;IACR,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;IACR,MAAM;IACN,EAAE;CACH,CAAA;AAED,MAAa,yBAAyB;IAmBpC;QACE,IAAI,CAAC,OAAO,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,kBAAkB,CAC5B,GAAG,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAC9C;YACD,QAAQ,EAAE,IAAI,CAAC,iBAAiB,CAC9B,GAAG,EAAE,CAAC,IAAI,C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;QAClB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAA;QAC9C,IAAI,CAAC,kCAAkC,GAAG,EAAE,CAAA;QAC5C,IAAI,CAAC,iCAAiC,GAAG,EAAE,CAAA;QAC3C,IAAI,CAAC,kCAAkC,GAAG,EAAE,CAAA;QAC5C,IAAI,CAAC,mCAAmC,GAAG,EAAE,CAAA;QAC7C,IAAI,CAAC,kCAAkC,GAAG,EAAE,CAAA;QAC5C,IAAI,CAAC,mCAAmC,GAAG,EAAE,CAAA;QAC7C,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAA;QACrC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;QAC1B,IAAI,CAAC,qBAAqB,GAAG,IAAI,4CAAqB,EAAE,CAAA;QACxD,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAA;QAC/B,IAAI,CAAC,iBAAiB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAA;QACnC,IAAI,CAAC,KAAK,GAAG,eAAK,CAAA;IACpB,CAAC;CACF;AAhYD,8DAgYC;AAED,kBAAe,IAAI,yBAAyB,EAAE,CAAA","sourcesContent":["import { buildParameterType } from './build_parameter_type'\nimport { getDefinitionLineAndUri } from './get_definition_line_and_uri'\nimport { IdGenerator } from '@cucumber/messages'\nimport * as messages from '@cucumber/messages'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport StepDefinition from '../models/step_definition'\nimport { formatLocation } from '../formatter/helpers'\nimport validateArguments from './validate_arguments'\nimport { deprecate } from 'util'\nimport arity from 'util-arity'\n\nimport {\n CucumberExpression,\n ParameterTypeRegistry,\n RegularExpression,\n} from '@cucumber/cucumber-expressions'\nimport { doesHaveValue } from '../value_checker'\nimport {\n DefineStepPattern,\n IDefineStepOptions,\n IDefineSupportCodeMethods,\n IDefineTestCaseHookOptions,\n IDefineTestStepHookOptions,\n IDefineTestRunHookOptions,\n IParameterTypeDefinition,\n ISupportCodeLibrary,\n TestCaseHookFunction,\n TestStepHookFunction,\n ParallelAssignmentValidator,\n ISupportCodeCoordinates,\n IDefineStep,\n} from './types'\nimport World from './world'\nimport { ICanonicalSupportCodeIds } from '../runtime/parallel/command_types'\nimport { GherkinStepKeyword } from '../models/gherkin_step_keyword'\n\ninterface IStepDefinitionConfig {\n code: any\n line: number\n options: any\n keyword: GherkinStepKeyword\n pattern: string | RegExp\n uri: string\n}\n\ninterface ITestCaseHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\ninterface ITestStepHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\ninterface ITestRunHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\nexport const builtinParameterTypes = [\n 'bigdecimal',\n 'biginteger',\n 'byte',\n 'double',\n 'float',\n 'int',\n 'long',\n 'short',\n 'string',\n 'word',\n '',\n]\n\nexport class SupportCodeLibraryBuilder {\n public readonly methods: IDefineSupportCodeMethods\n\n private originalCoordinates: ISupportCodeCoordinates\n private afterTestCaseHookDefinitionConfigs: ITestCaseHookDefinitionConfig[]\n private afterTestRunHookDefinitionConfigs: ITestRunHookDefinitionConfig[]\n private afterTestStepHookDefinitionConfigs: ITestStepHookDefinitionConfig[]\n private beforeTestCaseHookDefinitionConfigs: ITestCaseHookDefinitionConfig[]\n private beforeTestRunHookDefinitionConfigs: ITestRunHookDefinitionConfig[]\n private beforeTestStepHookDefinitionConfigs: ITestStepHookDefinitionConfig[]\n private cwd: string\n private defaultTimeout: number\n private definitionFunctionWrapper: any\n private newId: IdGenerator.NewId\n private parameterTypeRegistry: ParameterTypeRegistry\n private stepDefinitionConfigs: IStepDefinitionConfig[]\n private World: any\n private parallelCanAssign: ParallelAssignmentValidator\n\n constructor() {\n this.methods = {\n After: this.defineTestCaseHook(\n () => this.afterTestCaseHookDefinitionConfigs\n ),\n AfterAll: this.defineTestRunHook(\n () => this.afterTestRunHookDefinitionConfigs\n ),\n AfterStep: this.defineTestStepHook(\n () => this.afterTestStepHookDefinitionConfigs\n ),\n Before: this.defineTestCaseHook(\n () => this.beforeTestCaseHookDefinitionConfigs\n ),\n BeforeAll: this.defineTestRunHook(\n () => this.beforeTestRunHookDefinitionConfigs\n ),\n BeforeStep: this.defineTestStepHook(\n () => this.beforeTestStepHookDefinitionConfigs\n ),\n defineParameterType: this.defineParameterType.bind(this),\n defineStep: deprecate(\n this.defineStep('Unknown', () => this.stepDefinitionConfigs),\n '`defineStep` is deprecated, use `Given`, `When` or `Then` instead; see https://github.com/cucumber/cucumber-js/issues/2043'\n ),\n Given: this.defineStep('Given', () => this.stepDefinitionConfigs),\n setDefaultTimeout: (milliseconds) => {\n this.defaultTimeout = milliseconds\n },\n setDefinitionFunctionWrapper: (fn) => {\n this.definitionFunctionWrapper = fn\n },\n setWorldConstructor: (fn) => {\n this.World = fn\n },\n setParallelCanAssign: (fn: ParallelAssignmentValidator): void => {\n this.parallelCanAssign = fn\n },\n Then: this.defineStep('Then', () => this.stepDefinitionConfigs),\n When: this.defineStep('When', () => this.stepDefinitionConfigs),\n }\n }\n\n defineParameterType(options: IParameterTypeDefinition<any>): void {\n const parameterType = buildParameterType(options)\n this.parameterTypeRegistry.defineParameterType(parameterType)\n }\n\n defineStep(\n keyword: GherkinStepKeyword,\n getCollection: () => IStepDefinitionConfig[]\n ): IDefineStep {\n return (\n pattern: DefineStepPattern,\n options: IDefineStepOptions | Function,\n code?: Function\n ) => {\n if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, pattern, options },\n fnName: 'defineStep',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n keyword,\n pattern,\n uri,\n })\n }\n }\n\n defineTestCaseHook(\n getCollection: () => ITestCaseHookDefinitionConfig[]\n ): <WorldType>(\n options:\n | string\n | IDefineTestCaseHookOptions\n | TestCaseHookFunction<WorldType>,\n code?: TestCaseHookFunction<WorldType>\n ) => void {\n return <WorldType>(\n options:\n | string\n | IDefineTestCaseHookOptions\n | TestCaseHookFunction<WorldType>,\n code?: TestCaseHookFunction<WorldType>\n ) => {\n if (typeof options === 'string') {\n options = { tags: options }\n } else if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestCaseHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n defineTestStepHook(\n getCollection: () => ITestStepHookDefinitionConfig[]\n ): <WorldType>(\n options:\n | string\n | IDefineTestStepHookOptions\n | TestStepHookFunction<WorldType>,\n code?: TestStepHookFunction<WorldType>\n ) => void {\n return <WorldType>(\n options:\n | string\n | IDefineTestStepHookOptions\n | TestStepHookFunction<WorldType>,\n code?: TestStepHookFunction<WorldType>\n ) => {\n if (typeof options === 'string') {\n options = { tags: options }\n } else if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestStepHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n defineTestRunHook(\n getCollection: () => ITestRunHookDefinitionConfig[]\n ): (options: IDefineTestRunHookOptions | Function, code?: Function) => void {\n return (options: IDefineTestRunHookOptions | Function, code?: Function) => {\n if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestRunHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n wrapCode({\n code,\n wrapperOptions,\n }: {\n code: Function\n wrapperOptions: any\n }): Function {\n if (doesHaveValue(this.definitionFunctionWrapper)) {\n const codeLength = code.length\n const wrappedCode = this.definitionFunctionWrapper(code, wrapperOptions)\n if (wrappedCode !== code) {\n return arity(codeLength, wrappedCode)\n }\n return wrappedCode\n }\n return code\n }\n\n buildTestCaseHookDefinitions(\n configs: ITestCaseHookDefinitionConfig[],\n canonicalIds?: string[]\n ): TestCaseHookDefinition[] {\n return configs.map(({ code, line, options, uri }, index) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestCaseHookDefinition({\n code: wrappedCode,\n id: canonicalIds ? canonicalIds[index] : this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildTestStepHookDefinitions(\n configs: ITestStepHookDefinitionConfig[]\n ): TestStepHookDefinition[] {\n return configs.map(({ code, line, options, uri }) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestStepHookDefinition({\n code: wrappedCode,\n id: this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildTestRunHookDefinitions(\n configs: ITestRunHookDefinitionConfig[]\n ): TestRunHookDefinition[] {\n return configs.map(({ code, line, options, uri }) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestRunHookDefinition({\n code: wrappedCode,\n id: this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildStepDefinitions(canonicalIds?: string[]): {\n stepDefinitions: StepDefinition[]\n undefinedParameterTypes: messages.UndefinedParameterType[]\n } {\n const stepDefinitions: StepDefinition[] = []\n const undefinedParameterTypes: messages.UndefinedParameterType[] = []\n this.stepDefinitionConfigs.forEach(\n ({ code, line, options, keyword, pattern, uri }, index) => {\n let expression\n if (typeof pattern === 'string') {\n try {\n expression = new CucumberExpression(\n pattern,\n this.parameterTypeRegistry\n )\n } catch (e) {\n if (doesHaveValue(e.undefinedParameterTypeName)) {\n undefinedParameterTypes.push({\n name: e.undefinedParameterTypeName,\n expression: pattern,\n })\n return\n }\n throw e\n }\n } else {\n expression = new RegularExpression(\n pattern,\n this.parameterTypeRegistry\n )\n }\n\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n stepDefinitions.push(\n new StepDefinition({\n code: wrappedCode,\n expression,\n id: canonicalIds ? canonicalIds[index] : this.newId(),\n line,\n options,\n keyword,\n pattern,\n unwrappedCode: code,\n uri,\n })\n )\n }\n )\n return { stepDefinitions, undefinedParameterTypes }\n }\n\n finalize(canonicalIds?: ICanonicalSupportCodeIds): ISupportCodeLibrary {\n const stepDefinitionsResult = this.buildStepDefinitions(\n canonicalIds?.stepDefinitionIds\n )\n return {\n originalCoordinates: this.originalCoordinates,\n afterTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(\n this.afterTestCaseHookDefinitionConfigs,\n canonicalIds?.afterTestCaseHookDefinitionIds\n ),\n afterTestRunHookDefinitions: this.buildTestRunHookDefinitions(\n this.afterTestRunHookDefinitionConfigs\n ),\n afterTestStepHookDefinitions: this.buildTestStepHookDefinitions(\n this.afterTestStepHookDefinitionConfigs\n ),\n beforeTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(\n this.beforeTestCaseHookDefinitionConfigs,\n canonicalIds?.beforeTestCaseHookDefinitionIds\n ),\n beforeTestRunHookDefinitions: this.buildTestRunHookDefinitions(\n this.beforeTestRunHookDefinitionConfigs\n ),\n beforeTestStepHookDefinitions: this.buildTestStepHookDefinitions(\n this.beforeTestStepHookDefinitionConfigs\n ),\n defaultTimeout: this.defaultTimeout,\n parameterTypeRegistry: this.parameterTypeRegistry,\n undefinedParameterTypes: stepDefinitionsResult.undefinedParameterTypes,\n stepDefinitions: stepDefinitionsResult.stepDefinitions,\n World: this.World,\n parallelCanAssign: this.parallelCanAssign,\n }\n }\n\n reset(\n cwd: string,\n newId: IdGenerator.NewId,\n originalCoordinates: ISupportCodeCoordinates = {\n requireModules: [],\n requirePaths: [],\n importPaths: [],\n }\n ): void {\n this.cwd = cwd\n this.newId = newId\n this.originalCoordinates = originalCoordinates\n this.afterTestCaseHookDefinitionConfigs = []\n this.afterTestRunHookDefinitionConfigs = []\n this.afterTestStepHookDefinitionConfigs = []\n this.beforeTestCaseHookDefinitionConfigs = []\n this.beforeTestRunHookDefinitionConfigs = []\n this.beforeTestStepHookDefinitionConfigs = []\n this.definitionFunctionWrapper = null\n this.defaultTimeout = 5000\n this.parameterTypeRegistry = new ParameterTypeRegistry()\n this.stepDefinitionConfigs = []\n this.parallelCanAssign = () => true\n this.World = World\n }\n}\n\nexport default new SupportCodeLibraryBuilder()\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/support_code_library_builder/index.ts"],"names":[],"mappings":";;;;;;AAAA,iEAA2D;AAC3D,+EAAuE;AAGvE,oGAAwE;AACxE,oGAAwE;AACxE,kGAAsE;AACtE,gFAAsD;AACtD,kDAAqD;AACrD,8EAAoD;AACpD,+BAAgC;AAChC,4DAA8B;AAE9B,yEAIuC;AACvC,oDAAkE;AAgBlE,oDAA2B;AAkCd,QAAA,qBAAqB,GAAG;IACnC,YAAY;IACZ,YAAY;IACZ,MAAM;IACN,QAAQ;IACR,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;IACR,MAAM;IACN,EAAE;CACH,CAAA;AAED,MAAa,yBAAyB;IAmBpC;QACE,MAAM,OAAO,GAA8B;YACzC,KAAK,EAAE,IAAI,CAAC,kBAAkB,CAC5B,GAAG,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAC9C;YACD,QAAQ,EAAE,IAAI,CAAC,iBAAiB,CAC9B,GAAG,EAAE,CAAC,IAAI,CAAC,iCAAiC,CAC7C;YACD,SAAS,EAAE,IAAI,CAAC,kBAAkB,CAChC,GAAG,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAC9C;YACD,MAAM,EAAE,IAAI,CAAC,kBAAkB,CAC7B,GAAG,EAAE,CAAC,IAAI,CAAC,mCAAmC,CAC/C;YACD,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAC/B,GAA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B,EAAE,IAAI,CAAC,iBAAiB;SAC1C,CAAA;IACH,CAAC;IAED,KAAK,CACH,GAAW,EACX,KAAwB,EACxB,sBAA+C;QAC7C,cAAc,EAAE,EAAE;QAClB,YAAY,EAAE,EAAE;QAChB,WAAW,EAAE,EAAE;KAChB;QAED,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAA;QAC9C,IAAI,CAAC,kCAAkC,GAAG,EAAE,CAAA;QAC5C,IAAI,CAAC,iCAAiC,GAAG,EAAE,CAAA;QAC3C,IAAI,CAAC,kCAAkC,GAAG,EAAE,CAAA;QAC5C,IAAI,CAAC,mCAAmC,GAAG,EAAE,CAAA;QAC7C,IAAI,CAAC,kCAAkC,GAAG,EAAE,CAAA;QAC5C,IAAI,CAAC,mCAAmC,GAAG,EAAE,CAAA;QAC7C,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAA;QACrC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;QAC1B,IAAI,CAAC,qBAAqB,GAAG,IAAI,4CAAqB,EAAE,CAAA;QACxD,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAA;QAC/B,IAAI,CAAC,iBAAiB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAA;QACnC,IAAI,CAAC,KAAK,GAAG,eAAK,CAAA;IACpB,CAAC;CACF;AA1ZD,8DA0ZC;AAED,kBAAe,IAAI,yBAAyB,EAAE,CAAA","sourcesContent":["import { buildParameterType } from './build_parameter_type'\nimport { getDefinitionLineAndUri } from './get_definition_line_and_uri'\nimport { IdGenerator } from '@cucumber/messages'\nimport * as messages from '@cucumber/messages'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport StepDefinition from '../models/step_definition'\nimport { formatLocation } from '../formatter/helpers'\nimport validateArguments from './validate_arguments'\nimport { deprecate } from 'util'\nimport arity from 'util-arity'\n\nimport {\n CucumberExpression,\n ParameterTypeRegistry,\n RegularExpression,\n} from '@cucumber/cucumber-expressions'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport {\n DefineStepPattern,\n IDefineStepOptions,\n IDefineSupportCodeMethods,\n IDefineTestCaseHookOptions,\n IDefineTestStepHookOptions,\n IDefineTestRunHookOptions,\n IParameterTypeDefinition,\n ISupportCodeLibrary,\n TestCaseHookFunction,\n TestStepHookFunction,\n ParallelAssignmentValidator,\n ISupportCodeCoordinates,\n IDefineStep,\n} from './types'\nimport World from './world'\nimport { ICanonicalSupportCodeIds } from '../runtime/parallel/command_types'\nimport { GherkinStepKeyword } from '../models/gherkin_step_keyword'\n\ninterface IStepDefinitionConfig {\n code: any\n line: number\n options: any\n keyword: GherkinStepKeyword\n pattern: string | RegExp\n uri: string\n}\n\ninterface ITestCaseHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\ninterface ITestStepHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\ninterface ITestRunHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\nexport const builtinParameterTypes = [\n 'bigdecimal',\n 'biginteger',\n 'byte',\n 'double',\n 'float',\n 'int',\n 'long',\n 'short',\n 'string',\n 'word',\n '',\n]\n\nexport class SupportCodeLibraryBuilder {\n public readonly methods: IDefineSupportCodeMethods\n\n private originalCoordinates: ISupportCodeCoordinates\n private afterTestCaseHookDefinitionConfigs: ITestCaseHookDefinitionConfig[]\n private afterTestRunHookDefinitionConfigs: ITestRunHookDefinitionConfig[]\n private afterTestStepHookDefinitionConfigs: ITestStepHookDefinitionConfig[]\n private beforeTestCaseHookDefinitionConfigs: ITestCaseHookDefinitionConfig[]\n private beforeTestRunHookDefinitionConfigs: ITestRunHookDefinitionConfig[]\n private beforeTestStepHookDefinitionConfigs: ITestStepHookDefinitionConfig[]\n private cwd: string\n private defaultTimeout: number\n private definitionFunctionWrapper: any\n private newId: IdGenerator.NewId\n private parameterTypeRegistry: ParameterTypeRegistry\n private stepDefinitionConfigs: IStepDefinitionConfig[]\n private World: any\n private parallelCanAssign: ParallelAssignmentValidator\n\n constructor() {\n const methods: IDefineSupportCodeMethods = {\n After: this.defineTestCaseHook(\n () => this.afterTestCaseHookDefinitionConfigs\n ),\n AfterAll: this.defineTestRunHook(\n () => this.afterTestRunHookDefinitionConfigs\n ),\n AfterStep: this.defineTestStepHook(\n () => this.afterTestStepHookDefinitionConfigs\n ),\n Before: this.defineTestCaseHook(\n () => this.beforeTestCaseHookDefinitionConfigs\n ),\n BeforeAll: this.defineTestRunHook(\n () => this.beforeTestRunHookDefinitionConfigs\n ),\n BeforeStep: this.defineTestStepHook(\n () => this.beforeTestStepHookDefinitionConfigs\n ),\n defineParameterType: this.defineParameterType.bind(this),\n defineStep: deprecate(\n this.defineStep('Unknown', () => this.stepDefinitionConfigs),\n '`defineStep` is deprecated, use `Given`, `When` or `Then` instead; see https://github.com/cucumber/cucumber-js/issues/2043'\n ),\n Given: this.defineStep('Given', () => this.stepDefinitionConfigs),\n setDefaultTimeout: (milliseconds) => {\n this.defaultTimeout = milliseconds\n },\n setDefinitionFunctionWrapper: (fn) => {\n this.definitionFunctionWrapper = fn\n },\n setWorldConstructor: (fn) => {\n this.World = fn\n },\n setParallelCanAssign: (fn: ParallelAssignmentValidator): void => {\n this.parallelCanAssign = fn\n },\n Then: this.defineStep('Then', () => this.stepDefinitionConfigs),\n When: this.defineStep('When', () => this.stepDefinitionConfigs),\n }\n const checkInstall = (method: string) => {\n if (doesNotHaveValue(this.cwd)) {\n throw new Error(\n `\n You're calling functions (e.g. \"${method}\") on an instance of Cucumber that isn't running.\n This means you have an invalid installation, mostly likely due to:\n - Cucumber being installed globally\n - A project structure where your support code is depending on a different instance of Cucumber\n Either way, you'll need to address this in order for Cucumber to work.\n See https://github.com/cucumber/cucumber-js/blob/main/docs/installation.md#invalid-installations\n `\n )\n }\n }\n this.methods = new Proxy(methods, {\n get(\n target: IDefineSupportCodeMethods,\n method: keyof IDefineSupportCodeMethods\n ): any {\n return (...args: any[]) => {\n checkInstall(method)\n // @ts-expect-error difficult to type this correctly\n return target[method](...args)\n }\n },\n })\n }\n\n defineParameterType(options: IParameterTypeDefinition<any>): void {\n const parameterType = buildParameterType(options)\n this.parameterTypeRegistry.defineParameterType(parameterType)\n }\n\n defineStep(\n keyword: GherkinStepKeyword,\n getCollection: () => IStepDefinitionConfig[]\n ): IDefineStep {\n return (\n pattern: DefineStepPattern,\n options: IDefineStepOptions | Function,\n code?: Function\n ) => {\n if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, pattern, options },\n fnName: 'defineStep',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n keyword,\n pattern,\n uri,\n })\n }\n }\n\n defineTestCaseHook(\n getCollection: () => ITestCaseHookDefinitionConfig[]\n ): <WorldType>(\n options:\n | string\n | IDefineTestCaseHookOptions\n | TestCaseHookFunction<WorldType>,\n code?: TestCaseHookFunction<WorldType>\n ) => void {\n return <WorldType>(\n options:\n | string\n | IDefineTestCaseHookOptions\n | TestCaseHookFunction<WorldType>,\n code?: TestCaseHookFunction<WorldType>\n ) => {\n if (typeof options === 'string') {\n options = { tags: options }\n } else if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestCaseHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n defineTestStepHook(\n getCollection: () => ITestStepHookDefinitionConfig[]\n ): <WorldType>(\n options:\n | string\n | IDefineTestStepHookOptions\n | TestStepHookFunction<WorldType>,\n code?: TestStepHookFunction<WorldType>\n ) => void {\n return <WorldType>(\n options:\n | string\n | IDefineTestStepHookOptions\n | TestStepHookFunction<WorldType>,\n code?: TestStepHookFunction<WorldType>\n ) => {\n if (typeof options === 'string') {\n options = { tags: options }\n } else if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestStepHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n defineTestRunHook(\n getCollection: () => ITestRunHookDefinitionConfig[]\n ): (options: IDefineTestRunHookOptions | Function, code?: Function) => void {\n return (options: IDefineTestRunHookOptions | Function, code?: Function) => {\n if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestRunHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n wrapCode({\n code,\n wrapperOptions,\n }: {\n code: Function\n wrapperOptions: any\n }): Function {\n if (doesHaveValue(this.definitionFunctionWrapper)) {\n const codeLength = code.length\n const wrappedCode = this.definitionFunctionWrapper(code, wrapperOptions)\n if (wrappedCode !== code) {\n return arity(codeLength, wrappedCode)\n }\n return wrappedCode\n }\n return code\n }\n\n buildTestCaseHookDefinitions(\n configs: ITestCaseHookDefinitionConfig[],\n canonicalIds?: string[]\n ): TestCaseHookDefinition[] {\n return configs.map(({ code, line, options, uri }, index) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestCaseHookDefinition({\n code: wrappedCode,\n id: canonicalIds ? canonicalIds[index] : this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildTestStepHookDefinitions(\n configs: ITestStepHookDefinitionConfig[]\n ): TestStepHookDefinition[] {\n return configs.map(({ code, line, options, uri }) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestStepHookDefinition({\n code: wrappedCode,\n id: this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildTestRunHookDefinitions(\n configs: ITestRunHookDefinitionConfig[]\n ): TestRunHookDefinition[] {\n return configs.map(({ code, line, options, uri }) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestRunHookDefinition({\n code: wrappedCode,\n id: this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildStepDefinitions(canonicalIds?: string[]): {\n stepDefinitions: StepDefinition[]\n undefinedParameterTypes: messages.UndefinedParameterType[]\n } {\n const stepDefinitions: StepDefinition[] = []\n const undefinedParameterTypes: messages.UndefinedParameterType[] = []\n this.stepDefinitionConfigs.forEach(\n ({ code, line, options, keyword, pattern, uri }, index) => {\n let expression\n if (typeof pattern === 'string') {\n try {\n expression = new CucumberExpression(\n pattern,\n this.parameterTypeRegistry\n )\n } catch (e) {\n if (doesHaveValue(e.undefinedParameterTypeName)) {\n undefinedParameterTypes.push({\n name: e.undefinedParameterTypeName,\n expression: pattern,\n })\n return\n }\n throw e\n }\n } else {\n expression = new RegularExpression(\n pattern,\n this.parameterTypeRegistry\n )\n }\n\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n stepDefinitions.push(\n new StepDefinition({\n code: wrappedCode,\n expression,\n id: canonicalIds ? canonicalIds[index] : this.newId(),\n line,\n options,\n keyword,\n pattern,\n unwrappedCode: code,\n uri,\n })\n )\n }\n )\n return { stepDefinitions, undefinedParameterTypes }\n }\n\n finalize(canonicalIds?: ICanonicalSupportCodeIds): ISupportCodeLibrary {\n const stepDefinitionsResult = this.buildStepDefinitions(\n canonicalIds?.stepDefinitionIds\n )\n return {\n originalCoordinates: this.originalCoordinates,\n afterTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(\n this.afterTestCaseHookDefinitionConfigs,\n canonicalIds?.afterTestCaseHookDefinitionIds\n ),\n afterTestRunHookDefinitions: this.buildTestRunHookDefinitions(\n this.afterTestRunHookDefinitionConfigs\n ),\n afterTestStepHookDefinitions: this.buildTestStepHookDefinitions(\n this.afterTestStepHookDefinitionConfigs\n ),\n beforeTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(\n this.beforeTestCaseHookDefinitionConfigs,\n canonicalIds?.beforeTestCaseHookDefinitionIds\n ),\n beforeTestRunHookDefinitions: this.buildTestRunHookDefinitions(\n this.beforeTestRunHookDefinitionConfigs\n ),\n beforeTestStepHookDefinitions: this.buildTestStepHookDefinitions(\n this.beforeTestStepHookDefinitionConfigs\n ),\n defaultTimeout: this.defaultTimeout,\n parameterTypeRegistry: this.parameterTypeRegistry,\n undefinedParameterTypes: stepDefinitionsResult.undefinedParameterTypes,\n stepDefinitions: stepDefinitionsResult.stepDefinitions,\n World: this.World,\n parallelCanAssign: this.parallelCanAssign,\n }\n }\n\n reset(\n cwd: string,\n newId: IdGenerator.NewId,\n originalCoordinates: ISupportCodeCoordinates = {\n requireModules: [],\n requirePaths: [],\n importPaths: [],\n }\n ): void {\n this.cwd = cwd\n this.newId = newId\n this.originalCoordinates = originalCoordinates\n this.afterTestCaseHookDefinitionConfigs = []\n this.afterTestRunHookDefinitionConfigs = []\n this.afterTestStepHookDefinitionConfigs = []\n this.beforeTestCaseHookDefinitionConfigs = []\n this.beforeTestRunHookDefinitionConfigs = []\n this.beforeTestStepHookDefinitionConfigs = []\n this.definitionFunctionWrapper = null\n this.defaultTimeout = 5000\n this.parameterTypeRegistry = new ParameterTypeRegistry()\n this.stepDefinitionConfigs = []\n this.parallelCanAssign = () => true\n this.World = World\n }\n}\n\nexport default new SupportCodeLibraryBuilder()\n"]}
|
package/lib/time.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as messages from '@cucumber/messages';
|
|
2
|
-
|
|
2
|
+
import { FakeClock, GlobalTimers, TimerId } from '@sinonjs/fake-timers';
|
|
3
|
+
interface IMethods extends GlobalTimers<TimerId> {
|
|
4
|
+
beginTiming: () => void;
|
|
5
|
+
endTiming: () => number;
|
|
6
|
+
performance: FakeClock<TimerId>['performance'];
|
|
7
|
+
}
|
|
8
|
+
declare const methods: Partial<IMethods>;
|
|
3
9
|
export declare function durationBetweenTimestamps(startedTimestamp: messages.Timestamp, finishedTimestamp: messages.Timestamp): messages.Duration;
|
|
4
10
|
export declare function wrapPromiseWithTimeout<T>(promise: Promise<T>, timeoutInMilliseconds: number, timeoutMessage?: string): Promise<T>;
|
|
5
11
|
export default methods;
|
package/lib/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6DAA8C;
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6DAA8C;AAG9C,IAAI,iBAAyB,CAAA;AAQ7B,MAAM,OAAO,GAAsB;IACjC,WAAW;QACT,iBAAiB,GAAG,YAAY,EAAE,CAAA;IACpC,CAAC;IACD,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;IACzC,YAAY,EAAE,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IACvC,IAAI;IACJ,SAAS;QACP,OAAO,YAAY,EAAE,GAAG,iBAAiB,CAAA;IAC3C,CAAC;IACD,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;IACrC,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;IACnC,WAAW,EAAX,wBAAW;CACZ,CAAA;AAED,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;IACvC,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;CACrD;AAED,SAAS,YAAY;IACnB,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAA;AAClC,CAAC;AAED,SAAgB,yBAAyB,CACvC,gBAAoC,EACpC,iBAAqC;IAErC,MAAM,cAAc,GAClB,QAAQ,CAAC,cAAc,CAAC,iCAAiC,CACvD,iBAAiB,CAClB;QACD,QAAQ,CAAC,cAAc,CAAC,iCAAiC,CAAC,gBAAgB,CAAC,CAAA;IAC7E,OAAO,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAA;AACvE,CAAC;AAVD,8DAUC;AAEM,KAAK,UAAU,sBAAsB,CAC1C,OAAmB,EACnB,qBAA6B,EAC7B,iBAAyB,EAAE;IAE3B,IAAI,SAAkB,CAAA;IACtB,IAAI,cAAc,KAAK,EAAE,EAAE;QACzB,cAAc,GAAG,kCAAkC,qBAAqB,eAAe,CAAA;KACxF;IACD,MAAM,cAAc,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxD,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE;YAClC,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC,CAAA;QACnC,CAAC,EAAE,qBAAqB,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAChE,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAChC,CAAA;AACH,CAAC;AAjBD,wDAiBC;AAED,kBAAe,OAAO,CAAA","sourcesContent":["import { performance } from 'perf_hooks'\nimport * as messages from '@cucumber/messages'\nimport { FakeClock, GlobalTimers, TimerId } from '@sinonjs/fake-timers'\n\nlet previousTimestamp: number\n\ninterface IMethods extends GlobalTimers<TimerId> {\n beginTiming: () => void\n endTiming: () => number\n performance: FakeClock<TimerId>['performance']\n}\n\nconst methods: Partial<IMethods> = {\n beginTiming() {\n previousTimestamp = getTimestamp()\n },\n clearInterval: clearInterval.bind(global),\n clearTimeout: clearTimeout.bind(global),\n Date,\n endTiming() {\n return getTimestamp() - previousTimestamp\n },\n setInterval: setInterval.bind(global),\n setTimeout: setTimeout.bind(global),\n performance,\n}\n\nif (typeof setImmediate !== 'undefined') {\n methods.setImmediate = setImmediate.bind(global)\n methods.clearImmediate = clearImmediate.bind(global)\n}\n\nfunction getTimestamp(): number {\n return methods.performance.now()\n}\n\nexport function durationBetweenTimestamps(\n startedTimestamp: messages.Timestamp,\n finishedTimestamp: messages.Timestamp\n): messages.Duration {\n const durationMillis =\n messages.TimeConversion.timestampToMillisecondsSinceEpoch(\n finishedTimestamp\n ) -\n messages.TimeConversion.timestampToMillisecondsSinceEpoch(startedTimestamp)\n return messages.TimeConversion.millisecondsToDuration(durationMillis)\n}\n\nexport async function wrapPromiseWithTimeout<T>(\n promise: Promise<T>,\n timeoutInMilliseconds: number,\n timeoutMessage: string = ''\n): Promise<T> {\n let timeoutId: TimerId\n if (timeoutMessage === '') {\n timeoutMessage = `Action did not complete within ${timeoutInMilliseconds} milliseconds`\n }\n const timeoutPromise = new Promise<T>((resolve, reject) => {\n timeoutId = methods.setTimeout(() => {\n reject(new Error(timeoutMessage))\n }, timeoutInMilliseconds)\n })\n return await Promise.race([promise, timeoutPromise]).finally(() =>\n methods.clearTimeout(timeoutId)\n )\n}\n\nexport default methods\n"]}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "8.
|
|
1
|
+
export declare const version = "8.5.2";
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '8.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '8.5.2'\n"]}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"gherkin",
|
|
9
9
|
"tests"
|
|
10
10
|
],
|
|
11
|
-
"version": "8.
|
|
11
|
+
"version": "8.5.2",
|
|
12
12
|
"homepage": "https://github.com/cucumber/cucumber-js",
|
|
13
13
|
"author": "Julien Biezemans <jb@jbpros.com>",
|
|
14
14
|
"contributors": [
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
"Łukasz Gandecki <lgandecki@css.edu>",
|
|
101
101
|
"M.P. Korstanje <mpkorstanje@users.noreply.github.com>",
|
|
102
102
|
"mannyluvstacos <mannyis@typingona.computer>",
|
|
103
|
+
"Manny Pamintuan <mannyis+still@typingona.computer>",
|
|
103
104
|
"Marat Dyatko <vectart@gmail.com>",
|
|
104
105
|
"Marc Burton <marc.burton@first-utility.com>",
|
|
105
106
|
"Marcel Hoyer <mhoyer@pixelplastic.de>",
|
|
@@ -195,14 +196,14 @@
|
|
|
195
196
|
},
|
|
196
197
|
"dependencies": {
|
|
197
198
|
"@cspotcode/source-map-support": "^0.8.0",
|
|
198
|
-
"@cucumber/ci-environment": "9.0
|
|
199
|
-
"@cucumber/cucumber-expressions": "
|
|
199
|
+
"@cucumber/ci-environment": "9.1.0",
|
|
200
|
+
"@cucumber/cucumber-expressions": "16.0.0",
|
|
200
201
|
"@cucumber/gherkin": "24.0.0",
|
|
201
202
|
"@cucumber/gherkin-streams": "5.0.1",
|
|
202
203
|
"@cucumber/gherkin-utils": "8.0.0",
|
|
203
204
|
"@cucumber/html-formatter": "19.2.0",
|
|
204
205
|
"@cucumber/message-streams": "4.0.1",
|
|
205
|
-
"@cucumber/messages": "19.
|
|
206
|
+
"@cucumber/messages": "19.1.2",
|
|
206
207
|
"@cucumber/tag-expressions": "4.1.0",
|
|
207
208
|
"assertion-error-formatter": "^3.0.0",
|
|
208
209
|
"capital-case": "^1.0.4",
|
|
@@ -215,13 +216,13 @@
|
|
|
215
216
|
"glob": "^7.1.6",
|
|
216
217
|
"has-ansi": "^4.0.1",
|
|
217
218
|
"indent-string": "^4.0.0",
|
|
219
|
+
"is-installed-globally": "^0.4.0",
|
|
218
220
|
"is-stream": "^2.0.0",
|
|
219
221
|
"knuth-shuffle-seeded": "^1.0.6",
|
|
220
222
|
"lodash.merge": "^4.6.2",
|
|
221
223
|
"lodash.mergewith": "^4.6.2",
|
|
222
224
|
"mz": "^2.7.0",
|
|
223
225
|
"progress": "^2.0.3",
|
|
224
|
-
"resolve": "^1.19.0",
|
|
225
226
|
"resolve-pkg": "^2.0.0",
|
|
226
227
|
"semver": "7.3.7",
|
|
227
228
|
"stack-chain": "^2.0.0",
|
|
@@ -234,43 +235,42 @@
|
|
|
234
235
|
"yup": "^0.32.11"
|
|
235
236
|
},
|
|
236
237
|
"devDependencies": {
|
|
237
|
-
"@cucumber/compatibility-kit": "
|
|
238
|
+
"@cucumber/compatibility-kit": "11.0.1",
|
|
238
239
|
"@cucumber/query": "12.0.0",
|
|
239
|
-
"@microsoft/api-documenter": "7.
|
|
240
|
-
"@microsoft/api-extractor": "7.
|
|
240
|
+
"@microsoft/api-documenter": "7.19.1",
|
|
241
|
+
"@microsoft/api-extractor": "7.28.7",
|
|
241
242
|
"@sinonjs/fake-timers": "9.1.2",
|
|
242
243
|
"@types/chai": "4.3.1",
|
|
243
244
|
"@types/dirty-chai": "2.0.2",
|
|
244
245
|
"@types/express": "4.17.13",
|
|
245
246
|
"@types/fs-extra": "9.0.13",
|
|
246
247
|
"@types/glob": "7.2.0",
|
|
247
|
-
"@types/has-ansi": "
|
|
248
|
+
"@types/has-ansi": "5.0.0",
|
|
248
249
|
"@types/lodash.merge": "4.6.7",
|
|
249
250
|
"@types/lodash.mergewith": "4.6.7",
|
|
250
251
|
"@types/mocha": "9.1.1",
|
|
251
|
-
"@types/mustache": "4.1
|
|
252
|
+
"@types/mustache": "4.2.1",
|
|
252
253
|
"@types/mz": "2.7.4",
|
|
253
|
-
"@types/node": "16.11.
|
|
254
|
+
"@types/node": "16.11.47",
|
|
254
255
|
"@types/progress": "2.0.5",
|
|
255
|
-
"@types/
|
|
256
|
-
"@types/semver": "7.3.9",
|
|
256
|
+
"@types/semver": "7.3.10",
|
|
257
257
|
"@types/sinon-chai": "3.2.8",
|
|
258
258
|
"@types/sinonjs__fake-timers": "8.1.2",
|
|
259
259
|
"@types/stream-buffers": "3.0.4",
|
|
260
260
|
"@types/tmp": "0.2.3",
|
|
261
|
-
"@types/verror": "1.10.
|
|
262
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
263
|
-
"@typescript-eslint/parser": "5.
|
|
261
|
+
"@types/verror": "1.10.6",
|
|
262
|
+
"@typescript-eslint/eslint-plugin": "5.32.0",
|
|
263
|
+
"@typescript-eslint/parser": "5.32.0",
|
|
264
264
|
"chai": "4.3.6",
|
|
265
265
|
"chai-exclude": "2.1.0",
|
|
266
266
|
"coffeescript": "2.7.0",
|
|
267
267
|
"dependency-lint": "7.1.0",
|
|
268
268
|
"dirty-chai": "2.0.1",
|
|
269
|
-
"eslint": "8.
|
|
269
|
+
"eslint": "8.21.0",
|
|
270
270
|
"eslint-config-prettier": "8.5.0",
|
|
271
271
|
"eslint-plugin-import": "2.26.0",
|
|
272
272
|
"eslint-plugin-node": "11.1.0",
|
|
273
|
-
"eslint-plugin-prettier": "4.
|
|
273
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
274
274
|
"eslint-plugin-standard": "4.1.0",
|
|
275
275
|
"express": "4.18.1",
|
|
276
276
|
"fs-extra": "10.1.0",
|
|
@@ -278,16 +278,19 @@
|
|
|
278
278
|
"mocha": "10.0.0",
|
|
279
279
|
"mustache": "4.2.0",
|
|
280
280
|
"nyc": "15.1.0",
|
|
281
|
-
"prettier": "2.
|
|
281
|
+
"prettier": "2.7.1",
|
|
282
282
|
"reindent-template-literals": "1.1.0",
|
|
283
283
|
"shx": "0.3.4",
|
|
284
284
|
"sinon": "14.0.0",
|
|
285
285
|
"sinon-chai": "3.7.0",
|
|
286
286
|
"stream-buffers": "3.0.2",
|
|
287
287
|
"stream-to-string": "1.2.0",
|
|
288
|
-
"ts-node": "10.
|
|
289
|
-
"tsd": "0.
|
|
290
|
-
"typescript": "4.7.
|
|
288
|
+
"ts-node": "10.9.1",
|
|
289
|
+
"tsd": "0.22.0",
|
|
290
|
+
"typescript": "4.7.4"
|
|
291
|
+
},
|
|
292
|
+
"overrides": {
|
|
293
|
+
"ansi-regex": "^5.0.1"
|
|
291
294
|
},
|
|
292
295
|
"scripts": {
|
|
293
296
|
"build-local": "genversion --es6 src/version.ts && tsc --build tsconfig.node.json && shx cp src/importer.js lib/ && shx cp src/wrapper.mjs lib/ && shx cp src/api/wrapper.mjs lib/api/",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http_stream.js","sourceRoot":"","sources":["../../src/formatter/http_stream.ts"],"names":[],"mappings":";;;;;AAAA,mCAAsD;AACtD,8CAAqB;AACrB,4CAAmB;AACnB,gDAAuB;AACvB,kDAAyB;AACzB,oDAAgD;AAIhD;;;;;;;;;GASG;AACH,MAAqB,UAAW,SAAQ,kBAAS;IAI/C,YACmB,GAAW,EACX,MAAkB,EAClB,OAAiC;QAElD,KAAK,CAAC;YACJ,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAA;QANe,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAY;QAClB,YAAO,GAAP,OAAO,CAA0B;IAKpD,CAAC;IAED,MAAM,CACJ,KAAU,EACV,QAAwB,EACxB,QAAsC;QAEtC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC/B,aAAG,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EA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 'tmp'\nimport fs from 'fs'\nimport http from 'http'\nimport https from 'https'\nimport { doesHaveValue } from '../value_checker'\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT'\n\n/**\n * This Writable writes data to a HTTP/HTTPS URL.\n *\n * It has special handling for https://reports.cucumber.io/\n * which uses an API where the first request is a `GET`,\n * and if the response is 202 with a Location header, issues\n * a PUT request to that URL.\n *\n * 3xx redirects are not currently followed.\n */\nexport default class HttpStream extends Transform {\n private tempFilePath: string\n private tempFile: Writable\n\n constructor(\n private readonly url: string,\n private readonly method: HttpMethod,\n private readonly headers: http.OutgoingHttpHeaders\n ) {\n super({\n readableObjectMode: true,\n })\n }\n\n _write(\n chunk: any,\n encoding: BufferEncoding,\n callback: (err?: Error | null) => void\n ): void {\n if (this.tempFile === undefined) {\n tmp.file((err, name, fd) => {\n if (doesHaveValue(err)) return callback(err)\n this.tempFilePath = name\n this.tempFile = fs.createWriteStream(name, { fd })\n this.tempFile.write(chunk, encoding, callback)\n })\n } else {\n this.tempFile.write(chunk, encoding, callback)\n }\n }\n\n _final(callback: (error?: Error | null) => void): void {\n this.tempFile.end(() => {\n this.sendHttpRequest(\n this.url,\n this.method,\n this.headers,\n (err1, res1) => {\n if (doesHaveValue(err1)) return callback(err1)\n this.pushResponseBody(res1, () => {\n this.emitErrorUnlessHttp2xx(res1, this.url, this.method)\n if (\n res1.statusCode === 202 &&\n res1.headers.location !== undefined\n ) {\n this.sendHttpRequest(\n res1.headers.location,\n 'PUT',\n {},\n (err2, res2) => {\n if (doesHaveValue(err2)) return callback(err2)\n this.emitErrorUnlessHttp2xx(res2, this.url, this.method)\n callback()\n }\n )\n } else {\n callback()\n }\n })\n }\n )\n })\n }\n\n private pushResponseBody(res: http.IncomingMessage, done: () => void): void {\n let body = Buffer.alloc(0)\n res.on('data', (chunk) => {\n body = Buffer.concat([body, chunk])\n })\n res.on('end', () => {\n this.push(body.toString('utf-8'))\n done()\n })\n }\n\n private emitErrorUnlessHttp2xx(\n res: http.IncomingMessage,\n url: string,\n method: string\n ): void {\n if (res.statusCode >= 300)\n this.emit(\n 'error',\n new Error(\n `Unexpected http status ${res.statusCode} from ${method} ${url}`\n )\n )\n }\n\n private sendHttpRequest(\n url: string,\n method: HttpMethod,\n headers: http.OutgoingHttpHeaders,\n callback: (err?: Error | null, res?: http.IncomingMessage) => void\n ): void {\n const httpx = doesHaveValue(url.match(/^https:/)) ? https : http\n const additionalHttpHeaders: http.OutgoingHttpHeaders = {}\n\n const upload = method === 'PUT' || method === 'POST'\n if (upload) {\n additionalHttpHeaders['Content-Length'] = fs.statSync(\n this.tempFilePath\n ).size\n }\n\n const allHeaders = { ...headers, ...additionalHttpHeaders }\n const req = httpx.request(url, {\n method,\n headers: allHeaders,\n })\n req.on('error', (err) => this.emit('error', err))\n req.on('response', (res) => {\n res.on('error', (err) => this.emit('error', err))\n callback(null, res)\n })\n\n if (upload) {\n pipeline(fs.createReadStream(this.tempFilePath), req, (err) => {\n if (doesHaveValue(err)) {\n this.emit('error', err)\n }\n })\n } else {\n req.end()\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_CUCUMBER_PUBLISH_URL = "https://messages.cucumber.io/api/reports";
|
package/lib/formatter/publish.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/formatter/publish.ts"],"names":[],"mappings":";;;AAAa,QAAA,4BAA4B,GACvC,0CAA0C,CAAA","sourcesContent":["export const DEFAULT_CUCUMBER_PUBLISH_URL =\n 'https://messages.cucumber.io/api/reports'\n"]}
|