.network.mockResponse() 編集を提案する
追加されたバージョン: 2.2.0特定の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 オプション |
関数 | コマンドが終了したときに呼び出されるコールバック関数。 |