Skip to content
QSWEQB

Node.js & TypeScript interview questions

Server-side JavaScript depth, where nearly every question eventually reduces to understanding the event loop and the type system.

10 published across 5 topics.

Node.js and TypeScript fundamentals57 short answers on one page, for revising rather than studying.

Event Loop & Async

2 questions

Phases, microtasks versus macrotasks, blocking the loop, and streams and backpressure.

mediumConcept

Walk me through the phases of the Node event loop.

The loop cycles through timers, pending callbacks, poll, check and close phases; after every callback Node drains nextTick then promise microtasks, so nextTick beats promises and both beat any phase callback. setImmediate precedes the next timers phase only when scheduled inside a loop callback.

4 minmid, senior, staff

Node Runtime & Modules

2 questions

CommonJS versus ESM, worker threads, clustering, buffers, and process and memory limits.

Express & NestJS

2 questions

Middleware ordering, error handling, DI in Nest, and structuring a service beyond a single file.

TypeScript for Services

2 questions

Structural typing, generics, narrowing, and modelling domain constraints in the type system.

Testing & Tooling

2 questions

Jest and Vitest, mocking modules, build and bundling choices, and monorepo workflows.

mediumConceptDesign

How do you test a Node service, and what do you refuse to mock?

Drive business logic through injected dependencies rather than module mocks, intercept at the process boundary for outbound HTTP and time, and use a real database in a container for anything where the database is the logic — SQL, constraints, transactions and migrations.

5 minmid, senior, staff
mediumConceptCodingDesign

How do you test a service that calls a third-party API, without calling it?

Substitute at the network layer or behind your own client interface, not at the HTTP library's function. Stubbing the library couples the test to how you make the call rather than to what you send, so the test keeps passing through refactors that change the request and breaks on refactors that change nothing.

4 minmid, senior