Intercept the request made on a particular URL and mock the response.

Usage

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

Example

Or run locally with:
git clone https://github.com/nightwatchjs/nightwatch-examples.git
cd nightwatch-examples
npm install
npx nightwatch tests/api/mockNetworkResponse.js

Parameters

Name Type description
urlToIntercept string

URL to intercept and mock the response from.

response object

Response to return. Defaults: {status: 200, headers: {}, body: ''}.

callback
Optional
function

Callback function to be called when the command finishes.

Recommended content