← Back to Tutorials

23. Interview Prep (75 mins JavaScript Q&A)

JavaScript Core

  1. What is the difference between let, const, and var?
    var has function scope, let and const have block scope. const cannot be reassigned.
  2. Explain closures with an example.
    A closure is a function that remembers its outer variables even after the outer function returns.
  3. What is the event loop?
    The event loop handles async operations. Callbacks/microtasks (Promise) go to microtask queue; setTimeout/IO go to macrotask queue.
  4. What does this refer to in different contexts?
    In a method: the object. In a function (non-strict): global. In arrow function: lexical scope.

Playwright-Specific

  1. How does Playwright auto-wait work?
    Playwright waits for elements to be visible, enabled, and stable before actions. No explicit wait needed.
  2. What are the advantages of getByRole over CSS selectors?
    Accessibility-first, more resilient to DOM changes, better error messages, matches user perception.
  3. Explain browser contexts.
    Isolated browser sessions with separate storage, cookies, and cache. Each context is like a separate incognito window.
  4. How would you test a file download?
    Use page.waitForEvent('download') and download.saveAs().
  5. What is the difference between page.route() and page.waitForResponse()?
    route() intercepts and modifies requests. waitForResponse() waits for a specific response to complete.
  6. How do you run tests in parallel?
    Set fullyParallel: true in config or test.describe.configure({ mode: 'parallel' }).

SDET & Automation

  1. What is the Page Object Model?
    A design pattern that encapsulates page-specific elements and actions in classes for maintainability.
  2. How do you handle dynamic content?
    Use waitForSelector, waitForURL, or assertions with auto-retrying (toBeVisible).
  3. How do you set up CI for Playwright?
    GitHub Actions with matrix strategy across browsers. Install with --with-deps flag.
  4. What is visual testing and when would you use it?
    Comparing screenshots pixel-by-pixel. Useful for UI regression, cross-browser consistency, responsive layout checks.
  5. Explain retries and flaky tests.
    Retries re-run failed tests. Flaky tests pass intermittently — fix root cause rather than relying on retries.
✏️ Exercise: Practice answering all 15 questions aloud within 75 minutes. Write a Playwright test for the scenario described in question 8 (file download).