@wdio/cucumber-framework 7.16.12 → 7.17.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/build/types.d.ts DELETED
@@ -1,187 +0,0 @@
1
- import type { Capabilities, Frameworks } from '@wdio/types';
2
- import type { Pickle, PickleStep, TestStep, Feature } from '@cucumber/messages';
3
- import type { ITestCaseHookParameter } from '@cucumber/cucumber/lib/support_code_library_builder/types';
4
- export interface CucumberOptions {
5
- /**
6
- * Show full backtrace for errors.
7
- * @default true
8
- */
9
- backtrace?: boolean;
10
- /**
11
- * Require modules prior to requiring any support files.
12
- * @default []
13
- * @example `['@babel/register']` or `[['@babel/register', { rootMode: 'upward', ignore: ['node_modules'] }]] or [() => { require('ts-node').register({ files: true }) }]`
14
- */
15
- requireModule?: string[];
16
- /**
17
- * Treat ambiguous definitions as errors.
18
- *
19
- * Please note that this is a @wdio/cucumber-framework specific option
20
- * and not recognized by cucumber-js itself.
21
- * @default false
22
- */
23
- failAmbiguousDefinitions?: boolean;
24
- /**
25
- * Abort the run on first failure.
26
- * @default false
27
- */
28
- failFast?: boolean;
29
- /**
30
- * Treat undefined definitions as warnings.
31
- * Please note that this is a @wdio/cucumber-framework specific option and
32
- * not recognized by cucumber-js itself.
33
- * @default false
34
- */
35
- ignoreUndefinedDefinitions?: boolean;
36
- /**
37
- * Only execute the scenarios with name matching the expression (repeatable).
38
- * @default []
39
- */
40
- names?: (string | RegExp)[];
41
- /**
42
- * Require files containing your step definitions before executing features.
43
- * You can also specify a glob to your step definitions.
44
- * @default []
45
- * @example `[path.join(__dirname, 'step-definitions', 'my-steps.js')]`
46
- */
47
- require?: string[];
48
- /**
49
- * Specify a custom snippet syntax.
50
- */
51
- snippetSyntax?: string;
52
- /**
53
- * Hide step definition snippets for pending steps.
54
- * @default true
55
- */
56
- snippets?: boolean;
57
- /**
58
- * Hide source uris.
59
- * @default true
60
- */
61
- source?: boolean;
62
- /**
63
- * Fail if there are any undefined or pending steps
64
- * @default false
65
- */
66
- strict?: boolean;
67
- /**
68
- * Only execute the features or scenarios with tags matching the expression.
69
- * Please see the [Cucumber documentation](https://docs.cucumber.io/cucumber/api/#tag-expressions) for more details.
70
- */
71
- tagExpression?: string;
72
- /**
73
- * Add cucumber tags to feature or scenario name
74
- * @default false
75
- */
76
- tagsInTitle?: boolean;
77
- /**
78
- * Timeout in milliseconds for step definitions.
79
- * @default 30000
80
- */
81
- timeout?: number;
82
- /**
83
- * Specify the number of times to retry failing test cases.
84
- * @default 0
85
- */
86
- retry?: number;
87
- /**
88
- * Only retries the features or scenarios with tags matching the expression (repeatable).
89
- * This option requires 'retry' to be specified.
90
- */
91
- retryTagFilter?: RegExp | string;
92
- /**
93
- * Enable this to make webdriver.io behave as if scenarios
94
- * and not steps were the tests.
95
- * @default false
96
- */
97
- scenarioLevelReporter?: boolean;
98
- /**
99
- * Switch between deterministic and random feature execution. Either "defined",
100
- * "random" or "random:42" whereas 42 is the seed for randomization
101
- */
102
- order?: string;
103
- /**
104
- * The language you choose for Gherkin should be the same language your users and
105
- * domain experts use when they talk about the domain. Translating between two
106
- * languages should be avoided.
107
- * @see https://cucumber.io/docs/gherkin/reference/#spoken-languages
108
- */
109
- featureDefaultLanguage?: string;
110
- }
111
- export interface ReporterOptions {
112
- capabilities: Capabilities.RemoteCapability;
113
- ignoreUndefinedDefinitions: boolean;
114
- failAmbiguousDefinitions: boolean;
115
- tagsInTitle: boolean;
116
- scenarioLevelReporter: boolean;
117
- }
118
- export interface TestHookDefinitionConfig {
119
- code: Function;
120
- line: number;
121
- options: any;
122
- uri: string;
123
- }
124
- export interface HookParams {
125
- uri?: string | null;
126
- feature?: Feature | null;
127
- scenario?: Pickle;
128
- step?: PickleStep | TestStep;
129
- }
130
- export interface StepDefinitionOptions {
131
- retry: number;
132
- }
133
- export interface HookFunctionExtension {
134
- /**
135
- *
136
- * Runs before a Cucumber Feature.
137
- * @param uri path to feature file
138
- * @param feature Cucumber feature object
139
- */
140
- beforeFeature?(uri: string, feature: Feature): void;
141
- /**
142
- *
143
- * Runs before a Cucumber Scenario.
144
- * @param world world object containing information on pickle and test step
145
- * @param context Cucumber World object
146
- */
147
- beforeScenario?(world: ITestCaseHookParameter, context: Object): void;
148
- /**
149
- *
150
- * Runs before a Cucumber Step.
151
- * @param step step data
152
- * @param scenario scenario data
153
- * @param context Cucumber World object
154
- */
155
- beforeStep?(step: PickleStep, scenario: Pickle, context: Object): void;
156
- /**
157
- *
158
- * Runs after a Cucumber Step.
159
- * @param step step data
160
- * @param scenario scenario data
161
- * @param result result object containing
162
- * @param result.passed true if scenario has passed
163
- * @param result.error error stack if scenario failed
164
- * @param result.duration duration of scenario in milliseconds
165
- * @param context Cucumber World object
166
- */
167
- afterStep?(step: PickleStep, scenario: Pickle, result: Frameworks.PickleResult, context: Object): void;
168
- /**
169
- *
170
- * Runs after a Cucumber Scenario.
171
- * @param world world object containing information on pickle and test step
172
- * @param result result object containing
173
- * @param result.passed true if scenario has passed
174
- * @param result.error error stack if scenario failed
175
- * @param result.duration duration of scenario in milliseconds
176
- * @param context Cucumber World object
177
- */
178
- afterScenario?(world: ITestCaseHookParameter, result: Frameworks.PickleResult, context: Object): void;
179
- /**
180
- *
181
- * Runs after a Cucumber Feature.
182
- * @param uri path to feature file
183
- * @param feature Cucumber feature object
184
- */
185
- afterFeature?(uri: string, feature: Feature): void;
186
- }
187
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2DAA2D,CAAA;AAEvG,MAAM,WAAW,eAAe;IAC5B;;;OAG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ineProperty(exports, "__esModule", { value: true });
package/build/utils.d.ts DELETED
@@ -1,91 +0,0 @@
1
- import { supportCodeLibraryBuilder } from '@cucumber/cucumber';
2
- import { PickleStep, TestStep, Feature, Pickle, TestStepResultStatus } from '@cucumber/messages';
3
- import { Capabilities } from '@wdio/types';
4
- import { ReporterStep } from './constants';
5
- /**
6
- * NOTE: this function is exported for testing only
7
- */
8
- export declare function createStepArgument({ argument }: PickleStep): string | {
9
- rows: {
10
- cells: string[];
11
- }[];
12
- } | undefined;
13
- /**
14
- * format message
15
- * @param {object} message { type: string, payload: object }
16
- */
17
- export declare function formatMessage({ payload }: any): any;
18
- declare enum StepType {
19
- hook = "hook",
20
- test = "test"
21
- }
22
- /**
23
- * Get step type
24
- * @param {string} type `Step` or `Hook`
25
- */
26
- export declare function getStepType(step: TestStep): StepType;
27
- export declare function getFeatureId(uri: string, feature: Feature): string;
28
- /**
29
- * Builds test title from step keyword and text
30
- * @param {string} keyword
31
- * @param {string} text
32
- * @param {string} type
33
- */
34
- export declare function getTestStepTitle(keyword: string | undefined, text: string | undefined, type: string): string;
35
- /**
36
- * build payload for test/hook event
37
- */
38
- export declare function buildStepPayload(uri: string, feature: Feature, scenario: Pickle, step: ReporterStep, params: {
39
- type: string;
40
- state?: TestStepResultStatus | string | null;
41
- error?: Error;
42
- duration?: number;
43
- title?: string | null;
44
- passed?: boolean;
45
- file?: string;
46
- }): {
47
- uid: string;
48
- title: string;
49
- parent: string;
50
- argument: string | {
51
- rows: {
52
- cells: string[];
53
- }[];
54
- } | undefined;
55
- file: string;
56
- tags: readonly import("@cucumber/messages").PickleTag[];
57
- featureName: string;
58
- scenarioName: string;
59
- type: string;
60
- state?: string | null | undefined;
61
- error?: Error | undefined;
62
- duration?: number | undefined;
63
- passed?: boolean | undefined;
64
- };
65
- /**
66
- * wrap every user defined hook with function named `userHookFn`
67
- * to identify later on is function a step, user hook or wdio hook.
68
- * @param {object} options `Cucumber.supportCodeLibraryBuilder.options`
69
- */
70
- export declare function setUserHookNames(options: typeof supportCodeLibraryBuilder): void;
71
- /**
72
- * Returns true/false if testCase should be kept for current capabilities
73
- * according to tag in the syntax @skip([conditions])
74
- * For example "@skip(browserName=firefox)" or "@skip(browserName=chrome,platform=/.+n?x/)"
75
- * @param {*} testCase
76
- */
77
- export declare function filterPickles(capabilities: Capabilities.RemoteCapability, pickle?: Pickle): boolean;
78
- /**
79
- * The reporters need to have the rule.
80
- * They are NOT available on the scenario, they ARE on the feature.
81
- * This will add them to it
82
- */
83
- export declare function getRule(feature: Feature, scenarioId: string): string | undefined;
84
- /**
85
- * The reporters need to have the keywords, like `Given|When|Then`. They are NOT available
86
- * on the scenario, they ARE on the feature.
87
- * This will aad them
88
- */
89
- export declare function addKeywordToStep(steps: ReporterStep[], feature: Feature): ReporterStep[];
90
- export {};
91
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAuB,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACrH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAkC,YAAY,EAAE,MAAM,aAAa,CAAA;AAK1E;;GAEG;AACH,wBAAgB,kBAAkB,CAAE,EAAE,QAAQ,EAAE,EAAE,UAAU;;;;cAoB3D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAE,EAAE,OAAY,EAAE,EAAE,GAAG,OAgBnD;AAED,aAAK,QAAQ;IACT,IAAI,SAAS;IACb,IAAI,SAAS;CAChB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAE,IAAI,EAAE,QAAQ,YAE1C;AAED,wBAAgB,YAAY,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,UAE1D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAE,OAAO,oBAAY,EAAE,IAAI,oBAAY,EAAE,IAAI,EAAC,MAAM,UAGnF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC5B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE;IACJ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,oBAAoB,GAAG,MAAM,GAAG,IAAI,CAAA;IAC5C,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB;;;;;;;;;;;;;UAPS,MAAM;;;;;EAqBnB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAE,OAAO,EAAE,OAAO,yBAAyB,QAe1E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAE,YAAY,EAAE,YAAY,CAAC,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,WA+B1F;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAS3D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,OAAO,kBA4BvE"}
package/build/utils.js DELETED
@@ -1,210 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addKeywordToStep = exports.getRule = exports.filterPickles = exports.setUserHookNames = exports.buildStepPayload = exports.getTestStepTitle = exports.getFeatureId = exports.getStepType = exports.formatMessage = exports.createStepArgument = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const utils_1 = require("@wdio/utils");
9
- const logger_1 = __importDefault(require("@wdio/logger"));
10
- const constants_1 = require("./constants");
11
- const log = (0, logger_1.default)('@wdio/cucumber-framework:utils');
12
- /**
13
- * NOTE: this function is exported for testing only
14
- */
15
- function createStepArgument({ argument }) {
16
- var _a;
17
- if (!argument) {
18
- return undefined;
19
- }
20
- if (argument.dataTable) {
21
- return {
22
- rows: (_a = argument.dataTable.rows) === null || _a === void 0 ? void 0 : _a.map((row) => {
23
- var _a;
24
- return ({
25
- cells: (_a = row.cells) === null || _a === void 0 ? void 0 : _a.map((cell) => cell.value)
26
- });
27
- })
28
- };
29
- }
30
- if (argument.docString) {
31
- return argument.docString.content;
32
- }
33
- return undefined;
34
- }
35
- exports.createStepArgument = createStepArgument;
36
- /**
37
- * format message
38
- * @param {object} message { type: string, payload: object }
39
- */
40
- function formatMessage({ payload = {} }) {
41
- let content = { ...payload };
42
- /**
43
- * need to convert Error to plain object, otherwise it is lost on process.send
44
- */
45
- if (payload.error && (payload.error.message || payload.error.stack)) {
46
- const { name, message, stack } = payload.error;
47
- content.error = { name, message, stack };
48
- }
49
- if (payload.title && payload.parent) {
50
- content.fullTitle = `${payload.parent}: ${payload.title}`;
51
- }
52
- return content;
53
- }
54
- exports.formatMessage = formatMessage;
55
- var StepType;
56
- (function (StepType) {
57
- StepType["hook"] = "hook";
58
- StepType["test"] = "test";
59
- })(StepType || (StepType = {}));
60
- /**
61
- * Get step type
62
- * @param {string} type `Step` or `Hook`
63
- */
64
- function getStepType(step) {
65
- return step.hookId ? StepType.hook : StepType.test;
66
- }
67
- exports.getStepType = getStepType;
68
- function getFeatureId(uri, feature) {
69
- var _a, _b;
70
- return `${path_1.default.basename(uri)}:${(_a = feature.location) === null || _a === void 0 ? void 0 : _a.line}:${(_b = feature.location) === null || _b === void 0 ? void 0 : _b.column}`;
71
- }
72
- exports.getFeatureId = getFeatureId;
73
- /**
74
- * Builds test title from step keyword and text
75
- * @param {string} keyword
76
- * @param {string} text
77
- * @param {string} type
78
- */
79
- function getTestStepTitle(keyword = '', text = '', type) {
80
- const title = (!text && type.toLowerCase() !== 'hook') ? 'Undefined Step' : text;
81
- return `${keyword.trim()} ${title.trim()}`.trim();
82
- }
83
- exports.getTestStepTitle = getTestStepTitle;
84
- /**
85
- * build payload for test/hook event
86
- */
87
- function buildStepPayload(uri, feature, scenario, step, params) {
88
- return {
89
- ...params,
90
- uid: step.id,
91
- // @ts-ignore
92
- title: getTestStepTitle(step.keyword, step.text, params.type),
93
- parent: scenario.id,
94
- argument: createStepArgument(step),
95
- file: uri,
96
- tags: scenario.tags,
97
- featureName: feature.name,
98
- scenarioName: scenario.name,
99
- };
100
- }
101
- exports.buildStepPayload = buildStepPayload;
102
- /**
103
- * wrap every user defined hook with function named `userHookFn`
104
- * to identify later on is function a step, user hook or wdio hook.
105
- * @param {object} options `Cucumber.supportCodeLibraryBuilder.options`
106
- */
107
- function setUserHookNames(options) {
108
- constants_1.CUCUMBER_HOOK_DEFINITION_TYPES.forEach(hookName => {
109
- options[hookName].forEach((testRunHookDefinition) => {
110
- const hookFn = testRunHookDefinition.code;
111
- if (!hookFn.name.startsWith('wdioHook')) {
112
- const userHookAsyncFn = async function (...args) {
113
- return hookFn.apply(this, args);
114
- };
115
- const userHookFn = function (...args) {
116
- return hookFn.apply(this, args);
117
- };
118
- testRunHookDefinition.code = ((0, utils_1.isFunctionAsync)(hookFn)) ? userHookAsyncFn : userHookFn;
119
- }
120
- });
121
- });
122
- }
123
- exports.setUserHookNames = setUserHookNames;
124
- /**
125
- * Returns true/false if testCase should be kept for current capabilities
126
- * according to tag in the syntax @skip([conditions])
127
- * For example "@skip(browserName=firefox)" or "@skip(browserName=chrome,platform=/.+n?x/)"
128
- * @param {*} testCase
129
- */
130
- function filterPickles(capabilities, pickle) {
131
- const skipTag = /^@skip\((.*)\)$/;
132
- const match = (value, expr) => {
133
- if (Array.isArray(expr)) {
134
- return expr.indexOf(value) >= 0;
135
- }
136
- else if (expr instanceof RegExp) {
137
- return expr.test(value);
138
- }
139
- return (expr && ('' + expr).toLowerCase()) === (value && ('' + value).toLowerCase());
140
- };
141
- const parse = (skipExpr) => skipExpr.split(';').reduce((acc, splitItem) => {
142
- const pos = splitItem.indexOf('=');
143
- if (pos > 0) {
144
- try {
145
- acc[splitItem.substring(0, pos)] = eval(splitItem.substring(pos + 1));
146
- }
147
- catch (err) {
148
- log.error(`Couldn't use tag "${splitItem}" for filtering because it is malformed`);
149
- }
150
- }
151
- return acc;
152
- }, {});
153
- return !(pickle && pickle.tags && pickle.tags
154
- .map(p => { var _a; return (_a = p.name) === null || _a === void 0 ? void 0 : _a.match(skipTag); })
155
- .filter(Boolean)
156
- .map(m => parse(m[1]))
157
- .find((filter) => Object.keys(filter)
158
- .every((key) => match(capabilities[key], filter[key]))));
159
- }
160
- exports.filterPickles = filterPickles;
161
- /**
162
- * The reporters need to have the rule.
163
- * They are NOT available on the scenario, they ARE on the feature.
164
- * This will add them to it
165
- */
166
- function getRule(feature, scenarioId) {
167
- var _a, _b;
168
- const rules = (_a = feature.children) === null || _a === void 0 ? void 0 : _a.filter((child) => Object.keys(child)[0] === 'rule');
169
- const rule = rules.find((rule) => {
170
- var _a, _b;
171
- let scenarioRule = (_b = (_a = rule.rule) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.find((child) => { var _a; return ((_a = child.scenario) === null || _a === void 0 ? void 0 : _a.id) === scenarioId; });
172
- if (scenarioRule) {
173
- return rule;
174
- }
175
- });
176
- return (_b = rule === null || rule === void 0 ? void 0 : rule.rule) === null || _b === void 0 ? void 0 : _b.name;
177
- }
178
- exports.getRule = getRule;
179
- /**
180
- * The reporters need to have the keywords, like `Given|When|Then`. They are NOT available
181
- * on the scenario, they ARE on the feature.
182
- * This will aad them
183
- */
184
- function addKeywordToStep(steps, feature) {
185
- return steps.map(step => {
186
- // Steps without a astNodeIds are hooks
187
- if (step.astNodeIds && step.astNodeIds.length > 0 && feature.children) {
188
- // Points to the AST node locations of the pickle. The last one represents the unique id of the pickle.
189
- // A pickle constructed from Examples will have the first id originating from the Scenario AST node, and
190
- // the second from the TableRow AST node.
191
- // See https://github.com/cucumber/cucumber/blob/master/messages/messages.md
192
- const astNodeId = step.astNodeIds[0];
193
- const rules = feature.children.filter((child) => Object.keys(child)[0] === 'rule');
194
- let featureChildren = feature.children.filter((child) => Object.keys(child)[0] !== 'rule');
195
- const rulesChildrens = rules.map((child) => { var _a; return (_a = child.rule) === null || _a === void 0 ? void 0 : _a.children; }).flat();
196
- featureChildren = featureChildren.concat(rulesChildrens);
197
- featureChildren.find((child) =>
198
- // @ts-ignore
199
- child[Object.keys(child)[0]].steps.find((featureScenarioStep) => {
200
- if (featureScenarioStep.id === astNodeId.toString()) {
201
- step.keyword = featureScenarioStep.keyword;
202
- }
203
- return;
204
- }));
205
- return step;
206
- }
207
- return step;
208
- });
209
- }
210
- exports.addKeywordToStep = addKeywordToStep;