Nightcatch Cucumber не находит мои определения шагов - PullRequest
0 голосов
/ 14 февраля 2020

Текущее поведение

определения шагов не распознаются ... независимо от того, что я пытаюсь, при запуске nightwatch мои функции и шаги возвращаются как неопределенные.

Ожидаемое / желаемое поведение

Код в моей папке step_definitions выполняется.

Среда:

  • версия nightwatch-огурца: 9.1.3
  • версия nightwatch: 0.9.21
  • версия огурца: 6.0.5
  • версия Selenium_server: 3.141.59
  • Phantom js - встроенная версия: 2.1.16
  • Node.js версия : 10.17.0

Пакет. json

    {
      "name": "nightwatchcucumbertest",
      "version": "1.0.0",
      "description": "Test the setup of nightwatch and cucumber",
      "main": "index.js",
      "scripts": {
        "test": "nightwatch"
      },
      "author": "Mark Strohfus",
      "license": "ISC",
      "devDependencies": {
        "cucumber": "^6.0.5",
        "nightwatch": "^0.9.21",
        "nightwatch-cucumber": "^9.1.3",
        "phantomjs-prebuilt": "^2.1.16",
        "selenium-server": "^3.141.59"
      },
      "dependencies": {
        "cucumber": "^6.0.5",
        "phantomjs-prebuilt": "^2.1.16",
        "selenium-server": "^3.141.59"
      }
    }

nightwatch.conf. js

var seleniumServer = require('selenium-server')
var phantomjs = require('phantomjs-prebuilt')
var nightwatchCucumber = require('nightwatch-cucumber')

// Handles the runner, location of feature files and step definitions,
// and closing of nightwatch
var nightwatchCucumberConf = {
    runner: 'nightwatch',
    featureFiles: 'features',
    stepDefinitions: 'step_definitions',
    closeSession: 'afterFeature'
}

module.exports = {
    // Loads nightwatch-cucumber configuration into main nightwatch.js conf
    src_folders: [nightwatchCucumber(nightwatchCucumberConf)],
    custom_commands_path: '',
    custom_assertions_path: '',
    page_objects_path: '',
    live_output: false,
    disable_colors: false,


    // Sets configuration for Selenium Server
    selenium: {
        start_process: true,
        server_path: seleniumServer.path,
        host: '127.0.0.1',
        port: 4444
    },


    // Sets config options for different testing environments defined by the user
    test_settings: {
        default: {
            launch_url: 'https://moduscreate.com',
            silent: true,
            desiredCapabilities: {
                browserName: 'chrome',
                javascriptEnabled: true,
                acceptSslCerts: true
            },
            'screenshots': {
                enabled: true,
                on_error: true,
                on_failure: true,
                path: '/screenshots'
            }
        },
        firefox: {
            desiredCapabilities: {
                browserName: 'firefox',
                javascriptEnabled: true,
                acceptSslCerts: true
            }
        }
    }
}

функции / о.функции

Feature: Modus About Page
    To establish that our website has an About Page
    As a user, I want to ensure that our Home page has a link to the about page


    Scenario: Verify About Page Link
        Given I open the Modus Create home page
        And the title is "Modus Create - HTML5 Application Development & Training"
        Then the About Page link exists

step_definitions / о. js

const { client } = require('nightwatch-cucumber');
const { Given, Then, When } = require('cucumber');

    Given('I open the Modus Create home page', function () {
        client
            .url('https://moduscreate.com')
            .waitForElementVisible('body', 1000);
        return 'pending';
      });

    Given('the title is {string}', function (string) {
        client.assert.title(title);
        return 'pending';
      });

    Then('the About Page link exists', function () {
        client.assert.elementPresent('a[href="/about"]');
        return 'pending';
    });

выход из работающей ночной часы

Starting selenium server... started - PID:  13800
UUU

Warnings:

1) Scenario: Verify About Page Link # features\modusAbout.feature:6
   ? Given I open the Modus Create home page
       Undefined. Implement with the following snippet:

         Given('I open the Modus Create home page', function () {
           // Write code here that turns the phrase above into concrete actions
           return 'pending';
         });

   ? And the title is "Modus Create - HTML5 Application Development & Training"
       Undefined. Implement with the following snippet:

         Given('the title is {string}', function (string) {
           // Write code here that turns the phrase above into concrete actions
           return 'pending';
         });

   ? Then the About Page link exists
       Undefined. Implement with the following snippet:

         Then('the About Page link exists', function () {
           // Write code here that turns the phrase above into concrete actions
           return 'pending';
         });


1 scenario (1 undefined)
3 steps (3 undefined)
0m00.000s

true
'''

1 Ответ

0 голосов
/ 14 февраля 2020

Я бы настоятельно рекомендовал перейти с плагина nightwatch-cucumber на nightwatch-api.

Что касается проблемы, с которой вы столкнулись, я не смог увидеть какие-либо настройки, связанные с огурцом, в вашем конфигурационном файле, которые помогут бегуну определить файлы определения шага. Ниже приведена ссылка, которая может дать вам представление о том, что ему нужно.

http://mucsi96.github.io/nightwatch-cucumber/#passing -Addition-cli-options-for-cucumber js

https://github.com/mucsi96/nightwatch-cucumber/blob/master/examples/simple-example/nightwatch.conf.js#L5

Ура!

...