[Cucumber] [JS]: Getting rid of the callback argument in cucumber-js step definitions

581 views
Skip to first unread message

l.de...@tarent.de

unread,
Apr 9, 2014, 3:39:37 AM4/9/14
to cu...@googlegroups.com
Hi Everyone,

as the subject line states suggests, I was looking for ways to get rid of the callback argument in step definitions.

The reason for this is that my step definitions most of the time are either synchronous or they use promises for handling asynchronous execution.
In both cases, handling the callback in the step definitions adds extra code and technical complexity but it doesn't help the reader to understand the domain.

On the other hand there *are* situations where I want to handle the callback explicitly in the step definition. I just don't like being forced to do it, if I think it does not belong there.

Looking at how other tools (e.g. jasmine-node) solved a similar problem, I came up with a solution that I think is really neat, and I would like hear your thoughts on it:


It is basically a wrapper around the original step definition body that works by the following rules:
- The body expects the same number of arguments as are provided by the call, i.e. the body expects a callback argument --> assume the step wants to explicitly deal callback
- The body returns something that looks like a promise --> wire it up with the callback
- The body (synchronously) raises an exception --> Big deal, fail the step.
- The body does nothing of the above --> Assume a passing, synchronous step.

Check it out and let me know what you think.

Cheers,
--lu

Julien Biezemans

unread,
Apr 10, 2014, 3:52:47 AM4/10/14
to cu...@googlegroups.com
Hi Iu,

I like it. I've been thinking about something similar (less awesome tbh, mainly focussed on promises). I'll give it a try and see how much it could be retrofitted into Cucumber.js itself.

BTW, to anyone interested: please share your thoughts/experiences/use cases.

cheers, 


Cheers,
--lu

--
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.



--
Julien.

Founder, Cucumber Ltd.

Alexander Zinchuk

unread,
Apr 19, 2015, 2:59:08 PM4/19/15
to cu...@googlegroups.com
Any progress on that? Would be a great implementation.

четверг, 10 апреля 2014 г., 10:52:47 UTC+3 пользователь Julien Biezemans написал:
Reply all
Reply to author
Forward
0 new messages