Skip to contentPlayForge

Do I need to learn JavaScript before Playwright?

Written by Jatin Thacker, Automation Architect · Updated

Yes, the basics, because every Playwright test you write or review is JavaScript. You do not need the whole language: variables, objects and arrays, functions, if and loops, and async/await are enough to start.

A tester who cannot read the language cannot tell a good test from one that only looks good. That matters more now that AI tools write tests: reviewing them is reading JavaScript. This is why the course teaches JavaScript first, in Act I, before Playwright points those instructions at a browser.

The list that is enough to start:

  • const and let for values, and strings and numbers.
  • Objects and arrays, because test data and options are both.
  • Functions, including arrow functions like (item) => item.price.
  • if and loops, for decisions and for running a test over a list.
  • async and await, because every Playwright action returns a Promise; MDN puts it plainly: "Async functions always return a promise."
  • import, to bring in Playwright and your own files.

The example uses each of these, with no browser at all. It builds a cart from two objects, totals it with reduce and an arrow function, prints it with a template literal, and awaits an async function. If you can read every line of it, you can read your first Playwright test. Classes can come next, when you reach page objects.

js-basics.mjs
// The JavaScript a first Playwright test leans on, with no browser involved. const product = { name: 'Halcyon Burr Grinder', price: 11900 }; // const and an object const cart = [product, { name: 'Aurora Pour-Over Kettle', price: 4290 }]; // an array const total = cart.reduce((sum, item) => sum + item.price, 0); // an arrow function console.log(`Cart total: ${total}`); // a template literal // async and await: every Playwright action returns a Promise like this one. const loadPrice = async (item) => item.price; const price = await loadPrice(product); if (price > 10000) { console.log(`${product.name} is over ten thousand`); }
Output
Cart total: 16190
Halcyon Burr Grinder is over ten thousand
Test yourself
Why does a Playwright tester need async and await from day one?

AI can write the test now. The job is knowing whether it checks anything. That's what the course teaches, one chapter at a time.

163 lessons · 226 drills · start free

← All questions

Training a team? Talk to us.