docs.. mock responses API example
This commit is contained in:
@ -101,12 +101,14 @@ function mockResponses (route, targets) {
|
||||
}
|
||||
|
||||
if (target) {
|
||||
debug('target response: %j', target.response)
|
||||
debug('target response: %s', target.response)
|
||||
if (t.isFunction(target.response)) {
|
||||
const pathMatches = ctx.url.match(pathRe).slice(1)
|
||||
target.response.apply(null, [ctx].concat(pathMatches))
|
||||
} else {
|
||||
} else if (t.isPlainObject(target.response)) {
|
||||
Object.assign(ctx.response, target.response)
|
||||
} else {
|
||||
throw new Error(`Invalid response: ${JSON.stringify(target.response)}`)
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user