bruno777
bruno777

Reputation: 1896

Passing data from one step to another using screenplay ( e.g. When -> Then )

Using serenity-js, with cucumber and screenplay, i can't get to pass data from one step to another. E.g. : a "When" step defined by a pretty user.attempsTo() that simply calls a webservice, and a "Then" step that should simply checks the response of the webservice. "TakeNote" forgets the data of the previous step ( as i could see, even surprising) and "LastResponse" context might be lost also...

I guess there is a simple way to store an object (as a Question maybe) in one Activity of the "When" step, and get back this object in an Activity of the "Then" step.

Without Serenity, i would use a World object that is clearly a simple way to do the job, but i'm sure there a Serenity pretty way to do the trick.

Thank you.

Bruno

I tried to pass the object with LastResponse, with TakeNotes. But the object seems to be lost.

Upvotes: 0

Views: 139

Answers (1)

bruno777
bruno777

Reputation: 1896

I found what was wrong (answering to myself). user.attempsTo() is actually processed prior to the next step only if a resolution of the promise is asked, so if preceded by return, or await, or if it is declared as an implicit return using arrow function like this ( user :Actor) => attempsTo(...) ). Without the promise resolution, interactions are not executed in the described sequence, and this is really no good. The symptom for a bad code is that the interactions are not logged in their steps, but in step further. Hope this helps.

Upvotes: -1

Related Questions