Skip to content

McKinsey & Company Playwright Testing Interview Questions & Answers

Curated interview practice questions with answers. These are practice scenarios, not a verified list of past interview questions.

About McKinsey & Company hiring for Playwright Testing roles

McKinsey & Company is a global management consulting firm that advises companies, governments and institutions on strategy, operations, technology and organisation. In India it has client service offices as well as large knowledge and capability centres that support consultants worldwide with research, analytics and digital work. It hires business analysts, research analysts, data scientists and software engineers in India.

For Playwright Testing roles, this McKinsey & Company practice set focuses most on Network Mocking (7), API Testing (7), Visual & Accessibility Testing (5), Playwright Core (3). It has 5 easy, 29 medium, 6 hard questions, so you can start easy and work up to the harder ones.

Company type
Consulting
Headquarters
New York, USA
Main India offices
Gurugram, Mumbai, Bengaluru, Chennai

McKinsey & Company Playwright Testing interview process

  1. Online problem-solving assessment or game-based test
  2. Case interview round 1
  3. Case interview round 2 with personal experience questions
  4. Final partner round

Typical pattern based on public candidate experiences. Rounds vary by role, team and year.

Solved for McKinsey & CompanyStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
3 questions free Unlock the rest in seconds
01

How do you mock one GraphQL query when all calls go to /graphql?

Save to ▾
Show answer
await page.route('**/graphql', async route => { const body = route.request().postDataJSON(); if (body.operationName === 'GetCart') { return route.fulfill({ json: { data: { cart: { items: [] } } } }); } return route.fallback(); });
02

An API returns 200 but the body contains an error field. How should your test catch this?

Save to ▾
Show answer
Never trust status alone. Assert the body structure, for example that error is absent and data has the expected fields, ideally with a schema check. Report the issue, because returning 200 for errors breaks clients and monitoring. Add a helper that validates both status and body shape so every test checks it consistently.
03

How do you perform drag and drop and hover?

Save to ▾
Show answer
locator.hover() and locator.dragTo(target) perform these actions, with auto-waiting for actionability.
04

How do you test file upload via API?

Save to ▾
Show answer
Use request.post with multipart: { file: { name, mimeType, buffer } } and assert the response and stored file details.
05

What is the difference between a type and an enum in TypeScript?

Save to ▾
Show answer
A type alias describes a shape or union of values; an enum creates a named set of constants that exists at runtime.
06

When should you choose a component test over an end-to-end test?

Save to ▾
Show answer
Choose a component test when the behaviour lives inside one component: validation messages, disabled states, sorting in a table, keyboard handling in a dropdown or rendering of edge-case data. These are slow and awkward to reach through full flows. Choose end-to-end when the risk is in integration, such as routing, authentication or data saved on the server.
07

How do you test that the app retries a request that failed the first time?

Save to ▾
Show answer
Register a route with a counter: on the first call use route.fulfill with status 503, and on later calls fulfil with a success body. Perform the action, then assert the UI shows the final data and the counter equals 2. You can also check that no error message flashed. This proves the retry logic works without waiting for a real outage.
08

Why are screenshot baselines specific to browser and operating system?

Save to ▾
Show answer
Each browser engine lays out and paints text, shadows and form controls slightly differently, and each operating system has its own fonts and smoothing. A Chromium image on Linux will rarely match WebKit on macOS pixel for pixel. That is why Playwright includes project and platform in the file name and why teams fix one rendering environment for baselines.
09

How do you handle dialogs such as alerts?

Save to ▾
Show answer
Register page.on('dialog', d => d.accept()) before the action triggers the dialog.
10

What does the Pick locator tool do?

Save to ▾
Show answer
In the Inspector, UI mode and the VS Code extension, Pick locator lets you hover over any element on the page and see the locator Playwright recommends for it, usually a role or label based one. You can copy it into your test. It is a fast way to write locators and to check whether an existing one is unique.
11

How do you attach axe results to the Playwright HTML report?

Save to ▾
Show answer
test('cart is accessible', async ({ page }, testInfo) => { await page.goto('/cart'); const results = await new AxeBuilder({ page }).analyze(); await testInfo.attach('axe-results', { body: JSON.stringify(results.violations, null, 2), contentType: 'application/json', }); expect(results.violations).toEqual([]); });
12

How do you fail a test if the page logs any console error?

Save to ▾
Show answer
test('no console errors', async ({ page }) => { const errors: string[] = []; page.on('console', m => { if (m.type() === 'error') errors.push(m.text()); }); page.on('pageerror', e => errors.push(e.message)); await page.goto('/dashboard'); expect(errors).toEqual([]); });
13

How do you mock network requests?

Save to ▾
Show answer
page.route('**/api/items', route => route.fulfill({ json: [...] })) intercepts and replies with test data; route.abort() simulates failures.
14

What does the JSON reporter output and how would you use it?

Save to ▾
Show answer
The JSON reporter writes the full suite tree with every test, its status, retries, duration, errors and attachment paths into one file. Teams parse it in scripts to post a summary to chat, to collect flaky tests that passed on retry, or to push results to a database for trends. Set outputFile so the JSON does not mix with console output.
15

What does maxFailures do?

Save to ▾
Show answer
maxFailures stops the run after a set number of test failures, for example maxFailures: process.env.CI ? 10 : undefined. If an environment is down and every test fails, the build stops early instead of burning an hour of CI time. Set it high enough that a few real failures still show their full picture.
16

A setup fixture creates expensive test data and suite time has doubled. How do you redesign it?

Save to ▾
Show answer
Measure first with the report timings. Then create data through the API instead of the UI, move read-only shared data into a worker-scoped fixture, and seed common reference data once in a setup project. Keep per-test data only for things a test changes. Cache login with storageState. This usually cuts setup time sharply without losing isolation.
17

How do you handle token refresh in long API test runs?

Save to ▾
Show answer
Fetch tokens in a fixture with expiry tracking and refresh it when it is about to expire, keeping tests unaware of the details.
18

A fixture mocks every /api call, but one test needs a different response for /api/cart. How do you override it?

Save to ▾
Show answer
Register a new page.route for /api/cart inside that test. Handlers run in reverse order of registration, so the newer one runs first. Fulfil the cart request with the special data, and for anything else call route.fallback() so the request moves on to the fixture's general handler. This keeps the shared mock untouched and makes the override local and easy to read.
19

Visual tests pass on developers' laptops but fail in CI with tiny font differences. Why, and how do you fix it?

Save to ▾
Show answer
Font rendering, anti-aliasing and installed fonts differ between Windows, macOS and Linux, so the same page produces slightly different pixels. The fix is to generate and compare baselines in one fixed environment, usually the official Playwright Docker image used in CI. Developers update baselines by running that container locally or through a CI job, not from their own machines. Loosening thresholds should be the last resort.
20

How do you set baseURL and common headers for API tests?

Save to ▾
Show answer
Put them in the use block of playwright.config: use: { baseURL: process.env.API_URL, extraHTTPHeaders: { Accept: 'application/json', Authorization: `Bearer ${process.env.TOKEN}` } }. The request fixture then sends them on every call, and tests use short paths like /api/users. Keep tokens in environment variables, never in the repository.
21

How do you handle secrets such as passwords and tokens in CI?

Save to ▾
Show answer
Store them in the CI system's secret store and pass them as environment variables, never in the repository or config files. Read them through process.env and fail fast if they are missing. Use dedicated test accounts with limited rights. Avoid printing them in logs, and make sure traces and screenshots do not expose them in reports.
22

How do you keep API tests independent of environment data?

Save to ▾
Show answer
Do not depend on records that happen to exist in a shared environment. Each test or fixture creates what it needs through the API and cleans up after. Read environment-specific values such as base URL and credentials from config. For reference data that must exist, seed it in a setup project and verify it before tests run.
23

How do you validate response headers?

Save to ▾
Show answer
Use response.headers() for an object of lower-cased header names, or headersArray() for duplicates. Assert content-type contains application/json, cache-control matches the policy, and security headers such as strict-transport-security are present. Also check that sensitive headers like server version are not exposed. Header checks catch configuration bugs that body checks miss.
24

Component and end-to-end tests run together and slow down every commit. How do you separate them?

Save to ▾
Show answer
Give them separate configs, such as playwright-ct.config.ts with its own testDir for component specs and playwright.config.ts for end-to-end tests, because component tests also need the bundler options and framework test import. In CI, run component tests on every commit as a fast job and end-to-end tests later or in parallel. Shared settings like reporters can live in a common module both configs import.
25
Save to ▾
Show answer
A function that remembers variables from its outer scope even after that scope has finished. They are used for private state and factory helpers.
26

Describe a time you improved how test results were reported to the team or managers.

Save to ▾
Show answer
Situation: managers only heard pass or fail and could not tell flaky tests from real bugs. Task: make results useful. Action: I added a custom reporter that posted a short summary to our team chat with failures, flaky tests and a report link, and a weekly trend of flake rate. Result: flaky tests dropped by half in two months because owners could see them.
27

How do you test geolocation, permissions and time zones?

Save to ▾
Show answer
Set them in the context options (geolocation, permissions, timezoneId, locale) to simulate users from other regions.
28

How do you handle shadow DOM?

Save to ▾
Show answer
Playwright locators pierce open shadow roots by default, so getByRole and CSS locators work without special handling.
29

How do you mock network traffic using a HAR file?

Save to ▾
Show answer
Record once with page.routeFromHAR('data/orders.har', { url: '**/api/**', update: true }) while running against a real server. Later runs replay the saved responses from the HAR instead of hitting the backend. You can edit the stored JSON to create edge cases. Re-record when the API changes, otherwise the replay drifts from reality.
30

How do you combine fixtures from several files with mergeTests?

Save to ▾
Show answer
When teams define fixtures in separate modules, such as dbTest and a11yTest, mergeTests(dbTest, a11yTest) returns one test object that has all their fixtures. mergeExpects does the same for custom matchers. This keeps fixture modules small and owned by different people. Watch for name clashes, because two modules defining the same fixture name will conflict.
31

What do toHaveAccessibleName and toHaveAccessibleDescription check?

Save to ▾
Show answer
They assert the name and description that assistive technology computes for an element, using the accessibility tree rather than raw attributes. The name may come from a label, aria-label, aria-labelledby or inner text, and the description often from aria-describedby. For example an icon-only close button should have the name Close. These checks catch problems that a plain text assertion would miss.
32

What does the failOnStatusCode option do?

Save to ▾
Show answer
By default Playwright API calls do not throw on error statuses, you check them yourself. Setting failOnStatusCode: true on a request or context makes it throw for any status other than 2xx or 3xx. It is useful in setup helpers, where any failure should stop the test immediately with a clear message, instead of continuing with bad data.
33

What is the Playwright Inspector and how do you open it?

Save to ▾
Show answer
The Inspector is a debug window that lets you step through test actions one by one, see the locator being used and highlight it on the page. Open it with npx playwright test --debug, with PWDEBUG=1, or by calling page.pause(). It runs headed with no timeout, so you can explore the page at each step and edit locators live.
34

What is the difference between ES modules and CommonJS?

Save to ▾
Show answer
ES modules use import and export and are the modern standard, loaded statically. CommonJS uses require and module.exports and is the older Node.js style. Playwright supports both, and TypeScript test projects usually write import syntax. Mixing them causes errors such as require is not defined, so set type in package.json and tsconfig consistently.
35

What is the difference between getByText and getByLabel?

Save to ▾
Show answer
getByText matches visible text anywhere on the page, so it suits paragraphs, links and messages. getByLabel finds a form control through its associated label element, aria-label or aria-labelledby, so it is the right choice for inputs such as Email or Password. Using getByLabel for inputs also checks that labels are wired correctly, which getByText cannot do.
36

Baselines are always rendered in Docker, yet the repo has separate Windows and Linux image files. How do you keep one baseline per browser?

Save to ▾
Show answer
The default file name includes the platform, so a developer who updated baselines on Windows created a second set. Set snapshotPathTemplate in the config without the {platform} token, for example '{testDir}/__screenshots__/{testFilePath}/{arg}-{projectName}{ext}', delete the stray files and only update baselines through the Docker command or a CI job. Document the rule so it does not happen again.
37

How do you change part of a real API response?

Save to ▾
Show answer
await page.route('**/api/profile', async route => { const response = await route.fetch(); const json = await response.json(); json.plan = 'premium'; await route.fulfill({ response, json }); }); await page.goto('/account'); await expect(page.getByText('Premium plan')).toBeVisible();
38

How do you block images and fonts to speed up tests?

Save to ▾
Show answer
await page.route(/\.(png|jpe?g|webp|woff2?)$/, route => route.abort()); // or by resource type await page.route('**/*', route => route.request().resourceType() === 'image' ? route.abort() : route.continue() );
39

How do you publish the Playwright HTML report from a CI pipeline?

Save to ▾
Show answer
Keep the html reporter in the config. After the test step, add an upload-artifact step that runs even when tests fail, using a condition like always(), and upload the playwright-report folder with a retention period. Team members download and open it with npx playwright show-report. Some teams also publish it to static hosting for direct links.
40

Why does Playwright start a new worker after a test fails?

Save to ▾
Show answer
A failed test may leave the browser or worker-scoped fixtures in a bad state, such as an open dialog or corrupted login. To protect the remaining tests, Playwright throws that worker away and starts a fresh one for the next tests. This means worker fixtures run again and beforeAll hooks may run more than once, which is normal and something your setup must tolerate.

Tips to crack the McKinsey & Company Playwright Testing interview

  • Practise structured case interviews out loud, focusing on breaking problems into clear parts and doing quick mental arithmetic accurately.
  • Prepare detailed personal stories on leadership, impact and handling conflict, since McKinsey asks probing follow-up questions on each story.
  • For analytics roles, revise SQL, Python and statistics along with case skills, because both are often tested together.
  • Keep a one-minute story ready for every project on your CV: problem, your part, tools, result.
  • Practise the hard questions on this page aloud; McKinsey & Company interviewers usually ask follow-ups on your first answer.

Frequently asked questions

How many rounds are there in the McKinsey & Company Playwright Testing interview?

Candidates usually go through 4 stages: Online problem-solving assessment or game-based test; Case interview round 1; Case interview round 2 with personal experience questions; Final partner round. The exact rounds change with the role, team, location and your experience, so confirm the process with the recruiter.

Which topics should I prepare for the McKinsey & Company Playwright Testing interview?

This practice set leans on Network Mocking (7), API Testing (7), Visual & Accessibility Testing (5), Playwright Core (3). Revise those first, then practise explaining one or two of your own projects end to end, because most McKinsey & Company interviewers ask you to walk through real work.

Are these the exact questions asked at McKinsey & Company?

No. These are curated practice questions that match the skills and difficulty usually tested in consulting interviews like McKinsey & Company's. They are not a leaked or verified list of past questions.

Where does McKinsey & Company hire Playwright Testing professionals in India?

McKinsey & Company has large teams in Gurugram, Mumbai, Bengaluru, Chennai. Openings and locations change often, so check the McKinsey & Company careers page and filter by city and experience.

Playwright Testing questions for similar companies