QuizzesTesting Async Behaviour and the Network — Concept Check
intermediate
react

Testing Async Behaviour and the Network — Concept Check

Questions on Testing Async Behaviour and the Network. Mock at the network boundary with MSW so your real fetching code runs. Then test the states everyone forgets: error, empty, and slow.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Testing Async Behaviour and the Network — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A test is failing because it hangs indefinitely during an HTTP request. What might be the cause?

    • AThe test environment lacks necessary data.
    • BThe server is not running at all.
    • CThe network connection is too slow.
    • DAn unmocked request is being made and not handled by MSW.
  2. 2.During a test, a submit button remains disabled after a form submission attempt. What is likely happening?

    • AThe form validation failed, keeping the button disabled.
    • BThe submission request is still in flight, disabling the button.
    • CThe button has a bug preventing it from re-enabling.
    • DThe server returned an error response.
  3. 3.A developer uses `getByText` for an async element and finds the test flaky. Why is this happening?

    • A`getByText` doesn't wait for elements to appear, causing flakiness.
    • BThe test environment is misconfigured.
    • CThe element is rendered conditionally.
    • DThe element is not present in the DOM.
  4. 4.What is a best practice when testing network requests with MSW?

    • AUse arbitrary sleep to simulate network delay.
    • BIntercept HTTP requests to allow real fetch code to run.
    • CMock the API module directly to simplify tests.
    • DAvoid testing error states to reduce complexity.
  5. 5.A test suite using MSW is failing due to unhandled requests. What should be checked first?

    • ACheck if the network is properly configured.
    • BVerify the server is listening before tests run.
    • CConfirm the test data is correctly formatted.
    • DEnsure all necessary requests are mocked with handlers.
  6. 6.A test shows 'no problems yet' instead of a blank screen. What does this indicate?

    • AThe test correctly handles and displays an empty state.
    • BThe component is not rendering as expected.
    • CThe test is failing due to missing data.
    • DThe server is returning an error response.
  7. 7.In a test, an error message appears after a failed data fetch. What should happen next?

    • AThe test should automatically pass.
    • BThe error should be ignored.
    • CThe user should be able to retry the operation.
    • DThe application should crash.
  8. 8.Why is it important to test error, empty, and slow states in network requests?

    • AThey are common sources of bugs that aren't manually tested.
    • BThey are the easiest states to test.
    • CThey ensure the application never fails.
    • DThey simplify the test setup.