TypeScript for Testing
Application-level TS to read/write/maintain a Playwright suite (async/await is the real gap). Unlocks the 13% TS-only roles. STOP before compiler-level type gymnastics.
- Node LTS + node/npm/npx mental model
Install Node LTS and know what node, npm, and npx each do without looking it up.
Screening/env-setup: 'walk me through setting up a Playwright TS project from zero' or a live 'npm init playwright@latest' run-through.
- package.json / scripts / node_modules / lockfile; npm i -D, npm run
Read package.json, add dev deps, and run/author npm scripts (the pip+venv+pyproject analog).
'How do you pin/install test deps?', 'what runs when someone types npm test?' — often a live repo walkthrough.
- ES modules — named + default import/export
Import/export symbols across files the way Playwright suites are structured.
Live coding: organize a suite into modules; 'default vs named export difference?'
- tsconfig.json essentials — strict, target, module, paths/baseUrl
Read a tsconfig and change the few knobs that matter, knowing Playwright only honors allowJs/baseUrl/paths/references.
'What does strict mode buy you?', 'how do import aliases work in your framework?'
- ESLint + Prettier — npm run lint, auto-format, CI fails on lint
Know professional repos lint+format automatically and CI blocks on lint errors.
'How do you keep code style consistent across the QA team?' (hygiene signal, rarely deep)
- tsc --noEmit as a separate type-check gate (pretest)
Run type-checking as its own CI step because Playwright runs tests even with type errors.
'Playwright ran my test even though it had a type error — why, and how do you enforce types?'
- Primitives, arrays, void, any + variable/param/return annotations
Annotate the 90% of everyday types you actually write in a suite.
Fundamentals (~25% of TS interviews): 'annotate this function', 'what is any and why avoid it?'
- interface / type for object shapes + union types
Declare the shape of test data and API payloads — the level POM + data factories use.
Fundamentals + live coding: 'model this JSON as a type', 'what's a union type?'
- interface vs type (extends, intersection &)
Give the crisp distinction that is near-guaranteed in a TS screen.
Near-guaranteed direct question: 'interface vs type — when do you use which?'
- any vs unknown
Explain why unknown is the safe alternative to any for untyped inputs.
Common screen: 'any vs unknown — which and why?'
- null/undefined, optional ?, non-null !, optional chaining ?., nullish ??
Handle absent values the way strict mode forces you to in real TS code.
Code review / live: 'this may be undefined — handle it', '? vs ! vs ?? difference?'
- enums / string-literal unions for roles, envs, tags
Constrain a value to a fixed set (roles, environments, test tags).
'enum vs string union?', 'how do you type environments?'
- Type narrowing / guards (typeof, in, custom is predicates)
Narrow a union to a concrete type so the compiler lets you use it.
Advanced chunk: 'how do you safely handle an unknown response?', 'what's a type guard?'
- Utility types (consumer) — Partial, Pick, Omit, Record, Required
Reuse existing types to build test-data variants without redefining shapes.
Type-system chunk (~35%): 'how would you build flexible test data?', 'name a utility type you've used.'
- Generics as consumer (Promise<T>, Array<T>, Locator, Record) + author one <T> helper
Read the generics Playwright ships and write ONE reusable typed helper — not generic-heavy libraries.
Expected direct question: 'what is a generic and when would you use one?' — answer + Promise<T>/helper example.
- Conditional/mapped/template-literal/infer types, decorators, declaration-file authoring, namespaces
Type-library / frontend-framework gymnastics an SDET-2 never needs to author.
If probed at all: a 'have you used X?' filter — a confident scoped 'no, here's why it's not needed for tests' is correct.
- Promise concept + Promise<T>
Understand that a Promise is a future value and Promise<T> types what it resolves to.
'What is a Promise?', 'what does Promise<void> mean on this method?'
- async function always returns a Promise; await
The #1 Python-to-TS gap: async/await syntax and that async fns wrap returns in a Promise.
Live coding + concept: 'why is this function async?', 'what does await do here?'
- try/catch around awaits (== Python try/except)
Handle errors from awaited calls the same way you use try/except in Python.
'How do you handle an expected failure/timeout in a test?'
- Every Playwright call must be awaited; missing-await = flaky/false-pass
The single highest-leverage async fact — turn the Python background into a strength by explaining WHY.
Near-guaranteed: 'what happens if you forget await?', 'why must every Playwright call be awaited?'
- Promise.all for parallel awaits; awaiting in loops
Run independent async work concurrently and avoid the classic loop-await bug.
'How would you speed up test setup with several independent async calls?', 'why doesn't await work inside forEach?'
- callbacks / .then() chaining as a primary style
Legacy async style you should recognize but not build on.
Rarely: 'convert this .then() chain to async/await.'
- test, test.describe, beforeEach/afterEach hooks
Structure a spec file with tests, groups, and setup/teardown hooks.
Live coding baseline: 'write a test with setup', 'where does login go?'
- playwright.config.ts — defineConfig, projects, use, baseURL, reporter, retries
Read and edit the config you touch constantly (browser matrix, env, reporting, retries).
'How do you run cross-browser?', 'where do baseURL/retries/workers live?' — capgemini explicitly probes config tuning.
- Page Object Model class — Locator fields in constructor, async methods : Promise<void>
The dominant framework pattern JDs demand: a typed POM class wrapping a page.
Very common live task: 'write a Page Object for this screen', 'how do you structure your framework?'
- Locators (getByRole/getByTestId/getByText) + web-first await expect assertions
Use modern role/testid locators and auto-retrying web-first assertions — the 2026 baseline, not CSS/XPath sleeps.
Heavy 2026 focus: 'locator strategy?', 'why getByRole over CSS?', 'how does auto-waiting remove sleeps?'
- Custom typed fixtures (extend base test)
Extend base test with typed fixtures (loginPage, apiContext) — the senior differentiator vs beginners who only use beforeEach.
Senior probe: 'fixtures vs beforeEach?', 'how do you share auth/page objects across tests type-safely?'
- API testing in TS — request / APIRequestContext, type the response, schema validation
Test REST APIs in the same TS suite and type/validate the responses — JDs pair UI(TS)+API.
'How do you test APIs in Playwright?', 'how do you validate a response schema?'
- Run in CI — GitHub Actions / Jenkins, HTML/blob reporter, sharding
Wire the TS suite into CI with reporting and parallel sharding — a frequent hard must-have.
Must-have: 'how do you run this in Jenkins/GitLab CI?', 'how do you shard/parallelize in CI?'
- mergeTests multi-fixture composition + fixture options
Compose multiple fixture sets declaratively — highest single leverage 'framework-owner' signal.
Architect-level: 'how do you compose fixtures across UI and API suites?'
- Network interception / route mocking (route, fulfill, abort) + API mocking
Intercept and stub network calls to make complex scenarios deterministic — a 2026 interview staple the checklist underweighted.
Common Playwright question: 'how do you mock an API response / test an error state without a real backend?'
- Auth state reuse — storageState / global setup
Log in once and reuse the session across hundreds of tests instead of re-logging-in — explicitly probed for senior SDETs in 2026.
Senior probe: 'how do you handle auth across a large suite without logging in every test?'
- Trace viewer / debugging (trace, --ui, retries+trace on failure)
Debug failures with the trace viewer — 2026 baseline; not knowing it reads as not knowing async in a backend interview.
'How do you debug a failing/flaky test?', 'what does the trace viewer show you?'
- Custom expect matchers / expect.extend
Author a reusable domain assertion — a senior/architect signal, name-drop level.
Senior probe: 'have you extended expect / built custom matchers?'
- Cypress in TS (alternative framework awareness)
Recognize that some TS UI roles use Cypress rather than Playwright.
'You've used Playwright — how does that transfer to Cypress?' on Cypress-shop roles.
- BDD / Cucumber with TypeScript
Recognize Cucumber/BDD-in-TS since several pool JDs list it as a plus or stack element.
'Have you used Cucumber/BDD?' — a fit filter on specific roles, not universal.
- React/DOM/JSX types, state-management typing, building/publishing typed npm packages, bundler/transpiler internals
Application-developer territory — you test the app, you don't build it, and Playwright transpiles for you.
Filter questions only; a confident scoped decline is the right answer for an SDET-2.