All jobs / Full-stack developer / Testing
Full-stack developer interview question · 0–1 years
You built a feature that touches a React screen and two API endpoints. Which tests do you write, and where?
The strongest answer
Most of it in fast unit tests on both halves, a smaller layer of integration tests around the API and the database, and one or two end-to-end tests for the journey that must never break
Why it works
Right — many cheap tests, few slow ones, and the slow ones reserved for the journeys you cannot afford to break.
What a good answer covers
- Many fast tests, few slow ones.
- Unit-test the logic on both halves.
- Integrate where API meets database.
- End-to-end only the critical journey.
Answers that fall short
- Close, but not the strongest: Unit tests on both sides, plus an end-to-end test for every screen the feature touches
Good instinct, but the middle layer is missing, and an end-to-end test per screen becomes the slowest, flakiest suite you own. - Weak: End-to-end tests only — they run the real app, so they cover everything underneath
End-to-end tests are slow and fail for reasons unrelated to your change; they cannot tell you which unit broke. - Red flag: QA will test it after the merge; writing the tests is their part of the job
Handing your own verification to someone else tells an interviewer the code arrives unproven.
Who gets asked this
More Testing questions
- You are writing your first tests for a POST endpoint. What do you actually assert?
- How do you keep the real API out of a component test without the test drifting from the real thing?
- Do you test this against a real database or against a mocked repository?
- How do you test the parts that are not a request — an incoming webhook and a nightly job?
- Someone deleted a required field and merged because the unit tests still passed. What should CI do?
- The end-to-end suite passes alone and fails when it runs in parallel. What is wrong with the test data, and…
- How do you stop the API from breaking the UI in CI?
- Where should the end-to-end suite run in CI — against shared staging, or against a stack built for the run?