Cannot Intercept Outgoing Ajax Request From Page Using Testcafe
I am attempting to use TestCafe for a client-side javascript library, and I am unable to capture any outgoing AJAX requests for on the load of a testing page through the counting m
Solution 1:
Thank you for your detailed description.
You need to attach the logger
to your test
/fixture
. You can also attach and detach hooks during test run using the t.addRequestHooks
and t.removeRequestHooks
methods.
In the test code, I attached the logger
hook to the test
:
import { RequestLogger } from"testcafe";
fixture`Hello World - Leaflet`.page`http://localhost:8080`;
const logger = RequestLogger(/org/);
test
.requestHooks(logger)
("Test if there's an outgoing network request...", async t => {
await t
.wait(5000)
.expect(logger.count(() =>true))
.gt(0, "Must detect more than zero outgoing requests to openstreetmap");
});
Post a Comment for "Cannot Intercept Outgoing Ajax Request From Page Using Testcafe"