Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let scenarios be composable from other scenarios #29

Open
edconolly opened this issue Oct 29, 2015 · 4 comments
Open

Let scenarios be composable from other scenarios #29

edconolly opened this issue Oct 29, 2015 · 4 comments

Comments

@edconolly
Copy link
Contributor

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"
  ],
@chrisiconolly
Copy link
Contributor

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"
  ]

@edconolly
Copy link
Contributor Author

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?

@chrisiconolly
Copy link
Contributor

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"
    ]
  }

@nabil-boag
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants