question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use custom_steps.js in gherkin steps?

See original GitHub issue

Hello,

i’ve made a custom fonction to extend the I

custom_steps.js

'use strict';
module.exports = function () {
    return actor({
        waitForLoading: function (seconds = 10) {
            this.waitForInvisible('div.loading', seconds);
        }
    });
}

codecept.json "include": { "I": "./custom_steps.js" },

loginSteps.js

Given('i login with username {string} and password{string}', (username, password) => {
    I.amOnPage('/');
    I.fillField('input#username', username);
    I.fillField('input#password', password);
    I.click('#login-btn');
    I.waitForLoading();
});

I got : I.waitForLoading is not a function

It work when i do a classic scenario :

login_test.js

Feature('Toast');
Scenario('test something', (I) => {
    I.amOnPage('/');
    I.fillField('input#username', 'eeee');
    I.fillField('input#password', 'xxxx');
    I.click('#login-btn');
    I.waitForLoading();
});

How can i make it work in gherkin steps ? Thank you !

Details

  • CodeceptJS version: 1.4.6
  • NodeJS Version: 10.14.0
  • Operating System: windows 7 64 bits

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:6

github_iconTop GitHub Comments

7reactions
kaievnscommented, Mar 19, 2019

this was a frustrating few hours of poking at the thing only to realise that none of the dependency injection features work in the BDD mode 😦

you could at least mention that in the docs

1reaction
AdamOakmancommented, Dec 4, 2018

I worked it around by including customSteps at the top of step definition file (in your case loginSteps.js):

const customSteps = require('../custom_steps.js');
const I = customSteps();

But in this case Gherkin steps are not displayed in console (and also in allure report) after running: codeceptjs run --features --steps which is not really cool.

Please advise.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use custom_steps.js in gherkin steps? #1353 - GitHub
Hello, i've made a custom fonction to extend the I custom_steps.js 'use strict'; module.exports = function () { return actor({ ...
Read more >
Step Definitions - Cucumber Documentation
When Cucumber executes a Gherkin step in a scenario, it will look for a matching step definition to execute. To illustrate how this...
Read more >
cucumber-step-definitions - npm
Start using cucumber-step-definitions in your project by running `npm i ... /project/features/step_definitions/form.js.
Read more >
Nope, we created a test suite with cucumber-js and a lot of ...
... and it should work with react-testing-library as long as it's b. ... with cucumber-js and a lot of custom steps to support...
Read more >
BDD in JavaScript: Getting Started with Cucumber and Gherkin
We got automatic parameterized tests by simply specifying how the step code is executed from the Gherkin files. This means that adding many...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found