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


This Content is from Stack Overflow. Question asked by msilori

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 ?


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

const mock = RequestMock()
    .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.

This Question was asked in StackOverflow by msilori and Answered by Aleksey It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?