Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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)})}}]}]}}

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp