Support more than three stages
There should be a way of dynamically add additional stages to a scenario so that one is not limited to three stages
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.
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.
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:
- to inject additional stages in the test class
- 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.