Testing
242 bites tagged Testing — interview questions with model answers, and 60-second explainers.
How do CI and testing support the Scrum value of Commitment?
Tests if you can connect technical practices to business value. A great answer links CI/CD to the 'Definition of Done' and explains how automated tests de-risk the sprint commitment.
How would you refactor an inverted test pyramid?
This tests your ability to create a pragmatic, multi-sprint strategy for tech debt. A good answer includes analyzing the suite, quarantining flaky tests, enforcing new coverage standards, and incrementally refactoring. A red flag is proposing a total rewrite.
How would you introduce TDD to a team?
This tests your ability to influence a team and implement change pragmatically. A great answer outlines a gradual adoption: understand context, advocate with data, pilot on a new feature, then scale. A red flag is demanding a sudden, mandatory switch.
Describe the stages of a CI/CD pipeline for a containerized app
This tests your practical knowledge of automated software delivery and risk management. A strong answer outlines CI, build, test, and deploy stages, including container-specific steps like image scanning and quality gates like automated testing and…
Explain the Test Pyramid and its strategic use
Tests your grasp of balanced testing trade-offs. A good answer defines the Unit, Service, and UI layers, explains the cost/speed rationale, and applies it to a feature strategy. A red flag is describing the pyramid but not its strategic 'why'.
Describe the TDD Red-Green-Refactor cycle
This tests your grasp of TDD's core loop and its design implications. A good answer defines Red (failing test), Green (minimal code to pass), and Refactor (improve structure).
Testing NgRx Effects: Isolate and Verify Side Effects
Test NgRx Effects by treating them as pipelines that transform action streams. Provide a source action and mock dependencies to verify the effect dispatches the correct success or failure action.
Angular's TestBed: A Sandbox for Component Testing
Angular's TestBed creates a mini-app just for your test, letting you check how a component renders and behaves with mock dependencies. It's for testing component-template interactions in isolation.
Vitest Mocking: Isolating Code with `vi.mock`
Vitest's `vi.mock` replaces a module with a fake version, isolating your code for tests. This is key for preventing real network or database calls. The footgun: calls are "hoisted" to the top of the file, running before other code and breaking variable access.
Svelte Testing Library: Test Components Like a User
Test Svelte components like a user would use them. Svelte Testing Library interacts with the rendered DOM, not internal state, to verify behavior. This avoids brittle tests tied to implementation.
The Testing Trophy: Prioritize Integration Tests
The Testing Trophy flips the classic pyramid, arguing for "mostly integration tests" to maximize your return on investment. It's for UI apps where testing component interactions gives more confidence than isolated unit tests.
Unit Testing Vue Components with Vitest
Think of it as a two-part system: Vue Test Utils mounts your component in a virtual environment, and a runner like Vitest executes the test and reports pass/fail. Use this to verify a component's logic in isolation.
Angular Unit Testing: Jasmine & Karma
Jasmine is your testing script (`expect(a).toBe(b)`), while Karma is the stage that runs it in a browser. This is Angular's default stack for unit testing components and services to ensure they work in isolation.
Formative vs. Summative Evaluation: Improve vs. Judge
Formative evaluation improves a design in progress; summative evaluation judges a finished one. Use formative tests to find and fix flaws iteratively. Use summative tests to measure a shipped product against a benchmark, like a prior version or a competitor.
Heuristic Evaluation: An Expert UI Review on a Budget
Heuristic evaluation is like having an expert proofread your UI against a checklist of common usability flaws. It's a fast, cheap way to catch problems before writing code, but its value depends entirely on the evaluator's skill.
Usability Testing: Watch Real Users, Not Just Experts
Usability testing evaluates a product by observing real, first-time users interact with it, revealing flaws that designers often miss. It's used to validate design intuitiveness before launch.
Automating Next.js Builds and Deployments with CI/CD
CI/CD for Next.js is an automated assembly line for your app. It builds, tests, and deploys your code on every push, catching errors early. The biggest footgun is not caching build artifacts, resulting in slow, expensive pipelines.
cy.intercept: Control Network Traffic in Cypress Tests
cy.intercept acts like a programmable proxy in your Cypress tests, letting you watch, modify, or fake network requests. Use it to test loading states or error handling without a live backend. Footgun: intercepts are cleared before each test, not just once.
MSW: Mock APIs at the Network Layer
Mock Service Worker intercepts API calls at the network level using a Service Worker, so your app makes real requests. Use it for consistent mocking in development, testing, and Storybook.
Cypress for End-to-End Testing in Next.js
Cypress is a framework for end-to-end testing of Next.js applications. It's presented as a primary option in the official docs, alongside tools like Playwright and Vitest, for automating tests that simulate real user interactions in a browser.
Snapshot Testing: Lock In Your UI's Rendered Output
Snapshot testing catches unintended UI changes by comparing a component's rendered output to a saved 'golden' version. Use it to ensure UIs don't break during refactors. The biggest footgun is blindly updating snapshots, which can approve bugs as correct.
Handling Asynchronous UI with Testing Library
Your test shouldn't race your UI. Use async helpers to wait for elements to appear, disappear, or change after an event. This is crucial for testing components that fetch data. The footgun is forgetting `await` on `findBy` or `waitFor` calls.
Jest Mocks: Spies for Your Functions
A Jest mock is a spy that watches a function, recording calls without running the original logic. This lets you isolate code under test, verify interactions like callbacks, and control return values. The footgun is assuming mocks run real logic—they don't.
user-event vs. fireEvent: Testing Real User Interactions
user-event tests how users actually interact with your UI, not just isolated DOM events. It simulates a full action sequence, like a click firing pointerdown, mousedown, and click. Use it to test component behavior from a user's perspective.
Get Testing bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.