angular-multimocks
angular-multimocks copied to clipboard
Let scenarios be composable from other scenarios
It would be great to have scenarios not just be made up of resources but other scenarios as well.
Maybe something like
"emptyShoppingCart": [
"extends": [
"fooScenario",
"barScenario"
]
"cart/noItems.json"
],
This makes a lot of sense - what should happen if fooScenario
and barScenario
contain conflicting resources?
eg: fooScenario
contains quote/error.json
and fooScenario
contains quote/slowResponse.json
If we choose the pattern that resources declared later are used it also allows you to extend a single scenario and just overwrite files directly
"emptyShoppingCart": [
"extends": [
"fooScenario"
]
"cart/noItems.json"
]
It still doesn't get around the problem, since I can still state quote/fastResponse.json
in my actual resource definitions also. Do we need a build time check?
You can use the same logic, the last conflicting mock in the definition is the one that gets used. So anything you explicitly declare will be used as a priority. Be interesting to see what Nabil thinks.
This feature however might mean the config of laying out mocks might have to go through a braking change to something more like
"userWithCreditHasEmptyCart": {
"extends": [
"someItems",
"userHasCredit"
],
"mocks": [
"cart/empty.json"
]
}
I think this is a great feature request, and one that is the natural next step for mocking.
We should try to add this functionality without breaking backwards compatibility, but if we find an elegant solution that breaks backwards compatibility, we are still a small project so we should go for it. As @chrisiconolly said, this might be worth bumping the project up to v 1.0 for!