Skip to content
SDETRole
SDETRole

Interview questions / Languages

JavaScript Interview Questions

JavaScript questions for SDETs focus on the parts that bite automation code: async behaviour, closures, equality and data manipulation.

6 questions · 2 beginner· 3 intermediate· 1 advanced

beginner questions

intermediate questions

advanced questions

Why JavaScript questions matter for SDETs

Playwright, Cypress, WebdriverIO and most API test tools in the Node.js ecosystem are written in JavaScript or TypeScript, so JavaScript interview questions for testers focus on the parts of the language that break test code. Interviewers are less interested in trivia than in whether you will write a test that silently skips an await, compares objects with ===, or leaks state between tests through a shared variable.

The topics that come up most

  • Async await interview questions: why await inside forEach does not wait and how the event loop orders synchronous code, microtasks (promise callbacks) and macrotasks (timers).
  • JavaScript promises interview questions: Promise.all vs allSettled, race and any. Promise.all rejects on the first failure, which suits setup steps that must all succeed; allSettled suits cleanup, where you want every attempt to run.
  • Closures and var, let and const: scope bugs, counters and factories in test helpers.
  • Equality: === compares object references, so two identical API payloads are not equal; tests need deep equality such as toEqual.

A worked example: a retry helper

A common live-coding task is "write a retry with exponential backoff". A good answer is short and handles the edge cases: retry only a bounded number of times, wait baseMs * 2 ** attempt between tries (optionally with jitter), and rethrow the last error so the test fails with a useful message. In code: for (let attempt = 0; attempt < retries; attempt++) { try { return await fn(); } catch (e) { lastError = e; await sleep(baseMs * 2 ** attempt); } } throw lastError;. Expect a follow-up: retries can hide real defects, so in a test suite they belong around known-unstable infrastructure, not around assertions. See the retry with backoff model answer.

What interviewers listen for in your code

  • Every promise is awaited or returned. A missing await before an assertion can let a test finish before the check runs, so it passes without testing anything.
  • The right collection for the job: Set for uniqueness, Map for lookups by key, Array.prototype.reduce or Object.groupBy for grouping test results.
  • Edge cases stated out loud: empty arrays, null versus undefined, duplicate values and rejected promises.
  • Readable names and small functions. Test helpers are read far more often than they are written, and interviewers notice clarity.

Practise by running code

Reading answers is not enough for JavaScript. The JavaScript coding challenges run your code against real unit tests in a sandboxed worker, including event loop ordering, retrying a flaky call and implementing Promise.all. If you work in TypeScript, continue with the TypeScript interview questions.

Type to search across SDETRole.

Full-text search by Pagefind · runs in your browser Open search page →