cds-cucumber

Detailed information

Initialization

Initialization of the steps library is triggered via the command:

npx cds-add-cucumber

It will perform the following operations:

  1. create cucumber configuration file ./cucumber.yml containing the following settings:
    • require steps module
       default:
        requireModule:
          - "@cap-js-community/cds-cucumber"
      
  2. create directory for feature specifications: ./test/features
  3. create directory for own steps: ./test/features/step_definitions
  4. optionally (in case the project matches the cds samples one) create first feature file: ./test/features/first.feature
  5. create configuration for cucumber plugin: ./.vscode/settings.json
     {
       "cucumberautocomplete.steps": [
         "test/features/step_definitions/*.js",
         "node_modules/@cap-js-community/cds-cucumber/lib/steps/*.js"
       ],
       "cucumberautocomplete.strictGherkinCompletion": true
     }
    
  6. optionally (in case the project matches the cds samples one) create file with CDS annotations: ./srv/annotations.cds

Add your own steps

In addition to the provided steps you can add your own steps in your repository. By default they should be located in the following folder:

test/features/step_definitions

Local SAP UI5 build

Additional information about using local SAP UI5 build can be found here.

VSCode Cucumber(Gherkin) plugin

In order to get support (like code completion) for VSCode while writing your specifications, you can install one of the following plugins:

Debugging

Information can be found here.

Environment variables

Information can be found here.

Information about the used webdriver

The selenium-webdriver nodejs module is used to control the browser and it requires a webdriver. The version of the webdriver should match the version of the web browser. The node module chromedriver is used to download the latest webdriver version automatically. Both modules are listed in the dependencies of this module.

Most systems are configured to update the browser automatically which requires also an update of the webdriver. You can update the chrome webdriver to the latest version with the following command:

npm install chromedriver --chromedriver_version=LATEST

Selenium in docker

In cases where the browser is not installed or can not be started (CI), you can run selenium and the corresponding browser in docker as follows:

docker run -d --network host selenium/standalone-chrome

By default the selenium/standalone-chrome image opens the port 4444 to access the webdriver.

SELENIUM_REMOTE_URL="http://127.0.0.1:4444/wd/hub" npx cucumber-js test

Code coverage

Server-side code-covarage is available using the native V8 code-coverage module c8 and it can be activated via the environment variable CDS_CUCUMBER_CODECOV.

OData v2