Testing
242 bites tagged Testing — interview questions with model answers, and 60-second explainers.
The role of Storybook in a design system
Storybook renders components in isolation across states, serving as living documentation, a development sandbox, and a base for visual and accessibility testing. understanding of component workbenches.
Automated visual regression testing for components
Render components in known states, capture screenshots, diff against approved baselines in CI, and require human review of differences. Catching unintended visual changes automatically.
Code coverage and its pitfalls
It measures executed lines, surfaces untested paths, and guides where to add tests. understanding coverage as a signal, not a goal. treating 100 percent as proof of correctness or writing assertion-free tests just to inflate…
Testing async code and completion handlers in XCTest
Create an expectation, fulfill it inside the completion handler, call wait with a timeout, or use async test methods. knowledge of waiting for asynchronous work in tests.
Unit test versus UI test in Xcode
Unit tests (XCTest) exercise code logic in-process and fast; UI tests (XCUITest) drive the app through the accessibility layer, slower and end-to-end. The scope and tooling difference between test types.
Test Plans (XCTestPlan)
A Test Plan is an Xcode configuration file decoupling which tests run from how they run, letting one scheme execute many configurations: localizations, sanitizers, randomized order, and repetition, all without editing the scheme.
Criterion: the standard Rust benchmarking library
Criterion runs on stable Rust, collects many samples, applies statistical analysis with confidence intervals, and compares against saved baselines to detect regressions. ecosystem awareness and rigor about measurement.
Testing a tap that triggers a SnackBar
PumpWidget the app, find the button, tester.tap it, call pump or pumpAndSettle to advance frames, then expect a SnackBar finder. widget-test interaction flow. forgetting to pump after the tap so the SnackBar never appears.
Automated a11y testing in CI and its limits
Axe-core in unit and story tests, fail the build on violations, plus manual screen-reader and keyboard testing. building a11y checks into CI while knowing their ceiling.
How do you speed up slow integration tests without compromising quality?
Tests your ability to optimize CI/CD pipelines while preserving coverage. A strong answer covers parallel execution, Test Impact Analysis, ephemeral containers, and test data as code. Red flag: proposing to delete tests or disable integration stage entirely.
What does shift left mean in CI/CD, and give two concrete examples?
Your grasp of moving verification earlier to reduce cost and risk. Define shift left as earlier-stage testing; cite two concrete examples like pre-commit unit tests and PR-level SAST scans. Never call it "more testing" instead of earlier feedback.
How would you unit-test a Svelte date utility with Vitest?
This question tests isolating pure logic from Svelte and configuring Vitest. A good answer covers installing Vitest, co-locating a spec file, and asserting known inputs. A red flag is insisting you must mount a Svelte component to test a plain function.
How would you diagnose and optimize slow Angular component tests?
Tests Angular test economics and runner overhead. Strong answers profile with Vitest, swap Karma for jsdom/happy-dom, mock services, and reduce TestBed recompilation via targeted imports.
Describe the role of a spy in testing with a framework example
This tests whether you know a spy records calls without replacing original implementation. A strong answer defines the tracking role, picks a concrete Vue or Angular handler, and asserts with toHaveBeenCalled.
How do you mock an async service call in an Angular component test?
This tests Angular unit isolation and HTTP mocking. A strong answer covers HttpTestingController setup, flushing a mock response, asserting UI changes, and notes mocking avoids flaky networks. Red flag: using real HTTP calls in unit tests.
How do you test emitted events using Vue Test Utils?
Tests Vue Test Utils event inspection. Strong answer: mount, trigger('click'), then check wrapper.emitted('increment') for the payload array. Remember it returns an array of arrays, one per emission.
What is Angular's TestBed and when would you use it?
Say createComponent returns a fixture with no immediate binding, so await fixture.whenStable before asserting DOM. Your knowledge of TestBed as the component factory and change-detection controller.
What is the fundamental difference between unit and component tests?
Isolation levels in frontend testing. Unit tests verify single functions or composables with mocked dependencies; component tests verify mounting, rendering, and interaction and pull in more code. Claiming it is only the tool.
Testing SvelteKit load Functions
A SvelteKit load function consumes a request event and returns page data. Unit test it by mocking the event object in Vitest, not by mounting the page. Never test it through component rendering, because load runs before the component initializes.
Localization Testing Validates Regional Adaptation
Localization testing verifies that regional adaptation accounts for differences in distinct markets. It validates the second phase of internationalization and localization, catching the assumption that translation alone is enough.
i18n Testing: Check Scripts, Not Just Strings
i18n testing checks your product works across languages, scripts, and cultures before shipping. It catches rendering and layout failures in Arabic, Hebrew, Chinese, Japanese, or Korean contexts.
MSW vs mocking fetch or axios directly in Jest tests
MSW intercepts HTTP via Service Workers and Node, staying client-agnostic; direct fetch or axios mocks couple tests to specific libraries. Network interception vs function stubbing. Calling MSW a Jest-only utility.
How do you balance unit, integration, and end-to-end tests in Next.js?
This tests allocation of test types across Next.js boundaries. Propose 70 percent unit tests for utilities, 20 percent integration tests for data fetching, and 10 percent end-to-end tests for critical flows, weighing cost and confidence.
Difference between jest.fn, jest.spyOn, and jest.mock in React
Tests whether you distinguish Jest's three mocking scopes. Good answers: jest.fn for standalone callbacks; jest.spyOn to observe existing methods; jest.mock to swap entire modules. Red flag: using them interchangeably or saying spyOn replaces modules.
Get Testing bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.