Mock scenarios
For different tests it's often necessary to have different responses from the same request URI.
For example, you may want to check what will happen with your UI, if server returns:
- Empty products list
- Products list with/without need for pagination
- 404 Error
To do that, define several mocks for different scenarios. After, in tests, set active scenario to choose desired mock.
Define scenarios possible in two ways.
- through mock file location (for example, you have several recorded mocks in mocks directory, like
GET_products.empty.json
,GET_products.404.json
). - through scenariosMiddleware
Setting active scenario possible by 2 ways:
- By UI
- By API that available after applying controlMiddleware. To set active scenarios, use
PUT /${controlPath}/api/scenarios
.