The `wdio-cucumber-framework` package acts as an essential adapter for integrating the Cucumber.js testing framework into WebdriverIO projects. It allows developers to write Behavior-Driven Development (BDD) tests using Cucumber's Gherkin syntax and execute them via the WebdriverIO test runner. The current stable version, 2.2.8, is primarily designed to work with Cucumber.js v4. Users needing compatibility with older Cucumber.js versions must install specific legacy versions of this adapter (v1.1.1 for Cucumber.js v2, and v0.3.1 for Cucumber.js v1). This framework is released as part of the WebdriverIO ecosystem and typically sees updates in line with major WebdriverIO releases or significant changes in Cucumber.js. Its key differentiator is providing a seamless bridge between WebdriverIO's powerful automation capabilities and Cucumber's readability and BDD structure, offering specific configuration options not native to Cucumber.js itself, like `failAmbiguousDefinitions`.
npm install wdio-cucumber-frameworkVerified import paths — ran on the pinned version, not inferred.
This configuration snippet shows a basic `wdio.conf.ts` setup using the Cucumber framework, specifying feature and step definition paths, and common Cucumber options like `timeout` and `tagExpression`.
Ensure `wdio-cucumber-framework` version aligns with your Cucumber.js version. For Cucumber.js v2, use `wdio-cucumber-framework@1.1.1`. For Cucumber.js v1, use `wdio-cucumber-framework@0.3.1`.
Be aware that these options only apply when running Cucumber tests through WebdriverIO and this specific adapter. Refer to the `wdio-cucumber-framework` documentation for their correct usage.
Ensure all features intended for conditional execution have appropriate tags. Consider using `specs` filtering in `wdio.conf.js` for broader feature file exclusion if untagged features are not desired at all.
Adjust `cucumberOpts.timeout` to a sufficiently high value (in milliseconds) to accommodate long-running steps, especially those involving complex UI interactions or data processing. The default is 30000ms (30 seconds).
Ensure `npm install wdio-cucumber-framework @cucumber/cucumber --save-dev` has been run and check that `framework: 'cucumber'` is correctly spelled in your `wdio.conf.js`.
Verify that your `cucumberOpts.require` array in `wdio.conf.js` correctly points to your step definition files (e.g., `path.join(__dirname, 'features/step-definitions/**/*.ts')`). Also, ensure proper compilers like `ts-node/register` are configured for TypeScript.
Refine your step definition regular expressions to be more specific, or set `cucumberOpts.failAmbiguousDefinitions: true` in `wdio.conf.js` to treat this as an error and stop the test run immediately, aiding in debugging.
Implement the missing step definition in your step files. You can also temporarily set `cucumberOpts.ignoreUndefinedDefinitions: true` to treat this as a warning instead of a failure during development, or `cucumberOpts.strict: true` to ensure all steps are defined.