Do I need to learn JavaScript before Playwright?
Written by Jatin Thacker, Automation Architect · Updated
if and loops, and async/await are enough to start.This answer is one piece of Welcome.
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:
constandletfor values, and strings and numbers.- Objects and arrays, because test data and options are both.
- Functions, including arrow functions like
(item) => item.price. ifand loops, for decisions and for running a test over a list.asyncandawait, 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.
// 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`);
}Cart total: 16190 Halcyon Burr Grinder is over ten thousand
async and await from day one?Related questions
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