The page I am testing makes a POST ajax request when clicking a button. I would like to test, if the parameters that are being sent in this request are correct. How would I go about that?
This is, what I tried:
import {RequestLogger, Selector} from '../../../node_modules/testcafe';
const requestUrl = 'http://localhost:8080/mypage/posttarget';
const logger = RequestLogger({url: requestUrl, method: 'post'}, {logRequestBody: true, logRequestHeaders: true});
fixture `Notifications`.page('http://localhost:8080/mypage')
.requestHooks(logger);
test('notification request contains id', async t => {
await t
.click('#submit-notification')
.expect(logger.request.body.id)
.eql(1)
;
});
But logger.request is undefined. Also logger.requests.length is 0.
I would appreciate it, if someone could show me how I can check the request body?