I recommend you check out https://github.com/wongatech/angular-multimocks. This allows you to create mock responses for your apis and allows you to switch between them in real time via the url in your app.
We originally created it where I work to solve this exact issue and it is now being used in multiple large tech companies in London.
You define each of your mocks like below, you can create multiple different response for a resource and then arrange them into scenarios. The file mockResources.json
defines the available scenarios and
describes which version of each resource should be used for each scenario.
Mock example:
{
"httpMethod": "GET",
"statusCode": 200,
"uri": "/customer/cart",
"response": {
"id": "foo"
}
}
Scenario Listing Example:
{
"_default": [
"root/_default.json",
"account/anonymous.json",
"orders/_default.json"
],
"loggedIn": [
"account/loggedIn.json"
]
}
It allows you to mock different rest verbs, different uris, add delays to responses (for either testing slow responses, or just too give you app a more live like feel).
It's a core part of our development and strongly integrated with our acceptance testing.
Checkout the demo @ http://tech.wonga.com/angular-multimocks, the project readme gives detailed instructions on setup happy to help with any further questions.