Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new API for running Cucumber #3995

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davidjgoss
Copy link

@davidjgoss davidjgoss commented Jan 17, 2024

This PR changes the Cucumber runner integration to use Cucumber's JavaScript API rather than the now-deprecated Cli class. Closes #3317.

The size of the code change is pretty small since we can now pass in an argv array to Cucumber's loadConfiguration function without having to convert it to an options object.

Some of the tests from test/cucumber-integration-tests are failing for me locally, but are hitting issues at the Nightwatch level and fail in the same way on main - I'll try to get these fixed up if I can, and perhaps add some more.

One thing I wasn't sure about was - given this will only work with cucumber-js 10.3.1 and above - is whether I should keep the existing Cli-based implementation in place for now and check the version from Cucumber to decide which one to use. I'd be happy to add this in if it's considered valuable.

(Raising as draft so as to get some eyes on this early - feedback welcome.)

@CLAassistant
Copy link

CLAassistant commented Jan 17, 2024

CLA assistant check
All committers have signed the CLA.

@beatfactor
Copy link
Member

Thanks for sending this. On a quick glance, I'm thinking that we should keep the existing implementation for Cucumber version pre-10 so that we are backwards compatible.

@davidjgoss
Copy link
Author

@beatfactor no probem, I've updated so that both integrations are there with fairly decent code reuse, and we check the version exported by Cucumber to decide which to run. There's also an env var override which we use in the tests so we check every test case with both integrations.

We'll probably remove the Cli export in 12.0.0 which will be a few months out at least.

@nightwatchjs nightwatchjs deleted a comment from github-actions bot Jan 22, 2024
@beatfactor
Copy link
Member

Ok, so now it will look for the installed cucumber version and decide which integration strategy to use? Regarding the env var override, I'd suggest to use the existing config dictionary and add a new field there, as in extend the options here:

{
  test_runner: {
    // set cucumber as the runner
    type: 'cucumber',
    
    // define cucumber specific options
    
    options: {
      //set the feature path
      feature_path: 'examples/cucumber-js/*/*.feature',
      
      // start the webdriver session automatically (enabled by default)
      auto_start_session: true,
      
      // use parallel execution in Cucumber
      // set number of workers to use (can also be defined in the cli as --parallel 2
      parallel: 2 
    }
  },
  
  src_folders: ['examples/cucumber-js/features/step_definitions']
}

https://nightwatchjs.org/guide/writing-tests/using-cucumberjs.html

@davidjgoss
Copy link
Author

davidjgoss commented Jan 23, 2024

Thanks @beatfactor, I was a bit hesitant to add an option because it feels like this should just need to be an internal override for test purposes, and an env var was the least worst way to do it I could see. But thinking about it, if we make it an option it at least gives people the control if they need to switch because of some niche issue or something. I'll make that change.

@davidjgoss davidjgoss force-pushed the use-cucumber-api branch 2 times, most recently from 38be81f to e5219cd Compare January 27, 2024 11:22
@gravityvi gravityvi marked this pull request as ready for review April 19, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement] Change Cucumber Integration to use new Programmatic APIs
3 participants