timjroberts / cucumber-js-tsflow

Provides 'specflow' like bindings for Cucumber.js in TypeScript 1.7+.
MIT License
133 stars 34 forks source link

Support for `setDefaultTimeout`? #29

Closed KeithGillette closed 5 years ago

KeithGillette commented 7 years ago

Thanks for this very useful package, which we've found invaluable in implementing readable and maintainable CucumberJS tests.

Does cucumber-js-tsflow support global configuration of the timeout on asynchronous hooks and steps as with CucumberJS setDefaultTimeout or is the timeout only configurable on each step?

timjroberts commented 6 years ago

Currently it's only supported at each step if you go through cucumber-js-tsflow. However, all the decorators simply wrap around the CucumberJS library, so you should be able to mix calls to CucumberJS with the bindings that cucumber-js-tsflow provide. Putting the following lines into one of your files should do the same thing:

var {defineSupportCode} = require('cucumber');

defineSupportCode(function({setDefaultTimeout}) {
  setDefaultTimeout(60 * 1000);
});
KeithGillette commented 6 years ago

Thanks for the fast and helpful, reply, @timjroberts. Is there a recommended way to configure Cucumber under cucumber-js-tsflow to execute such setup calls before executing feature tests?

folterung commented 6 years ago

If there is a recommended way for configuration I would like to know as well. I currently have a project with protractor + typescript + cucumber-js-tsflow and I cannot figure out how to override the default timeout so everything times outs after 5000 milliseconds. Any insight would be appreciated.

@timjroberts @KeithGillette

edit: I was able to get this working by creating a file called cucumber.config.js, putting some code that I found on stack overflow into it (see below) and loading it with cucumberOpts.require:

const { defineSupportCode } = require('cucumber');
const cucumberOpts = require('./protractor-base-config');

defineSupportCode(({setDefaultTimeout}) => {
  console.info(`Setting default timeout to ${cucumberOpts.defaultTimeout / 1000}s.`);
  setDefaultTimeout(cucumberOpts.defaultTimeout);
});

It would definitely help if it was an option that you could set in the basic configuration.

ronlawrence3 commented 6 years ago

Hey @folterung did you do anything else but create this file and reference it in the protractor.conf.js in cucumberOpts.require? I'm not having any luck with that in a similar project.