- Notifications
You must be signed in to change notification settings - Fork90
How to create an asynchronous mock response
Lloyd Brookes edited this pageJun 24, 2019 ·2 revisions
DEPRECATED. The --mocks option and lws-mock-response modules were removed in v3.
To make aresponse asynchronous, use a response function which returns aPromise which resolves when complete.
module.exports=MockBase=>classMyMockModuleextendsMockBase{mocks(options){return[{route:'/',responses:[{response:function(ctx){returnnewPromise((resolve,reject)=>{setTimeout(()=>{ctx.body='<h1>You waited 2s for this</h1>'resolve()},2000)})}}]}]}}