Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in nodejs example #668

Closed
iamnogada opened this issue Nov 4, 2016 · 10 comments
Closed

Error in nodejs example #668

iamnogada opened this issue Nov 4, 2016 · 10 comments

Comments

@iamnogada
Copy link

Error message : TypeError: Cannot read property 'execute' of undefined
after "Step Definition: features\support\step_definitions\browser_steps.js:5
Message:"

I tried the sample code in 'https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md'

I have an error
OS; Windows 7
Node: 6.9.1
package used:
"devDependencies": {
"chromedriver": "^2.25.1",
"cucumber": "^1.3.1",
"selenium-webdriver": "^3.0.0"
}

command in rum : cucumber-js
other command(cucumber, cucumber.js) came out javascript error.

@vishysank
Copy link

👍 getting the same issue

@anatoliyarkhipov
Copy link

I spent some time trying to solve this problem and found this package:
https://www.npmjs.com/package/nightwatch-cucumber

It integrates CucumberJS with Nightwatch. If you already use Nightwatch then the package will just work after adding a few lines to the config. If not, you can try to set up Nightwatch first using its docs, they are pretty simple.

@coco-gsd
Copy link

@anatoliyarkhipov Anatoliy, you mentioned "...adding a few lines to the config" in your comment, could you please share some details about that? Thanks!

@shimaore
Copy link

features/support/world.js should read:

var webdriver = require('selenium-webdriver');

function CustomWorld() {
  this.driver = new webdriver.Builder()
    .forBrowser('chrome')
    .build();
}

module.exports = function() {
  this.World = CustomWorld;
};

I suspect the selenium-driver API might have changed since the example was written; the code above uses the example in the npm README.

@anatoliyarkhipov
Copy link

@coco-gsd it's step 4 from the docs:

// nightwatch.conf.js

require('nightwatch-cucumber')({
  nightwatchClientAsParameter: true,
  /* other configuration options */
})

module.exports = {
  ...
}

module.exports - it's your Nightwatch config, and the lines above it's what you need to add.

https://www.npmjs.com/package/nightwatch-cucumber#step-4

@Souji-Asapu
Copy link

Hi I am trying to generate cucumber-html-reports in nightwatchJS, declared code in Afterfeatures like below code but getting an error saying reporter not find. Someone please help me resolving this ASAP

please see the hooks code and error as well:

const {client} = require('nightwatch-cucumber');
const {defineSupportCode} = require('cucumber');
registerHandler('AfterFeatures', function(features, callback) {

  var options = {
  theme: 'bootstrap',
  jsonFile: './reports/cucumber.json',
  output: './reports/',
  reportSuiteAsScenarios: true,
  launchReport: true,
  metadata: {
      "App Version":"0.3.2",
      "Test Environment": "STAGING",
      "Browser": "Chrome  54.0.2840.98",
      "Platform": "Windows 10",
      "Parallel": "Scenarios",
      "Executed": "Remote"
  }

};

reporter.generate(options);
callback();
});

ERROR:

VError: a handler errored, process exiting: hooks.js:38: reporter is not defined
at /Users/sowjanya/nightwatch-test-framework/node_modules/cucumber/lib/runtime/event_broadcaster.js:78:21
at next (native)
at undefined.tryCatcher (/Users/sowjanya/nightwatch-test-framework/node_modules/bluebird/js/release/util.js:16:23)
at PromiseSpawn._promiseFulfilled (/Users/sowjanya/nightwatch-test-framework/node_modules/bluebird/js/release/generators.js:97:49)
at Promise._settlePromise (/Users/sowjanya/nightwatch-test-framework/node_modules/bluebird/js/release/promise.js:574:26)

@charlierudolph
Copy link
Member

charlierudolph commented Mar 17, 2017

The error message says reporter is not defined. In your code sample you have the line reporter.generate(options); and it doesn't appear that reporter is defined.

@Souji-Asapu
Copy link

Hi @charlierudolph .. Thanks yaar, I have done a very silly mistake, Do u have any in detail sample framework on nightwatchJS please? (I am using nightwatchJS-0.9.13, "nightwatch-cucumber": "^7.0.12", "cucumber": "2.0.0-rc.8", "cucumber-html-reporter": "^0.3.7",)

@charlierudolph
Copy link
Member

Nope. Nighwatch is a separate project and one I have never used. Please ask for that over on the nightwatch-cucumber repo.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants