RequestMock Constructor

Creates a request mocker.

RequestMock()

Use the requestMock.onRequestTo method followed by respond to define which request should be mocked and specify the responses. Then, attach the mock to a test or fixture.

import { RequestMock, Selector } from 'testcafe';

const mock = RequestMock()
    .onRequestTo(/google.com/)
    .respond('', 404);

fixture`RequestMock.constructor`
    .page`google.com`
    .requestHooks(mock);

test('Should mock requests', async t => {
    await t
        .expect(Selector('body').child().count).eql(0);
});