Currently there is a "pain point" when defining fixtures: All fixtures
responding to the same request have to redefined its url, and there is no a clear mechanism to identify how many of them correspond to a single url. You can know the total amount of fixtures you have defined (in the CLI, for example), but you can't know how many single routes are you listening to.
As a proposal, fixtures should be renamed into routes
, which I consider can be clearer, and should have a variants
property, which should contain all possible responses for the same url, as in:
{
"id":"get-users",
"url":"/api/users",
"method":"GET",
"variants":[
{
"id":"empty",
"response":{
"status":200,
"body":[
]
}
},
{
"id":"error",
"response":{
"status":500,
"body":{
"message":"Internal server error"
}
}
}
]
}
Then, behaviors
(which could be renamed into mocks
for more clarity), should be defined as in:
[
{
"id": "base",
"routes": ["get-users:success"]
},
{
"id": "users-error",
"from": "base",
"routes": ["get-users:error"]
}
]
Routes and variants could also include a handler
property which should decide the routesHandler
to use when loading it, as in:
{
"id":"get-users",
"url":"/api/users",
"method":"GET",
"variants":[
{
"id":"empty",
"response":{
"status":200,
"body":[]
}
},
{
"id":"real",
"handler": "proxy",
"redirect": "http://localhost:8080/users"
}
]
}