selenium-cucumber-js icon indicating copy to clipboard operation
selenium-cucumber-js copied to clipboard

Error with execution after just updating cucumber to latest version(4.2.1)

Open tigerdhana017 opened this issue 7 years ago • 6 comments

Hi,

I tried to run this project with just updating cucumber version to latest(4.2.1). But I've caught an error below:

My-MAC:selenium-cucumber-js fbb$node index.js /Users/fbb/Frameworks/cucumber-test8/selenium-cucumber-js/node_modules/babel-runtime/helpers/classCallCheck.js:7 throw new TypeError("Cannot call a class as a function"); ^

TypeError: Cannot call a class as a function at exports.default (/Users/fbb/Frameworks/cucumber-test8/selenium-cucumber-js/node_modules/babel-runtime/helpers/classCallCheck.js:7:11) at Object.Cli (/Users/fbb/Frameworks/cucumber-test8/selenium-cucumber-js/node_modules/cucumber/lib/cli/index.js:78:34) at Object. (/Users/fbb/Frameworks/cucumber-test8/selenium-cucumber-js/index.js:128:28) at Module._compile (internal/modules/cjs/loader.js:702:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10) at Module.load (internal/modules/cjs/loader.js:612:32) at tryModuleLoad (internal/modules/cjs/loader.js:551:12) at Function.Module._load (internal/modules/cjs/loader.js:543:3) at Function.Module.runMain (internal/modules/cjs/loader.js:744:10) at startup (internal/bootstrap/node.js:238:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

Kindly let me know what am I doing wrong here.

tigerdhana017 avatar Jun 04 '18 06:06 tigerdhana017

I think that the new version of cucumber requires a huge refactoring of the project :|

In the next days I will try to update the version and will change the whole code to es6 (I need a new cucumber version and es6 for an internal project used by my company), but I don't think that the owner of the project will be happy :P

kbytesys avatar Aug 31 '18 16:08 kbytesys

Why would you change the codebase to es6?

john-doherty avatar Aug 31 '18 17:08 john-doherty

Because the latest cucumber-js release uses es6 and you need to refactor index.js and world.js in order to use that library. We can't mix es5 and es6 because eslint will scream to us and run in circle 😄

BTW this could make the implementation of the helpers, steps, etc... much simpler:

Look to your example at "step-definitions/google-search-steps.js", you can write it in this way with es6:

    this.Then(/^I should see some results$/, () =>
        driver.wait(until.elementsLocated(by.css('div.g')), 10000)
            .then(() => driver.findElements(by.css('div.g')))
            .then((elements) => expect(elements.length).to.not.equal(0))
    );

kbytesys avatar Aug 31 '18 20:08 kbytesys

If that's true, it'll impact everyone using the project and all the tests/page objects they've created. I'll be honest, I'm not convinced it's necessary

john-doherty avatar Aug 31 '18 22:08 john-doherty

When I am trying to upgrade to newer version from index file getting some error. Its not related to es5/6. Its related to Cli. Would you be able to help me on this.

srutikritee avatar Aug 18 '19 06:08 srutikritee

I've made changes to selenium-cucumber-js to make it compatible with Cucumber-js v6.0. There were a lot of braking changes :/ and upgrade is not backwards compatible.

To get it work you need to:

  1. Upgrade all step-definitions to use new sytax (remove this and module.export). Both features and page-objects should work fine.
  2. Unfortunately require-dir no longer support camel-case - you need to change folder name to camelCase to keep it working.
  3. I've changed command to selenium-cucumber-es6.

Repository: https://github.com/dcmarti/selenium-cucumber-es6 Comments are welcome.

dcmarti avatar Apr 02 '20 21:04 dcmarti