Running cucumberjs directly from a node

484 views
Skip to first unread message

Sam Hatoum

unread,
Oct 14, 2014, 9:56:38 AM10/14/14
to cu...@googlegroups.com
Hi

I'm trying to build a cucumber plugin for a Velocity (the Meteor test runner) and I would like to run individual tests directly from node. My goals are to:
  1. Run any one feature or group of features at a time
  2. Collect the results into a custom report
Can anyone tell me how to do this please?

My attempts so far are below.




If I run this from the command line:

cd node_modules/cucumber/bin
./cucumber.js /Users/sam/WebstormProjects/meteor-testing/velocity-example/tests/cucumber/features

It works and I get:

1 scenario (1 undefined)
3 steps (3 undefined)

However when I try to do this programmatically like this:

var Cucumber = Npm.require('cucumber');
var featuresDir = '/Users/sam/WebstormProjects/meteor-testing/velocity-example/tests/cucumber/features';
var configuration = Cucumber.Cli.Configuration([featuresDir]);

var runtime   = Cucumber.Runtime(configuration);
var formatter = configuration.getFormatter();
runtime.attachListener(formatter);
runtime.start(function() {
  console.log('runtime.start callback');
});

Cucumber cannot find the suite and the get the following error:

Error: ENOENT, no such file or directory '/Users/sam/WebstormProjects/meteor-testing/velocity-example/.meteor/local/build/programs/server/features'


Which tells me the featuresDir above is being completely ignored.

also tried to take the content of cucumber.js directly and pretend to pass in process.argv like so:

var Cucumber = Npm.require('cucumber');
process.argv = ['/Users/sam/WebstormProjects/meteor-testing/velocity-example/tests/cucumber/features'];
var cli = Cucumber.Cli(process.argv);
cli.run(function (succeeded) {
  var code = succeeded ? 0 : 1;

  process.on('exit', function () {
    process.exit(code);
  });

  var timeoutId = setTimeout(function () {
    console.error('Cucumber process timed out after waiting 60 seconds for the node.js event loop to empty.  There may be a resource leak.  Have all resources like database connections and network connections been closed properly?');
    process.exit(code);
  }, 60 * 1000);

  if (timeoutId.unref) {
    timeoutId.unref();
  }
  else {
    clearTimeout(timeoutId);
  }
});

and got the same error again.

Any one got any ideas?

Stephen Abrams

unread,
Oct 14, 2014, 10:23:29 AM10/14/14
to cu...@googlegroups.com
Hi Sam,

I haven't looked into this myself, but you may want to take a look at how the cucumber-grunt-js plugin is doing the exec:




--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sam Hatoum

unread,
Oct 14, 2014, 12:03:46 PM10/14/14
to cu...@googlegroups.com, abrams....@gmail.com
Magic!

Thank you very much sir
Reply all
Reply to author
Forward
0 new messages