jsGiven icon indicating copy to clipboard operation
jsGiven copied to clipboard

Support more than three stages

Open janschaefer opened this issue 9 years ago • 3 comments

There should be a way of dynamically add additional stages to a scenario so that one is not limited to three stages

janschaefer avatar Oct 01 '16 15:10 janschaefer

I'm not sure I exactly understand this. Do you mean being able to define multiple stages (because they have different concerns) and being able to use steps coming from those different stages ?

If yes, I think it's possible already using javascript mixins, and even benefit from type-safety by using type intersections in both flowtype & typescript.

flegall avatar Oct 01 '16 17:10 flegall

Ok. Maybe I have not completely understand your implementation. It seems that you could only use at most three stages in a single scenario. In JGiven you can have additional stages by injecting them into the test class using the @ScenarioStage annotation.

janschaefer avatar Oct 01 '16 18:10 janschaefer

The scenarios() method takes as second argument a StagesParam<G, W, T> : Which can either be a 3 class tuple or a Class<G & W & T> type StagesParam<G, W, T> = [Class<G>, Class<W>, Class<T>] | Class<G & W & T>;

That mean that you can pass either:

  • 3 different stages that gets returned when calling given(), when() or then() in scenarios
  • or a single stage that gets returned when calling any of these methods.

I understand now what you mean: @ScenarioStage can be used:

  1. to inject additional stages in the test class
  2. within stages to inject other stages.

It's nicer than using javascript mixins to merge stages.

So, it's not possible yet in jsgiven. Let's think of a solution now even if we don't implement it, because so far nobody uses jsgiven, therefore we can still make breaking changes to the core API.

flegall avatar Oct 02 '16 01:10 flegall