TestingDocs.com logoTestingDocs.com
Automation learning lab
TestingDocs • Self-paced course

Playwright Automation
Self Study Guide

Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.

60 chaptersBeginner friendlyHands-on practice
JavaScript / Chapter 21 of 60~12 min • Beginner
Chapter 21JavaScript

Promise.all and asynchronous workflows

Promise.all awaits a group of independent promises, preserving input order in its result array. It rejects if any input rejects. Sequential await is preferable for dependent actions such as filling a form and submitting it.

How it works

Step-by-step walkthrough

  1. Prepare independent promises
  2. Await their combined result
  3. Print both values

Example

JavaScript
async function run() {
  const results = await Promise.all([
    Promise.resolve('A'), Promise.resolve('B')
  ]);
  console.log(results);
}
run().catch(console.error);
Expected result: ['A', 'B']
💡 Point to remember
Do not parallelize browser actions that depend on each other.

✎ Your practice task

Change one promise to reject and handle it.

Knowledge check

Does Promise.all preserve input result order?

🌐 Continue learning