Front End Development Quality Control & Assurance 5 β Questions and Answers
Question 1: What does the `--ci` flag do when running Jest in a continuous integration environment?
- Enables interactive watch mode
- Disables snapshot updates and fails if new snapshots are written, ensuring no unreviewed changes pass (Correct answer)
- Parallelizes tests across all available CPU cores
- Skips slow test suites automatically
Correct answer: Disables snapshot updates and fails if new snapshots are written, ensuring no unreviewed changes pass
With --ci, Jest will fail rather than write new snapshots, preventing accidental snapshot creation from masking real failures in CI.
Question 2: A QA engineer notices that a button works correctly in Chrome but fails in Safari. Which testing practice would have caught this earlier?
- Increasing unit test coverage to 100%
- Cross-browser testing using tools like BrowserStack or Playwright's multi-browser support (Correct answer)
- Adding more snapshot tests
- Running load tests against the front end
Correct answer: Cross-browser testing using tools like BrowserStack or Playwright's multi-browser support
Cross-browser testing runs the same scenarios across multiple browsers and versions to catch engine-specific rendering or API differences.
Question 3: What is the purpose of a 'test double' in unit testing?
- Running the same test twice to confirm consistency
- A generic term for replacing a real dependency (stub, mock, spy, fake) to isolate the unit under test (Correct answer)
- A second developer who reviews test code
- Duplicating tests across multiple test files for safety
Correct answer: A generic term for replacing a real dependency (stub, mock, spy, fake) to isolate the unit under test
Test doubles (mocks, stubs, fakes, spies) replace real collaborators so tests focus on the unit's behavior without external side effects.
Question 4: In front-end performance QA, what does 'Time to Interactive (TTI)' measure?
- The time until the first byte arrives from the server
- The time until the page is fully interactive and reliably responds to user input (Correct answer)
- The total JavaScript execution time
- The time until all images are loaded
Correct answer: The time until the page is fully interactive and reliably responds to user input
TTI marks when the main thread is quiet enough and all critical scripts are loaded so the page can respond consistently to user interactions.
Question 5: Which technique allows a team to test a new feature with a subset of real users before full rollout, reducing QA risk?
- A/B testing with synthetic data
- Feature flags (feature toggles) enabling gradual rollout to a percentage of users (Correct answer)
- Blue-green deployment with snapshot rollback
- Shadow DOM isolation
Correct answer: Feature flags (feature toggles) enabling gradual rollout to a percentage of users
Feature flags let teams enable a feature for a controlled percentage of real users, limiting exposure while validating behavior in production.
Question 6: What is 'test-driven development' (TDD) and how does it impact front-end code quality?
- Writing tests after features are complete to document existing behavior
- Writing failing tests first, then writing the minimum code to make them pass, resulting in inherently testable design (Correct answer)
- Running tests only in the CI pipeline, not locally
- Using automated tools to generate tests from existing code
Correct answer: Writing failing tests first, then writing the minimum code to make them pass, resulting in inherently testable design
TDD's red-green-refactor cycle ensures code is designed with testability in mind from the start, reducing coupling and improving coverage.
Question 7: A Playwright test uses `expect(page).toHaveScreenshot()`. What will happen on the first run?
- The test fails immediately with no baseline
- A baseline screenshot is created and saved; the test passes on first run (Correct answer)
- The test skips and marks itself as pending
- The test throws a configuration error
Correct answer: A baseline screenshot is created and saved; the test passes on first run
On the first run, Playwright generates the baseline screenshot file; subsequent runs diff against it and fail if differences exceed the threshold.
What does the `--ci` flag do when running Jest in a continuous integration environment?