Understanding Frontend Testing
Which statement best describes frontend testing in the context of a web application that renders forms, buttons, and dynamic content?
- It verifies that the user interface and client-side behavior work as intended across interactions and states.
- It compiles backend services into machine code for faster execution.
- It replaces design decisions such as color choices with automated algorithms.
- It encrypts all traffic between client and server by default.
- It stores user data in a scalable database.
Why It Matters
Why is frontend testing important for delivering a reliable user experience, for example when a user submits a form and expects a confirmation message?
- It helps catch UI bugs before users see them, increasing confidence and reducing costly regressions.
- It guarantees zero defects regardless of code changes.
- It eliminates the need for manual exploratory testing.
- It primarily reduces server hosting costs.
- It automatically writes product requirements.
Unit Testing Focus
Which type of frontend test is most appropriate for verifying that a date-formatting function returns '01/02/2025' when given a specific input?
- Unit testing
- End-to-end testing
- Load testting
- Visual regression testing
- Usabiliity review
End-to-End Scenario
Which scenario is an example of an end-to-end frontend test for an online shop?
- A test that simulates a user logging in, adding an item to the cart, and completing checkout.
- A test that checks whether a helper function trims whitespace.
- A linter that enforces code style rules.
- A stress test that measures server CPU usage.
- A build step that minifies images.
Accessibility Goals
What does accessibility testing aim to ensure in a page with forms, links, and buttons?
- That users can navigate via keyboard, labels are descriptive, and color contrast meets guidelines.
- That all images are compressed to the smallest possible size.
- That the database schema is normalized to third normal form.
- That every page uses a single font family for consistency.
- That server logs rotate on a fixed schedule.
Visual Regression
What is the main purpose of visual regression testing after a CSS change adjusts spacing and colors?
- To detect unintended changes in the appearance of the user interface by comparing renderings.
- To ensure API endpoints return the correct JSON payload.
- To verify that code is formatted according to style guides.
- To measure network bandwidth usage over time.
- To test cryptographic key rotation policies.
Interaction and State
When testing that clicking a 'Submit' button shows a spinner and disables the button until a response arrives, what aspect of frontend behavior is being verified?
- User interaction handling and UI state updates
- Database sharding strategy
- Operating system package management
- Ethernet cable integrity
- Static code analyzis
Mocks and Stubs
In a frontend test for a search component, what is the purpose of using a mock or stub for the network request?
- To simulate predictable responses without calling a real backend, making the test fast and reliable.
- To increase the bundle size so caching is tested thoroughly.
- To automatically improve the app's search engine ranking.
- To inject real ads for realistic revenue testing.
- To disable all error handling paths at runtime.
Flaky Tests
Which situation commonly causes flaky frontend tests when verifying a modal opens after an animation?
- Tests rely on real network timing or arbitrary timeouts instead of waiting for UI conditions.
- Tests run on a developer's machine at the same time every day.
- Tests render static HTML with no dynamic content.
- Tests use a consistent, pinned dependency version.
- Tests avoid any asynchronous operations.
Cross-Browser Coverage
What is the goal of cross-browser frontend testing for a responsive site viewed on different devices?
- To ensure the interface behaves and looks consistent across supported browsers and screen sizes.
- To rename all CSS classes to shorter identifiers.
- To measure the server's disk input/output speed.
- To remove all vendor prefixes from styles.
- To compress audio files used in the site.