cortexmg / nightwatch-xhr

An XHR "Listener" for Nightwatch.js
MIT License
28 stars 29 forks source link

Compatibility with nightwatch-cucumber #20

Open IvanNaumenko opened 6 years ago

IvanNaumenko commented 6 years ago

Hey guys! I downloaded your package and discovered it doesn't work with nigthwatch-cucumber....((

When I run them I got

Error while running waitForFirstXHR command: trigger should be a function

It would be great if you adept it with that framework

JalilArfaoui commented 6 years ago

Hello @IvanNaumenko

As a user of nightwatch-cucumber myself, I can say that both work together.

But you cannot use a trigger with BDD steps, since you have to write separate steps to start listenning for XHR, and then another step to get what has been listened.

I use :

Given some stuff
And browser listens for XHR
When some action that should trigger XHR
Then something that checks listened XHRs

where :

Given(/browser listens for XHR/, () =>
    client.listenXHR()
);

Then(/something that checks ("something") listened XHRs/, (something) =>
    client.getXHR(someUrlPattern, 2000, (xhrs => {
        assertSomethingWith(xhrs, something);
    }))
);
IvanNaumenko commented 6 years ago

Thanks! Works!

DmytroShtanko1 commented 6 years ago

Can you create some try project to demonstrate how it works correctly and share it on github?

DmytroShtanko1 commented 6 years ago

xhr It doesn't show any response code each time. wait 3sec

Pieras2 commented 4 years ago

xhr It doesn't show any response code each time. wait 3sec

Please look at https://github.com/cortexmg/nightwatch-xhr/issues/42 I had similar case and had to modify client.js in es5 folder. This might be due to the fact that there are multiple requests in background and last one finishes with 404.