RequestLogger Class

A request logger that stores the requests sent and responses received during test execution.

Use the RequestLogger constructor to create a logger.

Attach the logger to a test or fixture to enable logging.

You can access the log with the logger.requests property, or search for entries that satisfy a predicate with logger.contains and logger.count methods.

The logger.clear method removes all entries from the log.

import { RequestLogger } from 'testcafe';

const logger = RequestLogger();

fixture `My fixture`
    .page `http://example.com`
    .requestHooks(logger);

test('My test', async t => {
    await t
        .expect(logger.contains(record => record.response.statusCode === 200)).ok()
        .expect(logger.requests[0].method).eql('get');
});