This is how one of my intercept functions looks like now:
interceptWithError() {
nock(baseUrl)
.get(/.*/)
.replyWithError(500);
nock(baseUrl)
.put(/.*/)
.replyWithError(500);
nock(baseUrl)
.post(/.*/)
.replyWithError(500);
nock(baseUrl)
.delete(/.*/)
.replyWithError(500);
}
I would like to avoid repetition, and also give it more flexibility by doing something like this:
interceptWithError(params) {
const verb = params && params.verb;
const stat = params && params.stat;
return nock(baseUrl)
.[verb] // something like this!!!
.replyWithError(stat)
}
Is there a way to do so???