msilori
msilori

Reputation: 39

Testcafe: How to ignore the failed xhr requests on the page that we are trying to test

While running testcafe, I could see an xhr request failing in the background and may be that is why I could not see the UI elements of the page getting loaded. I could see only one element loaded.

If I try to access the same webpage without testcafe, I could see the page elements loading normal although the xhr request is still failing in the background.

Could this failing xhr request be a reason for the page not showing all the UI elements when I do it through testcafe?

Is there a way to ignore some xhr requests like this in testcafe ?

Upvotes: 0

Views: 81

Answers (1)

Alexey Popov
Alexey Popov

Reputation: 1047

To mock any request you can use RequestMock. For example:

const mock = RequestMock()
    .onRequestTo('http://xhr-request/')
    .respond('Mocked respond');

However, it may not resolve the problem. If it doesn't help, please, share a minimal working example with this template following this instruction.

Upvotes: 1

Related Questions