This is probably going to sound stupid to most people, but can I ask what the difference between
return Promise.all
and
Promise.all
is?
I don’t know whether I’m doing this wrong, but I have quite large userflows which I can’t really separate that much. For example, I need to go to a login page > login > navigate to another page within the app > fill out a form > submit > save > make a cup of tea > etc.
From what I understand, if I navigate to another page, or click an element with xk6, I need to properly script the promise that is returned? However, if I navigate to lots of different pages and click several elements, I therefore need to use several ‘return Promise.all’ but everything after my first return is unreachable code?
How does one correctly script multiple ‘return Promise.all’ without unreachable code?
Thanks for what I am sure is me just being an idiot.
You return promise.all to continue using .then, .catch, and so on.
Promise.all returns a promise. So you can use the returned promise to continue adding other promises to the chain. So you can wait for the promises in the chain and then do some other action.
Ah, there, we return from promise.All since we want to chain it to the finally block below. So we can close the page and browser when one of the promises in promise.All gets rejected or all are fulfilled. Otherwise, we would outrun the promises and close the page and browser earlier.
OK. So I think this is part of my confusion. When I’m logged in, I want to visit other pages within my web app. But it all goes wrong, and the browser closes immediately after the first screenshot is taken.
I just can’t see where I’m going wrong. But I’m guessing it’s relating to the return Promise.all and the finally block. But how then do you test going to multiple pages? Mimicking a user flow a bit more realistically.