New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@wdio/cucumber-framework

Package Overview
Dependencies
Maintainers
3
Versions
375
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wdio/cucumber-framework - npm Package Compare versions

Comparing version 8.10.1 to 8.10.2

10

build/cjs/index.d.ts

@@ -1,2 +0,2 @@

declare const After: any, AfterAll: any, AfterStep: any, Before: any, BeforeAll: any, BeforeStep: any, DataTable: any, defineParameterType: any, defineStep: any, Given: any, setDefaultTimeout: any, setDefinitionFunctionWrapper: any, setWorldConstructor: any, World: any, Then: any, When: any;
declare const After: any, AfterAll: any, AfterStep: any, Before: any, BeforeAll: any, BeforeStep: any, Given: any, Then: any, When: any, defineParameterType: any, defineStep: any, setDefaultTimeout: any, setDefinitionFunctionWrapper: any, setWorldConstructor: any, DataTable: any, World: any;
declare const adapterFactory: {

@@ -10,13 +10,13 @@ init: (...args: any[]) => Promise<import("../index.js").CucumberAdapter>;

BeforeStep: any;
DataTable: any;
Given: any;
Then: any;
When: any;
defineParameterType: any;
defineStep: any;
Given: any;
setDefaultTimeout: any;
setDefinitionFunctionWrapper: any;
setWorldConstructor: any;
DataTable: any;
World: any;
Then: any;
When: any;
};
//# sourceMappingURL=index.d.ts.map
"use strict";
const { After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, DataTable, defineParameterType, defineStep, Given, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, World, Then, When } = require('@cucumber/cucumber');
const { After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, Given, Then, When, defineParameterType, defineStep, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, DataTable, World, } = require('@cucumber/cucumber');
const adapterFactory = {

@@ -11,19 +11,19 @@ init: async function initCucumberFramework(...args) {

},
After: After,
AfterAll: AfterAll,
AfterStep: AfterStep,
Before: Before,
BeforeAll: BeforeAll,
BeforeStep: BeforeStep,
DataTable: DataTable,
defineParameterType: defineParameterType,
defineStep: defineStep,
Given: Given,
setDefaultTimeout: setDefaultTimeout,
setDefinitionFunctionWrapper: setDefinitionFunctionWrapper,
setWorldConstructor: setWorldConstructor,
World: World,
Then: Then,
When: When,
After,
AfterAll,
AfterStep,
Before,
BeforeAll,
BeforeStep,
Given,
Then,
When,
defineParameterType,
defineStep,
setDefaultTimeout,
setDefinitionFunctionWrapper,
setWorldConstructor,
DataTable,
World,
};
module.exports = adapterFactory;

@@ -18,3 +18,3 @@ /// <reference types="node" />

private _startedFeatures;
constructor(eventBroadcaster: EventEmitter, _pickleFilter: PickleFilter);
constructor(eventBroadcaster: EventEmitter, _pickleFilter: InstanceType<typeof PickleFilter>);
usesSpecGrouping(): boolean;

@@ -21,0 +21,0 @@ featureIsStarted(feature: string): boolean;

/// <reference types="node" />
import { EventEmitter } from 'node:events';
import * as Cucumber from '@cucumber/cucumber';
import { After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, DataTable, defineParameterType, defineStep, Given, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, World, Then, When } from '@cucumber/cucumber';
import type { World as WorldType } from '@cucumber/cucumber';
import type { GherkinDocument } from '@cucumber/messages';
import type { Capabilities, Options } from '@wdio/types';
import type { CucumberOptions, StepDefinitionOptions, HookFunctionExtension as HookFunctionExtensionImport } from './types.js';
declare const After: (<WorldType_1 = Cucumber.IWorld<any>>(code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestCaseHookFunction<WorldType_1>) => void) & (<WorldType_1 = Cucumber.IWorld<any>>(tags: string, code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestCaseHookFunction<WorldType_1>) => void) & (<WorldType_2 = Cucumber.IWorld<any>>(options: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").IDefineTestCaseHookOptions, code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestCaseHookFunction<WorldType_2>) => void), AfterAll: ((code: Function) => void) & ((options: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").IDefineTestRunHookOptions, code: Function) => void), AfterStep: (<WorldType_1 = Cucumber.IWorld<any>>(code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestStepHookFunction<WorldType_1>) => void) & (<WorldType_1 = Cucumber.IWorld<any>>(tags: string, code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestStepHookFunction<WorldType_1>) => void) & (<WorldType_2 = Cucumber.IWorld<any>>(options: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").IDefineTestStepHookOptions, code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestStepHookFunction<WorldType_2>) => void), Before: (<WorldType_1 = Cucumber.IWorld<any>>(code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestCaseHookFunction<WorldType_1>) => void) & (<WorldType_1 = Cucumber.IWorld<any>>(tags: string, code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestCaseHookFunction<WorldType_1>) => void) & (<WorldType_2 = Cucumber.IWorld<any>>(options: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").IDefineTestCaseHookOptions, code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestCaseHookFunction<WorldType_2>) => void), BeforeAll: ((code: Function) => void) & ((options: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").IDefineTestRunHookOptions, code: Function) => void), BeforeStep: (<WorldType_1 = Cucumber.IWorld<any>>(code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestStepHookFunction<WorldType_1>) => void) & (<WorldType_1 = Cucumber.IWorld<any>>(tags: string, code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestStepHookFunction<WorldType_1>) => void) & (<WorldType_2 = Cucumber.IWorld<any>>(options: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").IDefineTestStepHookOptions, code: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").TestStepHookFunction<WorldType_2>) => void), Given: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").IDefineStep, Then: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").IDefineStep, When: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").IDefineStep, DataTable: typeof Cucumber.DataTable, World: typeof Cucumber.World, setDefaultTimeout: (milliseconds: number) => void, setDefinitionFunctionWrapper: (fn: Function) => void, setWorldConstructor: (fn: any) => void, defineParameterType: (options: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").IParameterTypeDefinition<any>) => void, defineStep: import("@cucumber/cucumber/lib/support_code_library_builder/types.js").IDefineStep;
declare class CucumberAdapter {

@@ -24,2 +26,5 @@ private _cid;

constructor(_cid: string, _config: Options.Testrunner, _specs: string[], _capabilities: Capabilities.RemoteCapability, _reporter: EventEmitter);
readFiles(filePaths?: Options.Testrunner['specs']): (string | string[])[];
getGherkinDocuments(files?: Options.Testrunner['specs']): (GherkinDocument | GherkinDocument[])[];
filterSpecsByTagExpression(specs?: Options.Testrunner['specs'], tagExpression?: string): typeof specs;
init(): Promise<this>;

@@ -60,3 +65,3 @@ hasTests(): boolean;

*/
wrapStep(code: Function, isStep: boolean, config: Options.Testrunner, cid: string, options: StepDefinitionOptions, getHookParams: Function): (this: Cucumber.World, ...args: any[]) => Promise<unknown>;
wrapStep(code: Function, isStep: boolean, config: Options.Testrunner, cid: string, options: StepDefinitionOptions, getHookParams: Function): (this: WorldType, ...args: any[]) => Promise<unknown>;
}

@@ -63,0 +68,0 @@ declare const adapterFactory: {

import url from 'node:url';
import path from 'node:path';
import fs from 'node:fs';
import { createRequire } from 'node:module';

@@ -8,11 +9,20 @@ import { EventEmitter } from 'node:events';

import { sync as globSync } from 'glob';
import { executeHooksWithArgs, testFnWrapper } from '@wdio/utils';
import * as Cucumber from '@cucumber/cucumber';
import { After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, DataTable, defineParameterType, defineStep, Given, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, World, Then, When } from '@cucumber/cucumber';
import Gherkin from '@cucumber/gherkin';
import { GherkinStreams } from '@cucumber/gherkin-streams';
import { IdGenerator } from '@cucumber/messages';
import { executeHooksWithArgs, testFnWrapper } from '@wdio/utils';
import TagExpressionParser from '@cucumber/tag-expressions';
import CucumberReporter from './reporter.js';
import { DEFAULT_OPTS } from './constants.js';
import { setUserHookNames } from './utils.js';
import { setUserHookNames, shouldRun } from './utils.js';
const { After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, Given, Then, When, DataTable, World, PickleFilter, Runtime, Status, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, defineParameterType, defineStep, parseGherkinMessageStream, supportCodeLibraryBuilder, } = Cucumber;
const uuidFn = IdGenerator.uuid();
const builder = new Gherkin.AstBuilder(uuidFn);
const matcher = new Gherkin.GherkinClassicTokenMatcher();
const gherkinParser = new Gherkin.Parser(builder, matcher);
const require = createRequire(import.meta.url);
// EventDataCollector is not exported from main package
// Cannot import from path mapping without require
// See https://github.com/TypeStrong/ts-node/pull/1585
const EventDataCollector = require('@cucumber/cucumber/lib/formatter/helpers/event_data_collector').default;

@@ -23,3 +33,3 @@ const FILE_PROTOCOL = 'file://';

return {
passed: (world.result?.status === Cucumber.Status.PASSED || world.result?.status === Cucumber.Status.SKIPPED),
passed: (world.result?.status === Status.PASSED || world.result?.status === Status.SKIPPED),
error: world.result?.message,

@@ -73,3 +83,3 @@ duration: world.result?.duration?.nanos / 1e6 // convert into ms

: this._specs;
this._pickleFilter = new Cucumber.PickleFilter({
this._pickleFilter = new PickleFilter({
cwd: this._cwd,

@@ -89,4 +99,54 @@ featurePaths: featurePathsToRun,

}
readFiles(filePaths = []) {
return filePaths.map(filePath => {
return Array.isArray(filePath)
? filePath.map(file => fs.readFileSync(path.resolve(file), 'utf8'))
: fs.readFileSync(path.resolve(filePath), 'utf8');
});
}
getGherkinDocuments(files = []) {
return this.readFiles(files).map((specContent, idx) => {
const docs = [specContent]
.flat(1)
.map((content, ctIdx) => ({
...gherkinParser.parse(content),
uri: Array.isArray(specContent)
? files[idx][ctIdx]
: files[idx],
}));
const [doc, ...etc] = docs;
return etc.length ? docs : doc;
});
}
filterSpecsByTagExpression(specs = [], tagExpression = this._config.cucumberOpts?.tagExpression ?? '') {
if (!tagExpression) {
return specs;
}
const tagParser = TagExpressionParser(tagExpression);
const filteredSpecs = this
.getGherkinDocuments([this._specs])
.map((specDoc) => {
const [doc, ...etc] = [specDoc].flat(1).filter(doc => shouldRun(doc, tagParser));
const ret = Array.isArray(specDoc)
// Return group only if its not empty
? doc && [doc, ...etc]
: doc;
return ret;
})
.filter((doc) => !!doc)
.map(doc => {
// Get URIs from Gherkin documents to run
const [uri, ...etc] = [doc].flat(1).map(doc => doc.uri);
return Array.isArray(doc) ? [uri, ...etc] : uri;
});
return filteredSpecs;
}
async init() {
try {
// Filter the specs according to the tag expression
// Some workers would only spawn to then skip the spec (Feature) file
// Filtering at this stage can prevent the spawning of a massive number of workers
if (this._config.cucumberOpts?.tagExpression) {
this._specs = this.filterSpecsByTagExpression([this._specs]).flat(1);
}
const gherkinMessageStream = GherkinStreams.fromPaths(this._specs, {

@@ -96,3 +156,3 @@ defaultDialect: this._cucumberOpts.featureDefaultLanguage,

});
await Cucumber.parseGherkinMessageStream({
await parseGherkinMessageStream({
cwd: this._cwd,

@@ -121,3 +181,3 @@ eventBroadcaster: this._eventBroadcaster,

await this.registerRequiredModules();
Cucumber.supportCodeLibraryBuilder.reset(this._cwd, this._newId);
supportCodeLibraryBuilder.reset(this._cwd, this._newId);
/**

@@ -133,5 +193,5 @@ * wdio hooks should be added before spec files are loaded

*/
setUserHookNames(Cucumber.supportCodeLibraryBuilder);
Cucumber.setDefaultTimeout(this._cucumberOpts.timeout);
const supportCodeLibrary = Cucumber.supportCodeLibraryBuilder.finalize();
setUserHookNames(supportCodeLibraryBuilder);
setDefaultTimeout(this._cucumberOpts.timeout);
const supportCodeLibrary = supportCodeLibraryBuilder.finalize();
/**

@@ -145,3 +205,3 @@ * gets current step data: `{ uri, feature, scenario, step, sourceLocation }`

.bind(this._cucumberReporter.eventListener);
const runtime = new Cucumber.Runtime({
const runtime = new Runtime({
newId: this._newId,

@@ -235,21 +295,21 @@ eventBroadcaster: this._eventBroadcaster,

const eventListener = this._cucumberReporter?.eventListener;
Cucumber.BeforeAll(async function wdioHookBeforeFeature() {
BeforeAll(async function wdioHookBeforeFeature() {
const params = eventListener?.getHookParams();
await executeHooksWithArgs('beforeFeature', config.beforeFeature, [params?.uri, params?.feature]);
});
Cucumber.AfterAll(async function wdioHookAfterFeature() {
AfterAll(async function wdioHookAfterFeature() {
const params = eventListener?.getHookParams();
await executeHooksWithArgs('afterFeature', config.afterFeature, [params?.uri, params?.feature]);
});
Cucumber.Before(async function wdioHookBeforeScenario(world) {
Before(async function wdioHookBeforeScenario(world) {
await executeHooksWithArgs('beforeScenario', config.beforeScenario, [world, this]);
});
Cucumber.After(async function wdioHookAfterScenario(world) {
After(async function wdioHookAfterScenario(world) {
await executeHooksWithArgs('afterScenario', config.afterScenario, [world, getResultObject(world), this]);
});
Cucumber.BeforeStep(async function wdioHookBeforeStep() {
BeforeStep(async function wdioHookBeforeStep() {
const params = eventListener?.getHookParams();
await executeHooksWithArgs('beforeStep', config.beforeStep, [params?.step, params?.scenario, this]);
});
Cucumber.AfterStep(async function wdioHookAfterStep(world) {
AfterStep(async function wdioHookAfterStep(world) {
const params = eventListener?.getHookParams();

@@ -267,3 +327,3 @@ await executeHooksWithArgs('afterStep', config.afterStep, [params?.step, params?.scenario, getResultObject(world), this]);

const getHookParams = () => this.getHookParams && this.getHookParams();
Cucumber.setDefinitionFunctionWrapper((fn, options = { retry: 0 }) => {
setDefinitionFunctionWrapper((fn, options = { retry: 0 }) => {
/**

@@ -270,0 +330,0 @@ * hooks defined in wdio.conf are already wrapped

@@ -20,3 +20,3 @@ /// <reference types="node" />

private _testStart?;
constructor(eventBroadcaster: EventEmitter, pickleFilter: PickleFilter, _options: ReporterOptions, _cid: string, _specs: string[], _reporter: EventEmitter);
constructor(eventBroadcaster: EventEmitter, pickleFilter: InstanceType<typeof PickleFilter>, _options: ReporterOptions, _cid: string, _specs: string[], _reporter: EventEmitter);
handleBeforeFeature(uri: string, feature: Feature): void;

@@ -23,0 +23,0 @@ handleBeforeScenario(uri: string, feature: Feature, scenario: ReporterScenario): void;

@@ -0,3 +1,4 @@

import type TagExpressionParser from '@cucumber/tag-expressions';
import type { supportCodeLibraryBuilder } from '@cucumber/cucumber';
import type { PickleStep, TestStep, Feature, Pickle, TestStepResultStatus } from '@cucumber/messages';
import type { PickleStep, TestStep, Feature, Pickle, TestStepResultStatus, GherkinDocument, FeatureChild, RuleChild } from '@cucumber/messages';
import type { Capabilities } from '@wdio/types';

@@ -90,3 +91,8 @@ import type { ReporterStep } from './constants.js';

export declare function addKeywordToStep(steps: ReporterStep[], feature: Feature): ReporterStep[];
export declare function hasTags(msg: GherkinDocument | FeatureChild | RuleChild, { tagParser, lineOnFile }: {
tagParser: ReturnType<typeof TagExpressionParser>;
lineOnFile: number | undefined;
}): boolean;
export declare function shouldRun(doc: GherkinDocument, tagParser: ReturnType<typeof TagExpressionParser>): boolean;
export {};
//# sourceMappingURL=utils.d.ts.map

@@ -188,1 +188,36 @@ import path from 'node:path';

}
export function hasTags(msg, { tagParser, lineOnFile }) {
const type = (msg.feature
?? msg.rule
?? msg.scenario);
if (type) {
const matches = tagParser.evaluate(type.tags.map(t => t.name));
return lineOnFile
// Evaluate only specific line
? type.location.line === lineOnFile && matches
: matches;
}
return false;
}
export function shouldRun(doc, tagParser) {
if (!doc.feature) {
return false;
}
const ext = path.extname(doc.uri);
const lineOnFile = ext.startsWith('feature:')
? Number(ext.split('feature:').pop())
: undefined;
return (
// Check if Feature has matching tags
hasTags(doc, { tagParser, lineOnFile })
// Check if some root Scenarios have matching tags
|| doc.feature.children.filter(c => c.scenario).some(child => hasTags(child, { tagParser, lineOnFile }))
// Check if some Rules have matching tags
|| doc.feature.children.filter(c => c.rule).some(child => hasTags(child, { tagParser, lineOnFile }))
// Check if some Scenarios within Rules have matching tags
|| doc.feature.children
.filter(c => c.rule)
.map(c => c.rule.children.filter(c => c.scenario))
.flat(1)
.some(child => hasTags(child, { tagParser, lineOnFile })));
}
{
"name": "@wdio/cucumber-framework",
"version": "8.10.1",
"version": "8.10.2",
"description": "A WebdriverIO plugin. Adapter for Cucumber.js testing framework.",

@@ -41,10 +41,11 @@ "author": "Christian Bromann <mail@bromann.dev>",

"dependencies": {
"@cucumber/cucumber": "8.5.3",
"@cucumber/cucumber": "8.11.1",
"@cucumber/gherkin": "26.2.0",
"@cucumber/gherkin-streams": "^5.0.0",
"@cucumber/gherkin-streams": "^5.0.1",
"@cucumber/messages": "22.0.0",
"@cucumber/tag-expressions": "5.0.1",
"@types/node": "^20.1.0",
"@wdio/logger": "8.6.6",
"@wdio/types": "8.10.1",
"@wdio/utils": "8.10.1",
"@wdio/types": "8.10.2",
"@wdio/utils": "8.10.2",
"glob": "^10.2.2",

@@ -61,3 +62,3 @@ "is-glob": "^4.0.0",

},
"gitHead": "0fc768bb7b2fe233877893260aec658facf6357f"
"gitHead": "fb163d506af31d0c5e5328bfee07d55a56aa0034"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc