Testing & Quality Assurance Interview Questions (Node.js)
10 Testing & Quality Assurance questions from the Node.js track. Read each short answer here, then open a question for the full explanation, examples, common mistakes, and sources.
- Junior
How do you write robust unit tests for asynchronous functions and check for rejected promises in Node.js?
Make test functions async and use await with the functions under test; use assert.rejects to check promises that are expected to fail.
Read the full explanation - Junior
How do you use Supertest to test HTTP endpoints without binding the server to a real network port?
Pass an Express or Fastify app to supertest; it creates a lightweight server, sends simulated HTTP requests, and checks status codes, headers, and JSON content.
Read the full explanation - Mid-level
How do you isolate external services in integration tests with libraries such as nock or MSW?
These libraries intercept outgoing network calls (HTTP/HTTPS) inside Node.js and return predefined mock responses without making real internet connections.
Read the full explanation - Senior
What are the benefits of using Testcontainers to test real databases in Node.js projects?
It creates temporary, real Docker containers for databases (such as PostgreSQL or Redis) for the duration of the test, ensuring a test environment that matches production.
Read the full explanation - Senior
How do you test that operations remain correct under Race Conditions and balance conflicts?
Send multiple simultaneous requests with Promise.all to perform conflicting operations (such as booking the same seat or withdrawing a balance twice), and check that only one succeeds.
Read the full explanation - Senior
What is Contract Testing with Pact between Node.js microservices?
It checks that the API interfaces agree between a client (Consumer) and a provider (Provider), without running both services together in an integrated test environment.
Read the full explanation - Mid-level
What role do end-to-end (E2E) tests play in backend systems, and when are they useful?
They verify critical business scenarios across the assembled system (server, databases, job queues, and dependent services) from the perspective of a real client.
Read the full explanation - Mid-level
Why is 100% Code Coverage not sufficient evidence of test quality, and what is Mutation Testing?
Code coverage measures only whether lines ran, not whether Assertions are correct; Mutation Testing checks test strength by deliberately introducing small errors and ensuring tests fail.
Read the full explanation - Mid-level
How do you reliably test Streams and EventEmitters in Node.js tests?
Use events.once with promises to wait for specific events, or iterate through Streams with for await...of.
Read the full explanation - Senior
What causes Flaky Tests, and how do you make tests deterministic (Determinism)?
They may rely on unpredictable timing (random Timeouts), test order, the system clock, or leftover data; freeze time and clean the environment to address these causes.
Read the full explanation