RequestMock Class

A request mocker that intercepts requests to a web resource and emulates the response.

Use the RequestMock constructor to create a mocker.

Call the onRequestTo and respond methods in a chain to specify mock responses for every handled request.

To use the mocker during tests, attach it to a test or fixture.

import { RequestMock } from 'testcafe';

var mock = RequestMock()
        name: 'John Hearts',
        position: 'CTO'
    .respond(null, 404);

fixture `My fixture`
    .page ``

test('My test', async t => { /* ... */ });