特定のURLで行われたリクエストをインターセプトし、レスポンスをモックします。

使用方法

                    .mockNetworkResponse(urlToIntercept, {status, headers, body}, [callback])
                
                    .network.mockResponse(urlToIntercept, {status, headers, body}, [callback])
                

 describe('mock network response', function() {
   it('intercepts the request made to Google search and mocks its response', function() {
     browser
       .network.mockResponse('https://www.google.com/', {
         status: 200,
         headers: {
           'Content-Type': 'UTF-8'
         },
         body: 'Hello there!'
       })
       .navigateTo('https://www.google.com/')
       .pause(2000);
   });
 });

パラメータ

名前 説明
urlToIntercept 文字列

インターセプトしてレスポンスをモックするURL。

response オブジェクト

返すレスポンス。デフォルト: ` {status: 200, headers: {}, body: ''} `。

callback
オプション
関数

コマンドが終了したときに呼び出されるコールバック関数。