Thanks for watching! 🦝 You can find the source code on GitHub. 👇 If you have any questions or comments, let us know! github.com/checkly/playwright-examples/
Hello brother, could you please explain or make a video on when to use promise.all method and when not to. Like in this video you have used promise.all but what was the purpose of that ?
Promise.all is often used when you want to do multiple functions at once but will wait until all the methods encased within it are complete before proceeding. General playwright tests involve awaiting for each step as you often need the previous step to be complete before you continue. You may want to use promise.all when you can do a series of concurrent operations without effecting the test input/output. For example, when making breakfast you dont do one operation from start to finish at the same time. you may start the cooker, boil the kettle and retrieve the ingredients from the fridge. However you cannot begin cooking the breakfast until you have done those tasks so... Promise.all would contain the methods; startCooker(), boilKettle(), and retrieveIngredients() (as it doesnt matter when these methods finish as they do not rely on each other). once all these steps are done then 'await beginCooking()' method can begin. Hope this helps
I recommend looking into Promise Handling in JavaScript. In the video, an Array of string values is mapped into an Array of Promises (`getAttribute` in this case). JS Promises are async - we don't know when they resolve with a value (or reject with an error). So we have to wait until all these async operations finish. To access all the promise values, we then can call `Promise.all`, which takes an array of promises, waits for them to resolve, and returns an array of values. So, when writing Playwright (or JS) code, you should always check the data structures you're dealing with. Some are synchronous, while others will be async with promises.
Thanks for watching! 🦝
You can find the source code on GitHub. 👇
If you have any questions or comments, let us know!
github.com/checkly/playwright-examples/
Great video 👍🏻
Thanks 👍🦝
you are awesome mate :)
thanks!
sir please make a tutorial for playwright + cucumber
Heyoooo. I don't have any experience with cucumber so, unfortunately, it's very unlikely that we'll cover it here on the channel. :/
Hello brother, could you please explain or make a video on when to use promise.all method and when not to. Like in this video you have used promise.all but what was the purpose of that ?
Promise.all is often used when you want to do multiple functions at once but will wait until all the methods encased within it are complete before proceeding. General playwright tests involve awaiting for each step as you often need the previous step to be complete before you continue. You may want to use promise.all when you can do a series of concurrent operations without effecting the test input/output. For example, when making breakfast you dont do one operation from start to finish at the same time. you may start the cooker, boil the kettle and retrieve the ingredients from the fridge. However you cannot begin cooking the breakfast until you have done those tasks so... Promise.all would contain the methods; startCooker(), boilKettle(), and retrieveIngredients() (as it doesnt matter when these methods finish as they do not rely on each other). once all these steps are done then 'await beginCooking()' method can begin. Hope this helps
I recommend looking into Promise Handling in JavaScript. In the video, an Array of string values is mapped into an Array of Promises (`getAttribute` in this case). JS Promises are async - we don't know when they resolve with a value (or reject with an error). So we have to wait until all these async operations finish.
To access all the promise values, we then can call `Promise.all`, which takes an array of promises, waits for them to resolve, and returns an array of values.
So, when writing Playwright (or JS) code, you should always check the data structures you're dealing with. Some are synchronous, while others will be async with promises.