var myHooks = function () { this.Before(function(callback) { // Just like inside step definitions, "this" is set to a World instance. // It's actually the same instance the current scenario step definitions // will receive. // Let's say we have a bunch of "maintenance" methods available on our World // instance, we can fire some to prepare the application for the next // scenario: this.bootFullTextSearchServer(); this.createSomeUsers(); // Don't forget to tell Cucumber when you're done: callback(); }); }; module.exports = myHooks;
You can access the scenario currently being run by adding a parameter to your function:
this.Before(function (scenario, callback) { console.log(scenario.getName(), "(" + scenario.getUri() + ":" + scenario.getLine() + ")"); callback(); });
See Cucumber.Ast.Scenario for more information about the scenario object.
cheers
this.Before(function(scenario, callback){
console.log('now before scenario. world is',this,', scenario is ', scenario,', callback is ',callback);
Yes, I thought of that myself, but, as I wrote, my Before function is being passed only the callback parameter.
Here's my code:this.Before(function(scenario, callback){
console.log('now before scenario. world is',this,', scenario is ', scenario,', callback is ',callback);
And the output is:
now before scenario. world is {
takeScreenShot: [Function],
getSingleValueDatatable: [Function],
expectMultipleMembers: [Function] } , scenario is function () {
iterate();
} , callback is undefined
So that means that only the callback parameter is being passed.
I'm using cucumberjs 0.4.0
--
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.
On Tue, May 27, 2014 at 1:44 PM, Jhonny E. <jhonny....@sisense.com> wrote:
Yes, I thought of that myself, but, as I wrote, my Before function is being passed only the callback parameter.
Here's my code:this.Before(function(scenario, callback){
console.log('now before scenario. world is',this,', scenario is ', scenario,', callback is ',callback);
And the output is:
now before scenario. world is {
takeScreenShot: [Function],
getSingleValueDatatable: [Function],
expectMultipleMembers: [Function] } , scenario is function () {
iterate();
} , callback is undefined
So that means that only the callback parameter is being passed.
I'm using cucumberjs 0.4.0I tried and could access the scenario object in a before hook:Are you 100% sure you're running 0.4.0?
On Tuesday, May 27, 2014 11:45:13 PM UTC+3, Julien Biezemans wrote:On Tue, May 27, 2014 at 1:44 PM, Jhonny E. <jhonny....@sisense.com> wrote:
Yes, I thought of that myself, but, as I wrote, my Before function is being passed only the callback parameter.
Here's my code:this.Before(function(scenario, callback){
console.log('now before scenario. world is',this,', scenario is ', scenario,', callback is ',callback);
And the output is:
now before scenario. world is {
takeScreenShot: [Function],
getSingleValueDatatable: [Function],
expectMultipleMembers: [Function] } , scenario is function () {
iterate();
} , callback is undefined
So that means that only the callback parameter is being passed.
I'm using cucumberjs 0.4.0I tried and could access the scenario object in a before hook:Are you 100% sure you're running 0.4.0?
I was sure, but I was wrong. On closer inspection it turned out I had 0.3.3 globally installed :(.
Anyway, with 0.4.0 it works well.
Thanks for that, and for all the great work on cucumberJS.