What is your testing strategy for a full-stack feature such as "invite a teammate by email"?
What the interviewer wants to hear
- Unit tests for pure logic such as validation and token rules
- Integration tests for API routes against a real test database
- Mock external services like email at the boundary
- A few end-to-end tests for the critical user journey
- Run tests in CI on every pull request and keep them fast and reliable
Model answer
I follow a testing pyramid or trophy shape. Unit tests cover the pure logic: email validation, invite token generation and expiry rules, and the permission check for who can invite. Most of my confidence comes from integration tests that call the real API route against a real PostgreSQL test database, for example in a Docker container in CI, checking that an invite row is created, duplicates are rejected and a viewer gets 403. External services like the email provider are mocked at the boundary, so I assert that an email was requested with the right link without sending one. Then I write one or two Playwright end-to-end tests for the main journey: admin sends an invite, the invitee opens the link and joins the team. Everything runs in CI on each pull request, and I fix flaky tests quickly rather than adding retries.
Can you answer it under time pressure?
Take a timed medium round and get scored on every answer.
More medium Full Stack Developer questions
- How would you implement login for a web app? Compare server sessions with JWT access tokens and explain what you would choose.
- Users say the orders page is slow. How do you find and fix the problem across frontend, API and database?
- How would you build a feature that lets users upload profile photos and PDF documents up to 100 MB?
- Your API is used by a web app and an older mobile app that users do not update quickly. How do you make a breaking change safely?
- Describe a good CI/CD pipeline for a full stack app. What runs on each pull request and how do you deploy safely?
- You need to build a product search page with text search, filters and sorting. Walk through the design from the UI to the database.
- How would you add role-based access control (admin, editor, viewer) to an existing full-stack app?
- Describe the different layers where you can cache in a typical full-stack web app, and how you keep cached data correct.
- You need to show in-app notifications in real time. How do you choose between polling, server-sent events and WebSockets, and how would you build it?