Testing
242 bites tagged Testing: interview questions with model answers, and 60-second explainers.
Test yourself: Top 30 Testing interview questions →Multiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.Testing a component that consumes React Context
Render inside the Context.Provider with a value, or omit it to exercise the default; use a custom render wrapper for reuse.
Layered testing strategy for a large RN app
Many fast Jest unit tests, fewer RNTL component tests on behavior, few Detox/Maestro E2E on critical flows.
Unit testing a custom hook with renderHook
Render the hook, read result.current, fire actions inside act, assert updated state.
RNTL or Detox for a navigation flow?
RNTL can test navigation logic by rendering the navigator in JS and asserting screen changes; Detox runs the real app for true end-to-end confidence including native transitions.
What does 'test behavior, not implementation' mean?
Query elements the way a user finds them (text, role, label) and assert observable behavior; for a Button, fire press and assert the visible effect, not internal state.
How do you test a component using a native module?
Native code is absent in the Node-based Jest environment, so you mock the module with jest.mock to return fake values, often via the library's provided jest mock.
How do you mock a fetch call in Jest tests?
Replace global fetch with a Jest mock or a library like jest-fetch-mock, return a resolved Promise with a fake Response, and reset mocks between tests.
Unit testing vs component testing in React Native
Unit tests verify isolated functions/logic with Jest; component tests render components and assert behavior with React Native Testing Library.
Testing a DB endpoint via dependency override
Use app.dependency_overrides to swap the real get_db for one yielding a test database session, run against a disposable SQLite or test Postgres, and assert through TestClient.
Unit testing Express auth middleware in isolation
Build fake req/res, use a spy/mock for next and res methods, assert next called on valid token and 401 sent on invalid.
Testing an async workflow that spans DB and message queue
Assert the DB row, then verify the queue message via a test consumer or spy, polling with a timeout rather than fixed sleeps.
Testing code that calls a third-party API
Intercept at the HTTP boundary (nock) or run a local mock server; cover success, errors, timeouts, and assert request shape.
Managing clean test state across API integration tests
Compare seed-and-truncate, per-test transaction rollback, and in-memory or containerized databases, weighing fidelity, speed, and isolation.
Testing async Promise-returning code in Jest
Return or await the promise; use await expect(...).resolves/rejects, or await the value directly.
Mocking the database layer in Jest unit tests
A live DB makes tests slow, flaky, and order-dependent; use jest.mock on the model so methods return controlled fakes.
Integration testing a POST endpoint with Supertest
Pass the Express app to supertest, send a POST with a body, then assert status 201, the response shape, and the persisted side effect; also test validation failures.
Writing a basic Jest unit test
Import the function, group cases with describe, define each case with it or test, assert with expect and a matcher like toBe, covering normal and edge inputs.
Unit, integration, and E2E tests explained
Unit tests isolate one function with dependencies mocked, integration tests exercise several units together (route plus DB), E2E tests drive the whole running system.
How does chaos engineering differ from other testing?
It experiments on real systems by injecting faults to test a steady-state hypothesis, versus verifying known behaviors like integration or load tests.
LitmusChaos
LitmusChaos is an open-source, Kubernetes-native chaos engineering platform that runs fault experiments as custom resources. It injects failures like pod kills, network latency, and resource stress to validate that services stay resilient under real-world…
Staging Environments for ML Pipelines
A staging environment mirrors production so models and pipelines are validated on production-like data and infrastructure before release. It catches drift, integration breaks, and serving regressions early, making promotion to production a safe, repeatable…
Bug report to deployed fix workflow
Triage and reproduce, write a failing test, fix it, pass CI gates and review, then patch-release and notify.
Building a visual regression testing pipeline
Snapshot Storybook stories per PR, freeze nondeterminism, set diff thresholds, manage baselines via approvals.
Storybook's role in design system infrastructure
Isolated development, living documentation, visual and interaction testing, shared review surface.
Get Testing bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.