@cucumber/cucumber 8.0.0 → 8.1.0
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 -2
- package/bin/{cucumber-js → cucumber.js} +0 -0
- package/lib/cli/helpers.js +1 -0
- package/lib/cli/helpers.js.map +1 -1
- package/lib/configuration/argv_parser.js +1 -2
- package/lib/configuration/argv_parser.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +4 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +1 -0
- package/lib/formatter/helpers/test_case_attempt_parser.js +1 -0
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.d.ts +1 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +9 -1
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -1
- package/lib/index.d.ts +8 -8
- package/lib/models/definition.d.ts +1 -0
- package/lib/models/definition.js.map +1 -1
- package/lib/models/test_case_hook_definition.d.ts +1 -0
- package/lib/models/test_case_hook_definition.js +1 -0
- package/lib/models/test_case_hook_definition.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +1 -0
- package/lib/support_code_library_builder/types.js.map +1 -1
- package/lib/support_code_library_builder/world.d.ts +7 -7
- package/lib/support_code_library_builder/world.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 +12 -11
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
[](https://vshymanskyy.github.io/StandWithUkraine)
|
|
2
|
-
|
|
3
1
|
<h1 align="center">
|
|
4
2
|
<img src="./docs/images/logo.svg" alt="">
|
|
5
3
|
<br>
|
|
@@ -9,6 +7,7 @@
|
|
|
9
7
|
<b>Automated tests in plain language, for Node.js</b>
|
|
10
8
|
</p>
|
|
11
9
|
|
|
10
|
+
[](https://vshymanskyy.github.io/StandWithUkraine)
|
|
12
11
|
[](https://www.npmjs.com/package/@cucumber/cucumber)
|
|
13
12
|
[](https://github.com/cucumber/cucumber-js/actions)
|
|
14
13
|
[](https://coveralls.io/github/cucumber/cucumber-js?branch=master)
|
|
File without changes
|
package/lib/cli/helpers.js
CHANGED
|
@@ -170,6 +170,7 @@ function emitTestCaseHooks(supportCodeLibrary, eventBroadcaster) {
|
|
|
170
170
|
const envelope = {
|
|
171
171
|
hook: {
|
|
172
172
|
id: testCaseHookDefinition.id,
|
|
173
|
+
name: testCaseHookDefinition.name,
|
|
173
174
|
tagExpression: testCaseHookDefinition.tagExpression,
|
|
174
175
|
sourceReference: {
|
|
175
176
|
uri: testCaseHookDefinition.uri,
|
package/lib/cli/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gFAA0C;AAI1C,oDAAgD;AAChD,oDAAiD;AAEjD,4CAAmB;AACnB,6DAA8C;AAE9C,8EAA0D;AAK1D,kFAAuE;AACvE,wCAAoC;AAWpC;;;;;;;;;;GAUG;AACI,KAAK,UAAU,yBAAyB,CAAC,EAC9C,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,EACL,YAAY,GACsB;IAClC,OAAO,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,QAA2B,EAAE,EAAE;YAC9D,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;YAC3C,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAClC,MAA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seeded'\nimport { EventEmitter } from 'events'\nimport PickleFilter from '../pickle_filter'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { doesHaveValue } from '../value_checker'\nimport { OptionSplitter } from '../configuration'\nimport { Readable } from 'stream'\nimport os from 'os'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport detectCiEnvironment from '@cucumber/ci-environment'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport { PickleOrder } from '../models/pickle_order'\nimport { builtinParameterTypes } from '../support_code_library_builder'\nimport { version } from '../version'\n\ninterface IParseGherkinMessageStreamRequest {\n cwd?: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n gherkinMessageStream: Readable\n order: string\n pickleFilter: PickleFilter\n}\n\n/**\n * Process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids\n *\n * @deprecated use `loadSources` instead\n *\n * @param eventBroadcaster\n * @param eventDataCollector\n * @param gherkinMessageStream\n * @param order\n * @param pickleFilter\n */\nexport async function parseGherkinMessageStream({\n eventBroadcaster,\n eventDataCollector,\n gherkinMessageStream,\n order,\n pickleFilter,\n}: IParseGherkinMessageStreamRequest): Promise<string[]> {\n return await new Promise<string[]>((resolve, reject) => {\n const result: string[] = []\n gherkinMessageStream.on('data', (envelope: messages.Envelope) => {\n eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.pickle)) {\n const pickle = envelope.pickle\n const pickleId = pickle.id\n const gherkinDocument = eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n if (pickleFilter.matches({ gherkinDocument, pickle })) {\n result.push(pickleId)\n }\n }\n })\n gherkinMessageStream.on('end', () => {\n orderPickles(result, order, console)\n resolve(result)\n })\n gherkinMessageStream.on('error', reject)\n })\n}\n\n// Orders the pickleIds in place - morphs input\nexport function orderPickles<T = string>(\n pickleIds: T[],\n order: PickleOrder,\n logger: Console\n): void {\n const [type, seed] = OptionSplitter.split(order)\n switch (type) {\n case 'defined':\n break\n case 'random':\n if (seed === '') {\n const newSeed = Math.floor(Math.random() * 1000 * 1000).toString()\n logger.warn(`Random order using seed: ${newSeed}`)\n shuffle(pickleIds, newSeed)\n } else {\n shuffle(pickleIds, seed)\n }\n break\n default:\n throw new Error(\n 'Unrecgonized order type. Should be `defined` or `random`'\n )\n }\n}\n\nexport async function emitMetaMessage(\n eventBroadcaster: EventEmitter,\n env: NodeJS.ProcessEnv\n): Promise<void> {\n const meta: messages.Meta = {\n protocolVersion: messages.version,\n implementation: {\n version,\n name: 'cucumber-js',\n },\n cpu: {\n name: os.arch(),\n },\n os: {\n name: os.platform(),\n version: os.release(),\n },\n runtime: {\n name: 'node.js',\n version: process.versions.node,\n },\n ci: detectCiEnvironment(env),\n }\n eventBroadcaster.emit('envelope', {\n meta,\n })\n}\n\nfunction emitParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter,\n newId: IdGenerator.NewId\n): void {\n for (const parameterType of supportCodeLibrary.parameterTypeRegistry\n .parameterTypes) {\n if (builtinParameterTypes.includes(parameterType.name)) {\n continue\n }\n const envelope: messages.Envelope = {\n parameterType: {\n id: newId(),\n name: parameterType.name,\n preferForRegularExpressionMatch: parameterType.preferForRegexpMatch,\n regularExpressions: parameterType.regexpStrings,\n useForSnippets: parameterType.useForSnippets,\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitUndefinedParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n for (const undefinedParameterType of supportCodeLibrary.undefinedParameterTypes) {\n const envelope: messages.Envelope = {\n undefinedParameterType,\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitStepDefinitions(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n supportCodeLibrary.stepDefinitions.forEach((stepDefinition) => {\n const envelope: messages.Envelope = {\n stepDefinition: {\n id: stepDefinition.id,\n pattern: {\n source: stepDefinition.pattern.toString(),\n type:\n typeof stepDefinition.pattern === 'string'\n ? messages.StepDefinitionPatternType.CUCUMBER_EXPRESSION\n : messages.StepDefinitionPatternType.REGULAR_EXPRESSION,\n },\n sourceReference: {\n uri: stepDefinition.uri,\n location: {\n line: stepDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestCaseHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestCaseHookDefinitions,\n supportCodeLibrary.afterTestCaseHookDefinitions\n )\n .forEach((testCaseHookDefinition: TestCaseHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testCaseHookDefinition.id,\n tagExpression: testCaseHookDefinition.tagExpression,\n sourceReference: {\n uri: testCaseHookDefinition.uri,\n location: {\n line: testCaseHookDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestRunHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestRunHookDefinitions,\n supportCodeLibrary.afterTestRunHookDefinitions\n )\n .forEach((testRunHookDefinition: TestRunHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testRunHookDefinition.id,\n sourceReference: {\n uri: testRunHookDefinition.uri,\n location: {\n line: testRunHookDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nexport function emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n}: {\n eventBroadcaster: EventEmitter\n supportCodeLibrary: ISupportCodeLibrary\n newId: IdGenerator.NewId\n}): void {\n emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId)\n emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster)\n emitStepDefinitions(supportCodeLibrary, eventBroadcaster)\n emitTestCaseHooks(supportCodeLibrary, eventBroadcaster)\n emitTestRunHooks(supportCodeLibrary, eventBroadcaster)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gFAA0C;AAI1C,oDAAgD;AAChD,oDAAiD;AAEjD,4CAAmB;AACnB,6DAA8C;AAE9C,8EAA0D;AAK1D,kFAAuE;AACvE,wCAAoC;AAWpC;;;;;;;;;;GAUG;AACI,KAAK,UAAU,yBAAyB,CAAC,EAC9C,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,EACL,YAAY,GACsB;IAClC,OAAO,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,QAA2B,EAAE,EAAE;YAC9D,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;YAC3C,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAA;gBAC9B,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAA;gBAC1B,MAAM,eAAe,GAAG,kBAAkB,CAAC,kBAAkB,CAC3D,MAAM,CAAC,GAAG,CACX,CAAA;gBACD,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,EAAE;oBACrD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;iBACtB;aACF;QACH,CAAC,CAAC,CAAA;QACF,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YAClC,YAAY,CAAC,MAAM,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kBAAkB,CAAC,4BAA4B,EAC/C,kBAAkB,CAAC,2BAA2B,CAC/C;SACA,OAAO,CAAC,CAAC,qBAA4C,EAAE,EAAE;QACxD,MAAM,QAAQ,GAAsB;YAClC,IAAI,EAAE;gBACJ,EAAE,EAAE,qBAAqB,CAAC,EAAE;gBAC5B,eAAe,EAAE;oBACf,GAAG,EAAE,qBAAqB,CAAC,GAAG;oBAC9B,QAAQ,EAAE;wBACR,IAAI,EAAE,qBAAqB,CAAC,IAAI;qBACjC;iBACF;aACF;SACF,CAAA;QACD,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;AACN,CAAC;AAED,SAAgB,uBAAuB,CAAC,EACtC,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,GAKN;IACC,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAA;IAC/D,2BAA2B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACjE,mBAAmB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACzD,iBAAiB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACvD,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;AACxD,CAAC;AAdD,0DAcC","sourcesContent":["import shuffle from 'knuth-shuffle-seeded'\nimport { EventEmitter } from 'events'\nimport PickleFilter from '../pickle_filter'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { doesHaveValue } from '../value_checker'\nimport { OptionSplitter } from '../configuration'\nimport { Readable } from 'stream'\nimport os from 'os'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport detectCiEnvironment from '@cucumber/ci-environment'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport { PickleOrder } from '../models/pickle_order'\nimport { builtinParameterTypes } from '../support_code_library_builder'\nimport { version } from '../version'\n\ninterface IParseGherkinMessageStreamRequest {\n cwd?: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n gherkinMessageStream: Readable\n order: string\n pickleFilter: PickleFilter\n}\n\n/**\n * Process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids\n *\n * @deprecated use `loadSources` instead\n *\n * @param eventBroadcaster\n * @param eventDataCollector\n * @param gherkinMessageStream\n * @param order\n * @param pickleFilter\n */\nexport async function parseGherkinMessageStream({\n eventBroadcaster,\n eventDataCollector,\n gherkinMessageStream,\n order,\n pickleFilter,\n}: IParseGherkinMessageStreamRequest): Promise<string[]> {\n return await new Promise<string[]>((resolve, reject) => {\n const result: string[] = []\n gherkinMessageStream.on('data', (envelope: messages.Envelope) => {\n eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.pickle)) {\n const pickle = envelope.pickle\n const pickleId = pickle.id\n const gherkinDocument = eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n if (pickleFilter.matches({ gherkinDocument, pickle })) {\n result.push(pickleId)\n }\n }\n })\n gherkinMessageStream.on('end', () => {\n orderPickles(result, order, console)\n resolve(result)\n })\n gherkinMessageStream.on('error', reject)\n })\n}\n\n// Orders the pickleIds in place - morphs input\nexport function orderPickles<T = string>(\n pickleIds: T[],\n order: PickleOrder,\n logger: Console\n): void {\n const [type, seed] = OptionSplitter.split(order)\n switch (type) {\n case 'defined':\n break\n case 'random':\n if (seed === '') {\n const newSeed = Math.floor(Math.random() * 1000 * 1000).toString()\n logger.warn(`Random order using seed: ${newSeed}`)\n shuffle(pickleIds, newSeed)\n } else {\n shuffle(pickleIds, seed)\n }\n break\n default:\n throw new Error(\n 'Unrecgonized order type. Should be `defined` or `random`'\n )\n }\n}\n\nexport async function emitMetaMessage(\n eventBroadcaster: EventEmitter,\n env: NodeJS.ProcessEnv\n): Promise<void> {\n const meta: messages.Meta = {\n protocolVersion: messages.version,\n implementation: {\n version,\n name: 'cucumber-js',\n },\n cpu: {\n name: os.arch(),\n },\n os: {\n name: os.platform(),\n version: os.release(),\n },\n runtime: {\n name: 'node.js',\n version: process.versions.node,\n },\n ci: detectCiEnvironment(env),\n }\n eventBroadcaster.emit('envelope', {\n meta,\n })\n}\n\nfunction emitParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter,\n newId: IdGenerator.NewId\n): void {\n for (const parameterType of supportCodeLibrary.parameterTypeRegistry\n .parameterTypes) {\n if (builtinParameterTypes.includes(parameterType.name)) {\n continue\n }\n const envelope: messages.Envelope = {\n parameterType: {\n id: newId(),\n name: parameterType.name,\n preferForRegularExpressionMatch: parameterType.preferForRegexpMatch,\n regularExpressions: parameterType.regexpStrings,\n useForSnippets: parameterType.useForSnippets,\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitUndefinedParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n for (const undefinedParameterType of supportCodeLibrary.undefinedParameterTypes) {\n const envelope: messages.Envelope = {\n undefinedParameterType,\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitStepDefinitions(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n supportCodeLibrary.stepDefinitions.forEach((stepDefinition) => {\n const envelope: messages.Envelope = {\n stepDefinition: {\n id: stepDefinition.id,\n pattern: {\n source: stepDefinition.pattern.toString(),\n type:\n typeof stepDefinition.pattern === 'string'\n ? messages.StepDefinitionPatternType.CUCUMBER_EXPRESSION\n : messages.StepDefinitionPatternType.REGULAR_EXPRESSION,\n },\n sourceReference: {\n uri: stepDefinition.uri,\n location: {\n line: stepDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestCaseHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestCaseHookDefinitions,\n supportCodeLibrary.afterTestCaseHookDefinitions\n )\n .forEach((testCaseHookDefinition: TestCaseHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testCaseHookDefinition.id,\n name: testCaseHookDefinition.name,\n tagExpression: testCaseHookDefinition.tagExpression,\n sourceReference: {\n uri: testCaseHookDefinition.uri,\n location: {\n line: testCaseHookDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestRunHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestRunHookDefinitions,\n supportCodeLibrary.afterTestRunHookDefinitions\n )\n .forEach((testRunHookDefinition: TestRunHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testRunHookDefinition.id,\n sourceReference: {\n uri: testRunHookDefinition.uri,\n location: {\n line: testRunHookDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nexport function emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n}: {\n eventBroadcaster: EventEmitter\n supportCodeLibrary: ISupportCodeLibrary\n newId: IdGenerator.NewId\n}): void {\n emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId)\n emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster)\n emitStepDefinitions(supportCodeLibrary, eventBroadcaster)\n emitTestCaseHooks(supportCodeLibrary, eventBroadcaster)\n emitTestRunHooks(supportCodeLibrary, eventBroadcaster)\n}\n"]}
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const commander_1 = require("commander");
|
|
7
7
|
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
8
|
const gherkin_1 = require("@cucumber/gherkin");
|
|
10
9
|
const formatters_1 = __importDefault(require("../formatter/helpers/formatters"));
|
|
11
10
|
const version_1 = require("../version");
|
|
@@ -49,7 +48,7 @@ const ArgvParser = {
|
|
|
49
48
|
return value;
|
|
50
49
|
},
|
|
51
50
|
parse(argv) {
|
|
52
|
-
const program = new commander_1.Command(
|
|
51
|
+
const program = new commander_1.Command('cucumber-js');
|
|
53
52
|
program
|
|
54
53
|
.storeOptionsAsProperties(false)
|
|
55
54
|
.usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,gEAAgC;AAChC
|
|
1
|
+
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,gEAAgC;AAChC,+CAA4C;AAC5C,iFAAwD;AACxD,wCAAoC;AAkBpC,MAAM,UAAU,GAAG;IACjB,OAAO,CAAI,GAAM,EAAE,OAAY,EAAE;QAC/B,IAAI,GAAG,EAAE;YACP,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;SACtB;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,OAAO,UAAU,GAAW,EAAE,OAAe,EAAE;YAC7C,IAAI,GAAW,CAAA;YACf,IAAI;gBACF,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACtB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,GAAU,KAAK,CAAA;gBACtB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,yBAAyB,CAAC,CAAC,OAAO,KAAK,GAAG,EAAE,CAAC,CAAA;aACvE;YACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAA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rB;aACA,MAAM,CAAC,UAAU,EAAE,iCAAiC,CAAC;aACrD,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;aAChE,MAAM,CACL,yBAAyB,EACzB,uFAAuF,EACvF,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CACL,2BAA2B,EAC3B,8EAA8E,EAC9E,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAC3C,CAAA;QAEH,OAAO,CAAC,WAAW,CACjB,UAAU,EACV,6FAA6F,CAC9F,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACnB,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,OAAO,EACP,GAAG,YAAY,EAChB,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAA;QACnC,MAAM,aAAa,GAA4B,YAAY,CAAA;QAC3D,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;SACnC;QAED,OAAO;YACL,OAAO,EAAE;gBACP,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACR;YACD,aAAa;SACd,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { Command } from 'commander'\nimport merge from 'lodash.merge'\nimport { dialects } from '@cucumber/gherkin'\nimport Formatters from '../formatter/helpers/formatters'\nimport { version } from '../version'\nimport { IConfiguration } from './types'\n\nexport interface IParsedArgvOptions {\n config?: string\n i18nKeywords?: string\n i18nLanguages?: boolean\n profile: string[]\n}\n\nexport interface IParsedArgv {\n options: IParsedArgvOptions\n configuration: Partial<IConfiguration>\n}\n\ntype IRawArgvOptions = Partial<Omit<IConfiguration, 'paths'>> &\n IParsedArgvOptions\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[] = []): T[] {\n if (val) {\n return [...memo, val]\n }\n return undefined\n },\n\n mergeJson(option: string): (str: string, memo?: object) => object {\n return function (str: string, memo: object = {}) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return merge(memo, val)\n }\n },\n\n mergeTags(value: string, memo?: string): string {\n return memo ? `${memo} and (${value})` : `(${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!Object.keys(dialects).includes(value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command('cucumber-js')\n\n program\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option('-c, --config <PATH>', 'specify configuration file')\n .option('-d, --dry-run', 'invoke formatters without executing steps')\n .option(\n '--exit, --force-exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\n )\n .option('--fail-fast', 'abort the run on first failure')\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\n Formatters.buildFormattersDocumentationString(),\n ArgvParser.collect\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options')\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage\n )\n .option('--i18n-languages', 'list languages')\n .option(\n '-i, --import <GLOB|DIR|FILE>',\n 'import files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect\n )\n\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined` or `random`'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel')\n )\n .option('--publish', 'Publish a report to https://reports.cucumber.io')\n .option(\n '--publish-quiet',\n \"Don't print information banner about publishing reports\"\n )\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry')\n )\n .option(\n '--retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags\n )\n .option('--strict', 'fail if there are pending steps')\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters')\n )\n\n program.addHelpText(\n 'afterAll',\n 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\n )\n\n program.parse(argv)\n const {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n ...regularStuff\n }: IRawArgvOptions = program.opts()\n const configuration: Partial<IConfiguration> = regularStuff\n if (program.args.length > 0) {\n configuration.paths = program.args\n }\n\n return {\n options: {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n },\n configuration,\n }\n },\n}\n\nexport default ArgvParser\n"]}
|
|
@@ -55,10 +55,13 @@ function getStepMessage(testStep) {
|
|
|
55
55
|
return '';
|
|
56
56
|
}
|
|
57
57
|
function formatStep({ colorFns, testStep, printAttachments, }) {
|
|
58
|
-
const { result: { status }, actionLocation, attachments, } = testStep;
|
|
58
|
+
const { name, result: { status }, actionLocation, attachments, } = testStep;
|
|
59
59
|
const colorFn = colorFns.forStatus(status);
|
|
60
60
|
const identifier = testStep.keyword + (0, value_checker_1.valueOrDefault)(testStep.text, '');
|
|
61
61
|
let text = colorFn(`${CHARACTERS.get(status)} ${identifier}`);
|
|
62
|
+
if ((0, value_checker_1.doesHaveValue)(name)) {
|
|
63
|
+
text += colorFn(` (${name})`);
|
|
64
|
+
}
|
|
62
65
|
if ((0, value_checker_1.doesHaveValue)(actionLocation)) {
|
|
63
66
|
text += ` # ${colorFns.location((0, location_helpers_1.formatLocation)(actionLocation))}`;
|
|
64
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_case_attempt_formatter.js","sourceRoot":"","sources":["../../../src/formatter/helpers/test_case_attempt_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAwC;AACxC,6DAA8C;AAC9C,sDAA6B;AAC7B,yDAAmD;AACnD,yEAGmC;AACnC,uEAA8D;AAE9D,uDAAmE;AAKnE,MAAM,UAAU,GAA+C,IAAI,GAAG,CAAC;IACrE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,iBAAO,CAAC,KAAK,CAAC;IACxD,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,iBAAO,CAAC,KAAK,CAAC;IACrD,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,iBAAO,CAAC,IAAI,CAAC;IACpD,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG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AM,QAAQ,CAAC,QAAQ,CAC7B,IAAA,iCAAc,EAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAC/C,IAAI,CAAA;IACL,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QACpC,IAAI,IAAI,UAAU,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC,CAAA;IAC9D,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,IAAI,IAAI,CAAA;AACpB,CAAC;AArBD,sDAqBC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,aAAsB;IAC7D,IAAI,OAAO,GAAG,CAAC,IAAI,aAAa,EAAE;QAChC,MAAM,SAAS,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC1C,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;QACnD,OAAO,aAAa,SAAS,GAAG,UAAU,GAAG,CAAA;KAC9C;IACD,OAAO,EAAE,CAAA;AACX,CAAC","sourcesContent":["import indentString from 'indent-string'\nimport * as messages from '@cucumber/messages'\nimport figures from 'figures'\nimport { formatLocation } from './location_helpers'\nimport {\n IParsedTestStep,\n parseTestCaseAttempt,\n} from './test_case_attempt_parser'\nimport { formatStepArgument } from './step_argument_formatter'\nimport { IColorFns } from '../get_color_fns'\nimport { doesHaveValue, valueOrDefault } from '../../value_checker'\nimport { ITestCaseAttempt } from './event_data_collector'\nimport StepDefinitionSnippetBuilder from '../step_definition_snippet_builder'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\n\nconst CHARACTERS: Map<messages.TestStepResultStatus, string> = new Map([\n [messages.TestStepResultStatus.AMBIGUOUS, figures.cross],\n [messages.TestStepResultStatus.FAILED, figures.cross],\n [messages.TestStepResultStatus.PASSED, figures.tick],\n [messages.TestStepResultStatus.PENDING, '?'],\n [messages.TestStepResultStatus.SKIPPED, '-'],\n [messages.TestStepResultStatus.UNDEFINED, '?'],\n])\n\nfunction getStepMessage(testStep: IParsedTestStep): string {\n switch (testStep.result.status) {\n case messages.TestStepResultStatus.AMBIGUOUS:\n case messages.TestStepResultStatus.FAILED:\n return testStep.result.message\n case messages.TestStepResultStatus.UNDEFINED:\n return `${\n 'Undefined. Implement with the following snippet:' + '\\n\\n'\n }${indentString(testStep.snippet, 2)}\\n`\n case messages.TestStepResultStatus.PENDING:\n return 'Pending'\n }\n return ''\n}\n\ninterface IFormatStepRequest {\n colorFns: IColorFns\n testStep: IParsedTestStep\n printAttachments?: boolean\n}\n\nfunction formatStep({\n colorFns,\n testStep,\n printAttachments,\n}: IFormatStepRequest): string {\n const {\n result: { status },\n actionLocation,\n attachments,\n } = testStep\n const colorFn = colorFns.forStatus(status)\n const identifier = testStep.keyword + valueOrDefault(testStep.text, '')\n let text = colorFn(`${CHARACTERS.get(status)} ${identifier}`)\n if (doesHaveValue(actionLocation)) {\n text += ` # ${colorFns.location(formatLocation(actionLocation))}`\n }\n text += '\\n'\n if (doesHaveValue(testStep.argument)) {\n const argumentsText = formatStepArgument(testStep.argument)\n text += indentString(`${colorFn(argumentsText)}\\n`, 4)\n }\n if (valueOrDefault(printAttachments, true)) {\n attachments.forEach(({ body, mediaType }) => {\n const message = mediaType === 'text/plain' ? `: ${body}` : ''\n text += indentString(`Attachment (${mediaType})${message}\\n`, 4)\n })\n }\n const message = getStepMessage(testStep)\n if (message !== '') {\n text += `${indentString(colorFn(message), 4)}\\n`\n }\n return text\n}\n\nexport interface IFormatTestCaseAttemptRequest {\n colorFns: IColorFns\n testCaseAttempt: ITestCaseAttempt\n snippetBuilder: StepDefinitionSnippetBuilder\n supportCodeLibrary: ISupportCodeLibrary\n printAttachments?: boolean\n}\n\nexport function formatTestCaseAttempt({\n colorFns,\n snippetBuilder,\n supportCodeLibrary,\n testCaseAttempt,\n printAttachments,\n}: IFormatTestCaseAttemptRequest): string {\n const parsed = parseTestCaseAttempt({\n snippetBuilder,\n testCaseAttempt,\n supportCodeLibrary,\n })\n let text = `Scenario: ${parsed.testCase.name}`\n text += getAttemptText(parsed.testCase.attempt, testCaseAttempt.willBeRetried)\n text += ` # ${colorFns.location(\n formatLocation(parsed.testCase.sourceLocation)\n )}\\n`\n parsed.testSteps.forEach((testStep) => {\n text += formatStep({ colorFns, testStep, printAttachments })\n })\n return `${text}\\n`\n}\n\nfunction getAttemptText(attempt: number, willBeRetried: boolean): string {\n if (attempt > 0 || willBeRetried) {\n const numberStr = (attempt + 1).toString()\n const retriedStr = willBeRetried ? ', retried' : ''\n return ` (attempt ${numberStr}${retriedStr})`\n }\n return ''\n}\n"]}
|
|
1
|
+
{"version":3,"file":"test_case_attempt_formatter.js","sourceRoot":"","sources":["../../../src/formatter/helpers/test_case_attempt_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAwC;AACxC,6DAA8C;AAC9C,sDAA6B;AAC7B,yDAAmD;AACnD,yEAGmC;AACnC,uEAA8D;AAE9D,uDAAmE;AAKnE,MAAM,UAAU,GAA+C,IAAI,GAAG,CAAC;IACrE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,iBAAO,CAAC,KAAK,CAAC;IACxD,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,iBAAO,CAAC,KAAK,CAAC;IACrD,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,iBAAO,CAAC,IAAI,CAAC;IACpD,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,CAAC;CAC/C,CAAC,CAAA;AAEF,SAAS,cAAc,CAAC,QAAyB;IAC/C,QAAQ,QAAQ,CAAC,MAAM,CAAC,MAAM,E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c,EAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAC/C,IAAI,CAAA;IACL,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QACpC,IAAI,IAAI,UAAU,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC,CAAA;IAC9D,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,IAAI,IAAI,CAAA;AACpB,CAAC;AArBD,sDAqBC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,aAAsB;IAC7D,IAAI,OAAO,GAAG,CAAC,IAAI,aAAa,EAAE;QAChC,MAAM,SAAS,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC1C,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;QACnD,OAAO,aAAa,SAAS,GAAG,UAAU,GAAG,CAAA;KAC9C;IACD,OAAO,EAAE,CAAA;AACX,CAAC","sourcesContent":["import indentString from 'indent-string'\nimport * as messages from '@cucumber/messages'\nimport figures from 'figures'\nimport { formatLocation } from './location_helpers'\nimport {\n IParsedTestStep,\n parseTestCaseAttempt,\n} from './test_case_attempt_parser'\nimport { formatStepArgument } from './step_argument_formatter'\nimport { IColorFns } from '../get_color_fns'\nimport { doesHaveValue, valueOrDefault } from '../../value_checker'\nimport { ITestCaseAttempt } from './event_data_collector'\nimport StepDefinitionSnippetBuilder from '../step_definition_snippet_builder'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\n\nconst CHARACTERS: Map<messages.TestStepResultStatus, string> = new Map([\n [messages.TestStepResultStatus.AMBIGUOUS, figures.cross],\n [messages.TestStepResultStatus.FAILED, figures.cross],\n [messages.TestStepResultStatus.PASSED, figures.tick],\n [messages.TestStepResultStatus.PENDING, '?'],\n [messages.TestStepResultStatus.SKIPPED, '-'],\n [messages.TestStepResultStatus.UNDEFINED, '?'],\n])\n\nfunction getStepMessage(testStep: IParsedTestStep): string {\n switch (testStep.result.status) {\n case messages.TestStepResultStatus.AMBIGUOUS:\n case messages.TestStepResultStatus.FAILED:\n return testStep.result.message\n case messages.TestStepResultStatus.UNDEFINED:\n return `${\n 'Undefined. Implement with the following snippet:' + '\\n\\n'\n }${indentString(testStep.snippet, 2)}\\n`\n case messages.TestStepResultStatus.PENDING:\n return 'Pending'\n }\n return ''\n}\n\ninterface IFormatStepRequest {\n colorFns: IColorFns\n testStep: IParsedTestStep\n printAttachments?: boolean\n}\n\nfunction formatStep({\n colorFns,\n testStep,\n printAttachments,\n}: IFormatStepRequest): string {\n const {\n name,\n result: { status },\n actionLocation,\n attachments,\n } = testStep\n const colorFn = colorFns.forStatus(status)\n const identifier = testStep.keyword + valueOrDefault(testStep.text, '')\n let text = colorFn(`${CHARACTERS.get(status)} ${identifier}`)\n if (doesHaveValue(name)) {\n text += colorFn(` (${name})`)\n }\n if (doesHaveValue(actionLocation)) {\n text += ` # ${colorFns.location(formatLocation(actionLocation))}`\n }\n text += '\\n'\n if (doesHaveValue(testStep.argument)) {\n const argumentsText = formatStepArgument(testStep.argument)\n text += indentString(`${colorFn(argumentsText)}\\n`, 4)\n }\n if (valueOrDefault(printAttachments, true)) {\n attachments.forEach(({ body, mediaType }) => {\n const message = mediaType === 'text/plain' ? `: ${body}` : ''\n text += indentString(`Attachment (${mediaType})${message}\\n`, 4)\n })\n }\n const message = getStepMessage(testStep)\n if (message !== '') {\n text += `${indentString(colorFn(message), 4)}\\n`\n }\n return text\n}\n\nexport interface IFormatTestCaseAttemptRequest {\n colorFns: IColorFns\n testCaseAttempt: ITestCaseAttempt\n snippetBuilder: StepDefinitionSnippetBuilder\n supportCodeLibrary: ISupportCodeLibrary\n printAttachments?: boolean\n}\n\nexport function formatTestCaseAttempt({\n colorFns,\n snippetBuilder,\n supportCodeLibrary,\n testCaseAttempt,\n printAttachments,\n}: IFormatTestCaseAttemptRequest): string {\n const parsed = parseTestCaseAttempt({\n snippetBuilder,\n testCaseAttempt,\n supportCodeLibrary,\n })\n let text = `Scenario: ${parsed.testCase.name}`\n text += getAttemptText(parsed.testCase.attempt, testCaseAttempt.willBeRetried)\n text += ` # ${colorFns.location(\n formatLocation(parsed.testCase.sourceLocation)\n )}\\n`\n parsed.testSteps.forEach((testStep) => {\n text += formatStep({ colorFns, testStep, printAttachments })\n })\n return `${text}\\n`\n}\n\nfunction getAttemptText(attempt: number, willBeRetried: boolean): string {\n if (attempt > 0 || willBeRetried) {\n const numberStr = (attempt + 1).toString()\n const retriedStr = willBeRetried ? ', retried' : ''\n return ` (attempt ${numberStr}${retriedStr})`\n }\n return ''\n}\n"]}
|
|
@@ -52,6 +52,7 @@ function parseStep({ isBeforeHook, gherkinStepMap, keyword, keywordType, pickleS
|
|
|
52
52
|
uri: hookDefinition.uri,
|
|
53
53
|
line: hookDefinition.line,
|
|
54
54
|
};
|
|
55
|
+
out.name = hookDefinition.name;
|
|
55
56
|
}
|
|
56
57
|
if ((0, value_checker_1.doesHaveValue)(testStep.stepDefinitionIds) &&
|
|
57
58
|
testStep.stepDefinitionIds.length === 1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_case_attempt_parser.js","sourceRoot":"","sources":["../../../src/formatter/helpers/test_case_attempt_parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAgE;AAChE,uEAGkC;AAClC,mDAAkE;AAClE,6DAA8C;AAI9C,uDAAmE;AAGnE,iDAAmD;
|
|
1
|
+
{"version":3,"file":"test_case_attempt_parser.js","sourceRoot":"","sources":["../../../src/formatter/helpers/test_case_attempt_parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAgE;AAChE,uEAGkC;AAClC,mDAAkE;AAClE,6DAA8C;AAI9C,uDAAmE;AAGnE,iDAAmD;AAwCnD,SAAS,SAAS,CAAC,EACjB,YAAY,EACZ,cAAc,EACd,OAA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Ae,CAAC,QAAQ,CAAC,EAAE,CAAC,EAC5C,EAAE,CACH;SACF,CAAC,CAAA;QACF,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAChC,mBAAmB,GAAG,WAAW,CAAA;IACnC,CAAC,CAAC,CAAA;IACF,OAAO;QACL,QAAQ,EAAE,cAAc;QACxB,SAAS,EAAE,eAAe;KAC3B,CAAA;AACH,CAAC;AAjED,oDAiEC","sourcesContent":["import { getStepKeywordType, KeywordType } from './keyword_type'\nimport {\n getGherkinScenarioLocationMap,\n getGherkinStepMap,\n} from './gherkin_document_parser'\nimport { getPickleStepMap, getStepKeyword } from './pickle_parser'\nimport * as messages from '@cucumber/messages'\nimport { ITestCaseAttempt } from './event_data_collector'\nimport StepDefinitionSnippetBuilder from '../step_definition_snippet_builder'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\nimport { doesHaveValue, valueOrDefault } from '../../value_checker'\nimport TestCaseHookDefinition from '../../models/test_case_hook_definition'\nimport { ILineAndUri } from '../../types'\nimport { TestStepResult } from '@cucumber/messages'\n\nexport interface IParsedTestStep {\n actionLocation?: ILineAndUri\n argument?: messages.PickleStepArgument\n attachments: messages.Attachment[]\n keyword: string\n name?: string\n result: messages.TestStepResult\n snippet?: string\n sourceLocation?: ILineAndUri\n text?: string\n}\n\nexport interface IParsedTestCase {\n attempt: number\n name: string\n sourceLocation?: ILineAndUri\n worstTestStepResult: messages.TestStepResult\n}\n\nexport interface IParsedTestCaseAttempt {\n testCase: IParsedTestCase\n testSteps: IParsedTestStep[]\n}\n\ninterface IParseStepRequest {\n isBeforeHook: boolean\n gherkinStepMap: Record<string, messages.Step>\n keyword: string\n keywordType: KeywordType\n pickleStep: messages.PickleStep\n pickleUri: string\n snippetBuilder: StepDefinitionSnippetBuilder\n supportCodeLibrary: ISupportCodeLibrary\n testStep: messages.TestStep\n testStepResult: messages.TestStepResult\n testStepAttachments: messages.Attachment[]\n}\n\nfunction parseStep({\n isBeforeHook,\n gherkinStepMap,\n keyword,\n keywordType,\n pickleStep,\n pickleUri,\n snippetBuilder,\n supportCodeLibrary,\n testStep,\n testStepResult,\n testStepAttachments,\n}: IParseStepRequest): IParsedTestStep {\n const out: IParsedTestStep = {\n attachments: testStepAttachments,\n keyword: doesHaveValue(testStep.pickleStepId)\n ? keyword\n : isBeforeHook\n ? 'Before'\n : 'After',\n result: testStepResult,\n }\n if (doesHaveValue(testStep.hookId)) {\n let hookDefinition: TestCaseHookDefinition\n if (isBeforeHook) {\n hookDefinition = supportCodeLibrary.beforeTestCaseHookDefinitions.find(\n (x) => x.id === testStep.hookId\n )\n } else {\n hookDefinition = supportCodeLibrary.afterTestCaseHookDefinitions.find(\n (x) => x.id === testStep.hookId\n )\n }\n out.actionLocation = {\n uri: hookDefinition.uri,\n line: hookDefinition.line,\n }\n out.name = hookDefinition.name\n }\n if (\n doesHaveValue(testStep.stepDefinitionIds) &&\n testStep.stepDefinitionIds.length === 1\n ) {\n const stepDefinition = supportCodeLibrary.stepDefinitions.find(\n (x) => x.id === testStep.stepDefinitionIds[0]\n )\n out.actionLocation = {\n uri: stepDefinition.uri,\n line: stepDefinition.line,\n }\n }\n if (doesHaveValue(testStep.pickleStepId)) {\n out.sourceLocation = {\n uri: pickleUri,\n line: gherkinStepMap[pickleStep.astNodeIds[0]].location.line,\n }\n out.text = pickleStep.text\n if (doesHaveValue(pickleStep.argument)) {\n out.argument = pickleStep.argument\n }\n }\n if (testStepResult.status === messages.TestStepResultStatus.UNDEFINED) {\n out.snippet = snippetBuilder.build({ keywordType, pickleStep })\n }\n return out\n}\n\nexport interface IParseTestCaseAttemptRequest {\n testCaseAttempt: ITestCaseAttempt\n snippetBuilder: StepDefinitionSnippetBuilder\n supportCodeLibrary: ISupportCodeLibrary\n}\n\n// Converts a testCaseAttempt into a json object with all data needed for\n// displaying it in a pretty format\nexport function parseTestCaseAttempt({\n testCaseAttempt,\n snippetBuilder,\n supportCodeLibrary,\n}: IParseTestCaseAttemptRequest): IParsedTestCaseAttempt {\n const { testCase, pickle, gherkinDocument } = testCaseAttempt\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const gherkinScenarioLocationMap =\n getGherkinScenarioLocationMap(gherkinDocument)\n const pickleStepMap = getPickleStepMap(pickle)\n const relativePickleUri = pickle.uri\n const parsedTestCase: IParsedTestCase = {\n attempt: testCaseAttempt.attempt,\n name: pickle.name,\n sourceLocation: {\n uri: relativePickleUri,\n line: gherkinScenarioLocationMap[\n pickle.astNodeIds[pickle.astNodeIds.length - 1]\n ].line,\n },\n worstTestStepResult: testCaseAttempt.worstTestStepResult,\n }\n const parsedTestSteps: IParsedTestStep[] = []\n let isBeforeHook = true\n let previousKeywordType = KeywordType.Precondition\n\n testCase.testSteps.forEach((testStep) => {\n const testStepResult =\n testCaseAttempt.stepResults[testStep.id] || new TestStepResult()\n\n isBeforeHook = isBeforeHook && doesHaveValue(testStep.hookId)\n\n let keyword, keywordType, pickleStep\n if (doesHaveValue(testStep.pickleStepId)) {\n pickleStep = pickleStepMap[testStep.pickleStepId]\n keyword = getStepKeyword({ pickleStep, gherkinStepMap })\n keywordType = getStepKeywordType({\n keyword,\n language: gherkinDocument.feature.language,\n previousKeywordType,\n })\n }\n const parsedStep = parseStep({\n isBeforeHook,\n gherkinStepMap,\n keyword,\n keywordType,\n pickleStep,\n pickleUri: relativePickleUri,\n snippetBuilder,\n supportCodeLibrary,\n testStep,\n testStepResult,\n testStepAttachments: valueOrDefault(\n testCaseAttempt.stepAttachments[testStep.id],\n []\n ),\n })\n parsedTestSteps.push(parsedStep)\n previousKeywordType = keywordType\n })\n return {\n testCase: parsedTestCase,\n testSteps: parsedTestSteps,\n }\n}\n"]}
|
|
@@ -3,4 +3,5 @@ export default class JavaScriptSnippetSyntax implements ISnippetSnytax {
|
|
|
3
3
|
private readonly snippetInterface;
|
|
4
4
|
constructor(snippetInterface: SnippetInterface);
|
|
5
5
|
build({ comment, generatedExpressions, functionName, stepParameterNames, }: ISnippetSyntaxBuildOptions): string;
|
|
6
|
+
private escapeSpecialCharacters;
|
|
6
7
|
}
|
|
@@ -30,12 +30,20 @@ class JavaScriptSnippetSyntax {
|
|
|
30
30
|
if (this.snippetInterface === snippet_syntax_1.SnippetInterface.Callback) {
|
|
31
31
|
allParameterNames.push(CALLBACK_NAME);
|
|
32
32
|
}
|
|
33
|
-
return `${prefix + functionName}('${
|
|
33
|
+
return `${prefix + functionName}('${this.escapeSpecialCharacters(generatedExpression)}', ${functionKeyword}(${allParameterNames.join(', ')}) {\n`;
|
|
34
34
|
});
|
|
35
35
|
return (`${definitionChoices.join('')} // ${comment}\n` +
|
|
36
36
|
` ${implementation}\n` +
|
|
37
37
|
'});');
|
|
38
38
|
}
|
|
39
|
+
escapeSpecialCharacters(generatedExpression) {
|
|
40
|
+
let source = generatedExpression.source;
|
|
41
|
+
// double up any backslashes because we're in a javascript string
|
|
42
|
+
source = source.replace(/\\/g, '\\\\');
|
|
43
|
+
// escape any single quotes because that's our quote delimiter
|
|
44
|
+
source = source.replace(/'/g, "\\'");
|
|
45
|
+
return source;
|
|
46
|
+
}
|
|
39
47
|
}
|
|
40
48
|
exports.default = JavaScriptSnippetSyntax;
|
|
41
49
|
//# sourceMappingURL=javascript_snippet_syntax.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript_snippet_syntax.js","sourceRoot":"","sources":["../../../src/formatter/step_definition_snippet_builder/javascript_snippet_syntax.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"javascript_snippet_syntax.js","sourceRoot":"","sources":["../../../src/formatter/step_definition_snippet_builder/javascript_snippet_syntax.ts"],"names":[],"mappings":";;AACA,qDAIyB;AAEzB,MAAM,aAAa,GAAG,UAAU,CAAA;AAEhC,MAAqB,uBAAuB;IAG1C,YAAY,gBAAkC;QAC5C,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;IAC1C,CAAC;IAED,KAAK,CAAC,EACJ,OAAO,EACP,oBAAoB,EACpB,YAAY,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Ac,IAAI;YACvB,KAAK,CACN,CAAA;IACH,CAAC;IAEO,uBAAuB,CAAC,mBAAwC;QACtE,IAAI,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAA;QACvC,iEAAiE;QACjE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QACtC,8DAA8D;QAC9D,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QACpC,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AA1DD,0CA0DC","sourcesContent":["import { GeneratedExpression } from '@cucumber/cucumber-expressions'\nimport {\n ISnippetSnytax,\n ISnippetSyntaxBuildOptions,\n SnippetInterface,\n} from './snippet_syntax'\n\nconst CALLBACK_NAME = 'callback'\n\nexport default class JavaScriptSnippetSyntax implements ISnippetSnytax {\n private readonly snippetInterface: SnippetInterface\n\n constructor(snippetInterface: SnippetInterface) {\n this.snippetInterface = snippetInterface\n }\n\n build({\n comment,\n generatedExpressions,\n functionName,\n stepParameterNames,\n }: ISnippetSyntaxBuildOptions): string {\n let functionKeyword = 'function '\n if (this.snippetInterface === SnippetInterface.AsyncAwait) {\n functionKeyword = 'async ' + functionKeyword\n } else if (this.snippetInterface === SnippetInterface.Generator) {\n functionKeyword += '*'\n }\n\n let implementation: string\n if (this.snippetInterface === SnippetInterface.Callback) {\n implementation = `${CALLBACK_NAME}(null, 'pending');`\n } else if (this.snippetInterface === SnippetInterface.Promise) {\n implementation = \"return Promise.resolve('pending');\"\n } else {\n implementation = \"return 'pending';\"\n }\n\n const definitionChoices = generatedExpressions.map(\n (generatedExpression, index) => {\n const prefix = index === 0 ? '' : '// '\n const allParameterNames =\n generatedExpression.parameterNames.concat(stepParameterNames)\n if (this.snippetInterface === SnippetInterface.Callback) {\n allParameterNames.push(CALLBACK_NAME)\n }\n return `${prefix + functionName}('${this.escapeSpecialCharacters(\n generatedExpression\n )}', ${functionKeyword}(${allParameterNames.join(', ')}) {\\n`\n }\n )\n\n return (\n `${definitionChoices.join('')} // ${comment}\\n` +\n ` ${implementation}\\n` +\n '});'\n )\n }\n\n private escapeSpecialCharacters(generatedExpression: GeneratedExpression) {\n let source = generatedExpression.source\n // double up any backslashes because we're in a javascript string\n source = source.replace(/\\\\/g, '\\\\\\\\')\n // escape any single quotes because that's our quote delimiter\n source = source.replace(/'/g, \"\\\\'\")\n return source\n }\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -19,21 +19,21 @@ export { default as SummaryFormatter } from './formatter/summary_formatter';
|
|
|
19
19
|
export { default as UsageFormatter } from './formatter/usage_formatter';
|
|
20
20
|
export { default as UsageJsonFormatter } from './formatter/usage_json_formatter';
|
|
21
21
|
export { formatterHelpers };
|
|
22
|
-
export declare const After: (<WorldType = import("./support_code_library_builder/world").IWorld
|
|
22
|
+
export declare const After: (<WorldType = import("./support_code_library_builder/world").IWorld<any>>(code: import("./support_code_library_builder/types").TestCaseHookFunction<WorldType>) => void) & (<WorldType_1 = import("./support_code_library_builder/world").IWorld<any>>(tags: string, code: import("./support_code_library_builder/types").TestCaseHookFunction<WorldType_1>) => void) & (<WorldType_2 = import("./support_code_library_builder/world").IWorld<any>>(options: import("./support_code_library_builder/types").IDefineTestCaseHookOptions, code: import("./support_code_library_builder/types").TestCaseHookFunction<WorldType_2>) => void);
|
|
23
23
|
export declare const AfterAll: ((code: Function) => void) & ((options: import("./support_code_library_builder/types").IDefineTestRunHookOptions, code: Function) => void);
|
|
24
|
-
export declare const AfterStep: (<WorldType = import("./support_code_library_builder/world").IWorld
|
|
25
|
-
export declare const Before: (<WorldType = import("./support_code_library_builder/world").IWorld
|
|
24
|
+
export declare const AfterStep: (<WorldType = import("./support_code_library_builder/world").IWorld<any>>(code: import("./support_code_library_builder/types").TestStepHookFunction<WorldType>) => void) & (<WorldType_1 = import("./support_code_library_builder/world").IWorld<any>>(tags: string, code: import("./support_code_library_builder/types").TestStepHookFunction<WorldType_1>) => void) & (<WorldType_2 = import("./support_code_library_builder/world").IWorld<any>>(options: import("./support_code_library_builder/types").IDefineTestStepHookOptions, code: import("./support_code_library_builder/types").TestStepHookFunction<WorldType_2>) => void);
|
|
25
|
+
export declare const Before: (<WorldType = import("./support_code_library_builder/world").IWorld<any>>(code: import("./support_code_library_builder/types").TestCaseHookFunction<WorldType>) => void) & (<WorldType_1 = import("./support_code_library_builder/world").IWorld<any>>(tags: string, code: import("./support_code_library_builder/types").TestCaseHookFunction<WorldType_1>) => void) & (<WorldType_2 = import("./support_code_library_builder/world").IWorld<any>>(options: import("./support_code_library_builder/types").IDefineTestCaseHookOptions, code: import("./support_code_library_builder/types").TestCaseHookFunction<WorldType_2>) => void);
|
|
26
26
|
export declare const BeforeAll: ((code: Function) => void) & ((options: import("./support_code_library_builder/types").IDefineTestRunHookOptions, code: Function) => void);
|
|
27
|
-
export declare const BeforeStep: (<WorldType = import("./support_code_library_builder/world").IWorld
|
|
27
|
+
export declare const BeforeStep: (<WorldType = import("./support_code_library_builder/world").IWorld<any>>(code: import("./support_code_library_builder/types").TestStepHookFunction<WorldType>) => void) & (<WorldType_1 = import("./support_code_library_builder/world").IWorld<any>>(tags: string, code: import("./support_code_library_builder/types").TestStepHookFunction<WorldType_1>) => void) & (<WorldType_2 = import("./support_code_library_builder/world").IWorld<any>>(options: import("./support_code_library_builder/types").IDefineTestStepHookOptions, code: import("./support_code_library_builder/types").TestStepHookFunction<WorldType_2>) => void);
|
|
28
28
|
export declare const defineParameterType: (options: import("./support_code_library_builder/types").IParameterTypeDefinition<any>) => void;
|
|
29
|
-
export declare const defineStep: (<WorldType = import("./support_code_library_builder/world").IWorld
|
|
30
|
-
export declare const Given: (<WorldType = import("./support_code_library_builder/world").IWorld
|
|
29
|
+
export declare const defineStep: (<WorldType = import("./support_code_library_builder/world").IWorld<any>>(pattern: import("./support_code_library_builder/types").DefineStepPattern, code: import("./support_code_library_builder/types").TestStepFunction<WorldType>) => void) & (<WorldType_1 = import("./support_code_library_builder/world").IWorld<any>>(pattern: import("./support_code_library_builder/types").DefineStepPattern, options: import("./support_code_library_builder/types").IDefineStepOptions, code: import("./support_code_library_builder/types").TestStepFunction<WorldType_1>) => void);
|
|
30
|
+
export declare const Given: (<WorldType = import("./support_code_library_builder/world").IWorld<any>>(pattern: import("./support_code_library_builder/types").DefineStepPattern, code: import("./support_code_library_builder/types").TestStepFunction<WorldType>) => void) & (<WorldType_1 = import("./support_code_library_builder/world").IWorld<any>>(pattern: import("./support_code_library_builder/types").DefineStepPattern, options: import("./support_code_library_builder/types").IDefineStepOptions, code: import("./support_code_library_builder/types").TestStepFunction<WorldType_1>) => void);
|
|
31
31
|
export declare const setDefaultTimeout: (milliseconds: number) => void;
|
|
32
32
|
export declare const setDefinitionFunctionWrapper: (fn: Function) => void;
|
|
33
33
|
export declare const setWorldConstructor: (fn: any) => void;
|
|
34
34
|
export declare const setParallelCanAssign: (fn: import("./support_code_library_builder/types").ParallelAssignmentValidator) => void;
|
|
35
|
-
export declare const Then: (<WorldType = import("./support_code_library_builder/world").IWorld
|
|
36
|
-
export declare const When: (<WorldType = import("./support_code_library_builder/world").IWorld
|
|
35
|
+
export declare const Then: (<WorldType = import("./support_code_library_builder/world").IWorld<any>>(pattern: import("./support_code_library_builder/types").DefineStepPattern, code: import("./support_code_library_builder/types").TestStepFunction<WorldType>) => void) & (<WorldType_1 = import("./support_code_library_builder/world").IWorld<any>>(pattern: import("./support_code_library_builder/types").DefineStepPattern, options: import("./support_code_library_builder/types").IDefineStepOptions, code: import("./support_code_library_builder/types").TestStepFunction<WorldType_1>) => void);
|
|
36
|
+
export declare const When: (<WorldType = import("./support_code_library_builder/world").IWorld<any>>(pattern: import("./support_code_library_builder/types").DefineStepPattern, code: import("./support_code_library_builder/types").TestStepFunction<WorldType>) => void) & (<WorldType_1 = import("./support_code_library_builder/world").IWorld<any>>(pattern: import("./support_code_library_builder/types").DefineStepPattern, options: import("./support_code_library_builder/types").IDefineStepOptions, code: import("./support_code_library_builder/types").TestStepFunction<WorldType_1>) => void);
|
|
37
37
|
export { default as World, IWorld, IWorldOptions, } from './support_code_library_builder/world';
|
|
38
38
|
export { parallelCanAssignHelpers };
|
|
39
39
|
export { ITestCaseHookParameter, ITestStepHookParameter, } from './support_code_library_builder/types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/models/definition.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/models/definition.ts"],"names":[],"mappings":";;AAsDA,MAA8B,UAAU;IAQtC,YAAY,EACV,IAAI,EACJ,EAAE,EACF,IAAI,EACJ,OAAO,EACP,aAAa,EACb,GAAG,GACuC;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,6BAA6B,CAC3B,mBAAoC,EACpC,cAA+B;QAE/B,OAAO,CACL,gBAAgB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY;YACvD,iBAAiB,mBAAmB,CAAC,QAAQ,EAAE,0CAA0C;YACzF,OAAO,cAAc,CAAC,QAAQ,EAAE,4BAA4B,CAC7D,CAAA;IACH,CAAC;IAED,+BAA+B,CAAC,UAAiB;QAC/C,OAAO,IAAI,CAAC,6BAA6B,CACvC,UAAU,CAAC,MAAM,EACjB,UAAU,CAAC,MAAM,GAAG,CAAC,CACtB,CAAA;IACH,CAAC;CACF;AAzCD,6BAyCC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { ITestCaseHookParameter } from '../support_code_library_builder/types'\nimport { Expression } from '@cucumber/cucumber-expressions'\n\nexport interface IGetInvocationDataRequest {\n hookParameter: ITestCaseHookParameter\n step: messages.PickleStep\n world: any\n}\n\nexport interface IGetInvocationDataResponse {\n getInvalidCodeLengthMessage: () => string\n parameters: any[]\n validCodeLengths: number[]\n}\n\nexport interface IDefinitionOptions {\n timeout?: number\n wrapperOptions?: any\n}\n\nexport interface IHookDefinitionOptions extends IDefinitionOptions {\n name?: string\n tags?: string\n}\n\nexport interface IDefinitionParameters<T extends IDefinitionOptions> {\n code: Function\n id: string\n line: number\n options: T\n unwrappedCode?: Function\n uri: string\n}\n\nexport interface IStepDefinitionParameters\n extends IDefinitionParameters<IDefinitionOptions> {\n pattern: string | RegExp\n expression: Expression\n}\n\nexport interface IDefinition {\n readonly code: Function\n readonly id: string\n readonly line: number\n readonly options: IDefinitionOptions\n readonly unwrappedCode: Function\n readonly uri: string\n\n getInvocationParameters: (\n options: IGetInvocationDataRequest\n ) => Promise<IGetInvocationDataResponse>\n}\n\nexport default abstract class Definition {\n public readonly code: Function\n public readonly id: string\n public readonly line: number\n public readonly options: IDefinitionOptions\n public readonly unwrappedCode: Function\n public readonly uri: string\n\n constructor({\n code,\n id,\n line,\n options,\n unwrappedCode,\n uri,\n }: IDefinitionParameters<IDefinitionOptions>) {\n this.code = code\n this.id = id\n this.line = line\n this.options = options\n this.unwrappedCode = unwrappedCode\n this.uri = uri\n }\n\n buildInvalidCodeLengthMessage(\n syncOrPromiseLength: number | string,\n callbackLength: number | string\n ): string {\n return (\n `function has ${this.code.length.toString()} arguments` +\n `, should have ${syncOrPromiseLength.toString()} (if synchronous or returning a promise)` +\n ` or ${callbackLength.toString()} (if accepting a callback)`\n )\n }\n\n baseGetInvalidCodeLengthMessage(parameters: any[]): string {\n return this.buildInvalidCodeLengthMessage(\n parameters.length,\n parameters.length + 1\n )\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Definition, { IDefinition, IDefinitionParameters, IGetInvocationDataRequest, IGetInvocationDataResponse, IHookDefinitionOptions } from './definition';
|
|
2
2
|
import * as messages from '@cucumber/messages';
|
|
3
3
|
export default class TestCaseHookDefinition extends Definition implements IDefinition {
|
|
4
|
+
readonly name: string;
|
|
4
5
|
readonly tagExpression: string;
|
|
5
6
|
private readonly pickleTagFilter;
|
|
6
7
|
constructor(data: IDefinitionParameters<IHookDefinitionOptions>);
|
|
@@ -8,6 +8,7 @@ const definition_1 = __importDefault(require("./definition"));
|
|
|
8
8
|
class TestCaseHookDefinition extends definition_1.default {
|
|
9
9
|
constructor(data) {
|
|
10
10
|
super(data);
|
|
11
|
+
this.name = data.options.name;
|
|
11
12
|
this.tagExpression = data.options.tags;
|
|
12
13
|
this.pickleTagFilter = new pickle_filter_1.PickleTagFilter(data.options.tags);
|
|
13
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_case_hook_definition.js","sourceRoot":"","sources":["../../src/models/test_case_hook_definition.ts"],"names":[],"mappings":";;;;;AAAA,oDAAkD;AAClD,8DAMqB;AAGrB,MAAqB,sBACnB,SAAQ,oBAAU;
|
|
1
|
+
{"version":3,"file":"test_case_hook_definition.js","sourceRoot":"","sources":["../../src/models/test_case_hook_definition.ts"],"names":[],"mappings":";;;;;AAAA,oDAAkD;AAClD,8DAMqB;AAGrB,MAAqB,sBACnB,SAAQ,oBAAU;IAOlB,YAAY,IAAmD;QAC7D,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAA;QAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAA;QACtC,IAAI,CAAC,eAAe,GAAG,IAAI,+BAAe,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/D,CAAC;IAED,iBAAiB,CAAC,MAAuB;QACvC,OAAO,IAAI,CAAC,eAAe,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAA;IAC9D,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,EAC5B,aAAa,GACa;QAC1B,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC;YAC3B,2BAA2B,EAAE,GAAG,EAAE,CAChC,IAAI,CAAC,6BAA6B,CAAC,QAAQ,EAAE,GAAG,CAAC;YACnD,UAAU,EAAE,CAAC,aAAa,CAAC;YAC3B,gBAAgB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SAC5B,CAAC,CAAA;IACJ,CAAC;CACF;AA7BD,yCA6BC","sourcesContent":["import { PickleTagFilter } from '../pickle_filter'\nimport Definition, {\n IDefinition,\n IDefinitionParameters,\n IGetInvocationDataRequest,\n IGetInvocationDataResponse,\n IHookDefinitionOptions,\n} from './definition'\nimport * as messages from '@cucumber/messages'\n\nexport default class TestCaseHookDefinition\n extends Definition\n implements IDefinition\n{\n public readonly name: string\n public readonly tagExpression: string\n private readonly pickleTagFilter: PickleTagFilter\n\n constructor(data: IDefinitionParameters<IHookDefinitionOptions>) {\n super(data)\n this.name = data.options.name\n this.tagExpression = data.options.tags\n this.pickleTagFilter = new PickleTagFilter(data.options.tags)\n }\n\n appliesToTestCase(pickle: messages.Pickle): boolean {\n return this.pickleTagFilter.matchesAllTagExpressions(pickle)\n }\n\n async getInvocationParameters({\n hookParameter,\n }: IGetInvocationDataRequest): Promise<IGetInvocationDataResponse> {\n return await Promise.resolve({\n getInvalidCodeLengthMessage: () =>\n this.buildInvalidCodeLengthMessage('0 or 1', '2'),\n parameters: [hookParameter],\n validCodeLengths: [0, 1, 2],\n })\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/support_code_library_builder/types.ts"],"names":[],"mappings":"","sourcesContent":["import * 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 { ParameterTypeRegistry } from '@cucumber/cucumber-expressions'\nimport { IWorld } from './world'\n\nexport type DefineStepPattern = string | RegExp\nexport type ParallelAssignmentValidator = (\n pickle: messages.Pickle,\n runningPickles: messages.Pickle[]\n) => boolean\nexport interface ITestCaseHookParameter {\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n result?: messages.TestStepResult\n testCaseStartedId: string\n}\n\nexport interface ITestStepHookParameter {\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n pickleStep: messages.PickleStep\n result: messages.TestStepResult\n testCaseStartedId: string\n testStepId: string\n}\n\nexport type TestCaseHookFunction<WorldType> = (\n this: WorldType,\n arg: ITestCaseHookParameter\n) => any | Promise<any>\n\nexport type TestStepHookFunction<WorldType> = (\n this: WorldType,\n arg: ITestStepHookParameter\n) => void\n\nexport type TestStepFunction<WorldType> = (\n this: WorldType,\n ...args: any[]\n) => any | Promise<any>\n\nexport interface IDefineStepOptions {\n timeout?: number\n wrapperOptions?: any\n}\n\nexport interface IDefineTestCaseHookOptions {\n tags?: string\n timeout?: number\n}\n\nexport interface IDefineTestStepHookOptions {\n tags?: string\n timeout?: number\n}\n\nexport interface IDefineTestRunHookOptions {\n timeout?: number\n}\n\nexport interface IParameterTypeDefinition<T> {\n name: string\n regexp: readonly RegExp[] | readonly string[] | RegExp | string\n transformer: (...match: string[]) => T\n useForSnippets?: boolean\n preferForRegexpMatch?: boolean\n}\n\nexport interface IDefineSupportCodeMethods {\n defineParameterType: (options: IParameterTypeDefinition<any>) => void\n defineStep: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n setDefaultTimeout: (milliseconds: number) => void\n setDefinitionFunctionWrapper: (fn: Function) => void\n setParallelCanAssign: (fn: ParallelAssignmentValidator) => void\n setWorldConstructor: (fn: any) => void\n After: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestCaseHookOptions,\n code: TestCaseHookFunction<WorldType>\n ) => void)\n AfterStep: (<WorldType = IWorld>(\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestStepHookOptions,\n code: TestStepHookFunction<WorldType>\n ) => void)\n AfterAll: ((code: Function) => void) &\n ((options: IDefineTestRunHookOptions, code: Function) => void)\n Before: (<WorldType = IWorld>(\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestCaseHookOptions,\n code: TestCaseHookFunction<WorldType>\n ) => void)\n BeforeStep: (<WorldType = IWorld>(\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestStepHookOptions,\n code: TestStepHookFunction<WorldType>\n ) => void)\n BeforeAll: ((code: Function) => void) &\n ((options: IDefineTestRunHookOptions, code: Function) => void)\n Given: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n Then: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n When: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n}\n\nexport interface ISupportCodeCoordinates {\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n}\n\nexport interface ISupportCodeLibrary {\n readonly originalCoordinates: ISupportCodeCoordinates\n readonly afterTestCaseHookDefinitions: TestCaseHookDefinition[]\n readonly afterTestStepHookDefinitions: TestStepHookDefinition[]\n readonly afterTestRunHookDefinitions: TestRunHookDefinition[]\n readonly beforeTestCaseHookDefinitions: TestCaseHookDefinition[]\n readonly beforeTestStepHookDefinitions: TestStepHookDefinition[]\n readonly beforeTestRunHookDefinitions: TestRunHookDefinition[]\n readonly defaultTimeout: number\n readonly stepDefinitions: StepDefinition[]\n readonly undefinedParameterTypes: messages.UndefinedParameterType[]\n readonly parameterTypeRegistry: ParameterTypeRegistry\n readonly World: any\n readonly parallelCanAssign: ParallelAssignmentValidator\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/support_code_library_builder/types.ts"],"names":[],"mappings":"","sourcesContent":["import * 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 { ParameterTypeRegistry } from '@cucumber/cucumber-expressions'\nimport { IWorld } from './world'\n\nexport type DefineStepPattern = string | RegExp\nexport type ParallelAssignmentValidator = (\n pickle: messages.Pickle,\n runningPickles: messages.Pickle[]\n) => boolean\nexport interface ITestCaseHookParameter {\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n result?: messages.TestStepResult\n testCaseStartedId: string\n}\n\nexport interface ITestStepHookParameter {\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n pickleStep: messages.PickleStep\n result: messages.TestStepResult\n testCaseStartedId: string\n testStepId: string\n}\n\nexport type TestCaseHookFunction<WorldType> = (\n this: WorldType,\n arg: ITestCaseHookParameter\n) => any | Promise<any>\n\nexport type TestStepHookFunction<WorldType> = (\n this: WorldType,\n arg: ITestStepHookParameter\n) => void\n\nexport type TestStepFunction<WorldType> = (\n this: WorldType,\n ...args: any[]\n) => any | Promise<any>\n\nexport interface IDefineStepOptions {\n timeout?: number\n wrapperOptions?: any\n}\n\nexport interface IDefineTestCaseHookOptions {\n name?: string\n tags?: string\n timeout?: number\n}\n\nexport interface IDefineTestStepHookOptions {\n tags?: string\n timeout?: number\n}\n\nexport interface IDefineTestRunHookOptions {\n timeout?: number\n}\n\nexport interface IParameterTypeDefinition<T> {\n name: string\n regexp: readonly RegExp[] | readonly string[] | RegExp | string\n transformer: (...match: string[]) => T\n useForSnippets?: boolean\n preferForRegexpMatch?: boolean\n}\n\nexport interface IDefineSupportCodeMethods {\n defineParameterType: (options: IParameterTypeDefinition<any>) => void\n defineStep: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n setDefaultTimeout: (milliseconds: number) => void\n setDefinitionFunctionWrapper: (fn: Function) => void\n setParallelCanAssign: (fn: ParallelAssignmentValidator) => void\n setWorldConstructor: (fn: any) => void\n After: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestCaseHookOptions,\n code: TestCaseHookFunction<WorldType>\n ) => void)\n AfterStep: (<WorldType = IWorld>(\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestStepHookOptions,\n code: TestStepHookFunction<WorldType>\n ) => void)\n AfterAll: ((code: Function) => void) &\n ((options: IDefineTestRunHookOptions, code: Function) => void)\n Before: (<WorldType = IWorld>(\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestCaseHookOptions,\n code: TestCaseHookFunction<WorldType>\n ) => void)\n BeforeStep: (<WorldType = IWorld>(\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestStepHookOptions,\n code: TestStepHookFunction<WorldType>\n ) => void)\n BeforeAll: ((code: Function) => void) &\n ((options: IDefineTestRunHookOptions, code: Function) => void)\n Given: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n Then: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n When: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n}\n\nexport interface ISupportCodeCoordinates {\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n}\n\nexport interface ISupportCodeLibrary {\n readonly originalCoordinates: ISupportCodeCoordinates\n readonly afterTestCaseHookDefinitions: TestCaseHookDefinition[]\n readonly afterTestStepHookDefinitions: TestStepHookDefinition[]\n readonly afterTestRunHookDefinitions: TestRunHookDefinition[]\n readonly beforeTestCaseHookDefinitions: TestCaseHookDefinition[]\n readonly beforeTestStepHookDefinitions: TestStepHookDefinition[]\n readonly beforeTestRunHookDefinitions: TestRunHookDefinition[]\n readonly defaultTimeout: number\n readonly stepDefinitions: StepDefinition[]\n readonly undefinedParameterTypes: messages.UndefinedParameterType[]\n readonly parameterTypeRegistry: ParameterTypeRegistry\n readonly World: any\n readonly parallelCanAssign: ParallelAssignmentValidator\n}\n"]}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ICreateAttachment, ICreateLog } from '../runtime/attachment_manager';
|
|
2
|
-
export interface IWorldOptions {
|
|
2
|
+
export interface IWorldOptions<ParametersType = any> {
|
|
3
3
|
attach: ICreateAttachment;
|
|
4
4
|
log: ICreateLog;
|
|
5
|
-
parameters:
|
|
5
|
+
parameters: ParametersType;
|
|
6
6
|
}
|
|
7
|
-
export interface IWorld {
|
|
7
|
+
export interface IWorld<ParametersType = any> {
|
|
8
8
|
readonly attach: ICreateAttachment;
|
|
9
9
|
readonly log: ICreateLog;
|
|
10
|
-
readonly parameters:
|
|
10
|
+
readonly parameters: ParametersType;
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
}
|
|
13
|
-
export default class World implements IWorld {
|
|
13
|
+
export default class World<ParametersType = any> implements IWorld<ParametersType> {
|
|
14
14
|
readonly attach: ICreateAttachment;
|
|
15
15
|
readonly log: ICreateLog;
|
|
16
|
-
readonly parameters:
|
|
17
|
-
constructor({ attach, log, parameters }: IWorldOptions);
|
|
16
|
+
readonly parameters: ParametersType;
|
|
17
|
+
constructor({ attach, log, parameters }: IWorldOptions<ParametersType>);
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world.js","sourceRoot":"","sources":["../../src/support_code_library_builder/world.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"world.js","sourceRoot":"","sources":["../../src/support_code_library_builder/world.ts"],"names":[],"mappings":";;AAgBA,MAAqB,KAAK;IAOxB,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAiC;QACpE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAZD,wBAYC","sourcesContent":["import { ICreateAttachment, ICreateLog } from '../runtime/attachment_manager'\n\nexport interface IWorldOptions<ParametersType = any> {\n attach: ICreateAttachment\n log: ICreateLog\n parameters: ParametersType\n}\n\nexport interface IWorld<ParametersType = any> {\n readonly attach: ICreateAttachment\n readonly log: ICreateLog\n readonly parameters: ParametersType\n\n [key: string]: any\n}\n\nexport default class World<ParametersType = any>\n implements IWorld<ParametersType>\n{\n public readonly attach: ICreateAttachment\n public readonly log: ICreateLog\n public readonly parameters: ParametersType\n\n constructor({ attach, log, parameters }: IWorldOptions<ParametersType>) {\n this.attach = attach\n this.log = log\n this.parameters = parameters\n }\n}\n"]}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "8.
|
|
1
|
+
export declare const version = "8.1.0";
|
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,0BAA0B;AACb,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,0BAA0B;AACb,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// generated by genversion\nexport const version = '8.1.0'\n"]}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"gherkin",
|
|
9
9
|
"tests"
|
|
10
10
|
],
|
|
11
|
-
"version": "8.
|
|
11
|
+
"version": "8.1.0",
|
|
12
12
|
"homepage": "https://github.com/cucumber/cucumber-js",
|
|
13
13
|
"author": "Julien Biezemans <jb@jbpros.com>",
|
|
14
14
|
"contributors": [
|
|
@@ -197,11 +197,11 @@
|
|
|
197
197
|
"@cspotcode/source-map-support": "^0.7.0",
|
|
198
198
|
"@cucumber/ci-environment": "9.0.4",
|
|
199
199
|
"@cucumber/cucumber-expressions": "15.0.2",
|
|
200
|
-
"@cucumber/gherkin": "
|
|
201
|
-
"@cucumber/gherkin-streams": "
|
|
200
|
+
"@cucumber/gherkin": "23.0.1",
|
|
201
|
+
"@cucumber/gherkin-streams": "5.0.1",
|
|
202
202
|
"@cucumber/gherkin-utils": "^7.0.0",
|
|
203
|
-
"@cucumber/html-formatter": "19.
|
|
204
|
-
"@cucumber/messages": "
|
|
203
|
+
"@cucumber/html-formatter": "19.1.0",
|
|
204
|
+
"@cucumber/messages": "18.0.0",
|
|
205
205
|
"@cucumber/tag-expressions": "4.1.0",
|
|
206
206
|
"assertion-error-formatter": "^3.0.0",
|
|
207
207
|
"capital-case": "^1.0.4",
|
|
@@ -230,8 +230,8 @@
|
|
|
230
230
|
"yup": "^0.32.11"
|
|
231
231
|
},
|
|
232
232
|
"devDependencies": {
|
|
233
|
-
"@cucumber/compatibility-kit": "9.
|
|
234
|
-
"@cucumber/message-streams": "
|
|
233
|
+
"@cucumber/compatibility-kit": "9.2.0",
|
|
234
|
+
"@cucumber/message-streams": "4.0.1",
|
|
235
235
|
"@cucumber/query": "11.0.0",
|
|
236
236
|
"@microsoft/api-documenter": "7.17.0",
|
|
237
237
|
"@microsoft/api-extractor": "7.20.0",
|
|
@@ -274,6 +274,7 @@
|
|
|
274
274
|
"mocha": "9.2.2",
|
|
275
275
|
"mustache": "4.2.0",
|
|
276
276
|
"nyc": "15.1.0",
|
|
277
|
+
"portfinder": "^1.0.28",
|
|
277
278
|
"prettier": "2.6.1",
|
|
278
279
|
"reindent-template-literals": "1.1.0",
|
|
279
280
|
"shx": "0.3.4",
|
|
@@ -291,7 +292,7 @@
|
|
|
291
292
|
"cck-test": "mocha 'compatibility/**/*_spec.ts'",
|
|
292
293
|
"docs:ci": "api-extractor run --verbose",
|
|
293
294
|
"docs:local": "api-extractor run --verbose --local && api-documenter markdown --input-folder ./tmp/api-extractor --output-folder ./docs/api",
|
|
294
|
-
"feature-test": "node
|
|
295
|
+
"feature-test": "node bin/cucumber.js",
|
|
295
296
|
"lint-autofix": "eslint --fix \"{compatibility,example,features,scripts,src,test}/**/*.ts\"",
|
|
296
297
|
"lint-code": "eslint \"{compatibility,example,features,scripts,src,test}/**/*.ts\"",
|
|
297
298
|
"lint-dependencies": "dependency-lint",
|
|
@@ -303,14 +304,14 @@
|
|
|
303
304
|
"prepublishOnly": "rm -rf lib && npm run build-local",
|
|
304
305
|
"pretest-coverage": "npm run build-local",
|
|
305
306
|
"pretypes-test": "npm run build-local",
|
|
306
|
-
"test-coverage": "nyc --silent mocha 'src/**/*_spec.ts' 'compatibility/**/*_spec.ts' && nyc --silent --no-clean node
|
|
307
|
-
"test": "npm run lint && npm run
|
|
307
|
+
"test-coverage": "nyc --silent mocha 'src/**/*_spec.ts' 'compatibility/**/*_spec.ts' && nyc --silent --no-clean node bin/cucumber.js && nyc report --reporter=lcov",
|
|
308
|
+
"test": "npm run lint && npm run types-test && npm run unit-test && npm run cck-test && npm run feature-test",
|
|
308
309
|
"types-test": "tsd",
|
|
309
310
|
"unit-test": "mocha 'src/**/*_spec.ts'",
|
|
310
311
|
"update-dependencies": "npx npm-check-updates --upgrade"
|
|
311
312
|
},
|
|
312
313
|
"bin": {
|
|
313
|
-
"cucumber-js": "
|
|
314
|
+
"cucumber-js": "bin/cucumber.js"
|
|
314
315
|
},
|
|
315
316
|
"license": "MIT",
|
|
316
317
|
"files": [
|