Previously, wrote tests for java , but there was a need to write them in js .

To set a "custom" path to features or to step_definitions files, there were no problems in java . In cucumber-js , the problem is urgent, there is not a word in the documentation about the ability to configure paths.

The proposed structure by the developers:

 features/ test.feature support/ world.js hooks.js step_definitions/ test.js 

Desired structure:

 src/ features/ test/ test.feature # Сценарий test.steps.js # "Шаги" для сценари test.js # Объект страницы со всеми методами для "шагов" helpers/ hooks.js 

Accordingly, we need the ability to override the paths for steps_definitions files, without using third-party tools ( wdio , protractor , etc.) to run tests.

I launch it as follows:

Helper to initialize the driver:

 'use strict'; const webdriver = require('selenium-webdriver'), chrome = require('chromedriver'), { setWorldConstructor } = require('cucumber'); const driver = new webdriver.Builder().forBrowser('chrome').build(); module.exports = { driver }; 

Test feature:

 #local-run Feature: Работоспособность поиска google Scenario: Поиск работает Given Открыли страницу google When Ввели поисковой зарос | Tomato | | Cucumber | | Cabage | Then Поиск выдал результаты 

"Steps" for a test feature:

 'use strict'; const { defineSupportCode } = require('cucumber'); defineSupportCode(({ Given, When, Then, setDefinitionFunctionWrapper }) => { setDefinitionFunctionWrapper(() => { this.Given('Открыли страницу google', function (callback) { callback.pending(); }); this.When('Ввели поисковой зарос', function (callback) { callback.pending(); }); this.Then('Поиск выдал результаты', function (callback) { callback.pending(); }); }) }); 

The page object is empty, so I don’t cite it, for the reason that tests do not run in principle, that is, the feature is visible, but there are no steps.

I launch through cucumber.js in the project.

Tried to do the "standard" structure given in the docks - it still does not work, even with the code given there.

  • Please show how you run the tests - Mikhail Vaysman
  • @MikhailVaysman updated the description. - lamartire
  • try specifying directories using the -r option. The -r switch can be used several times to specify multiple directories. - Mikhail Vaysman
  • @MikhailVaysman thanks. It turned out that everything is much simpler - there should be no switch functions at all in the description of steps, because the expected context is lost. - lamartire

0