To test some Timeout cases in my front-end, I want to introduce an artificial delay in mirage while responding to some specific requests only and respond right away for all other cases.
i am writing Mirage scenario like this
export default function () {
this.post('/ebm-anp/api/v1/json/sessions', (schema, request) => {
const req = JSON.parse(request.requestBody);
if ((req.card.value === '12345678' || req.card.value === '12345678-encrypted-value') && req.password === 'abc') {
return new Response(200, {'X-Auth-Token': '2704412f-7820-4431-86c1-1234567800'}, successResponse);
}else if (..){
}
}
}
In this post, Introduce momentary delays in ember-cli-mirage Sam suggested to use {timing: 400}; with the call , which when used in my example looks like following.
export default function () {
this.post('/ebm-anp/api/v1/json/sessions', (schema, request) => {
const req = JSON.parse(request.requestBody);
if ((req.card.value === '12345678' || req.card.value === '12345678-encrypted-value') && req.password === 'abc') {
return new Response(200, {'X-Auth-Token': '2704412f-7820-4431-86c1-1234567800'}, successResponse);
}else if (..){
}
},{timing: 400};
}
This basically introduces the delay in the calls for all testcases that hit this endpoint - which does not serve my purpose.
Is there someway i could refactor my Mirage setup so that i can setup the timing(delay) configuration only for some cases and leave it normal for all others.
Aucun commentaire:
Enregistrer un commentaire