JEST Assignment- 4

Basic Questions

  1. Write a test that runs 5 test cases in parallel using Jest.
  2. Write a test that fails when two tests share a mock function (without clearAllMocks).
  3. Write a test that uses jest.clearAllMocks() to reset mock call counts.
  4. Write a test that uses jest.resetAllMocks() to reset mock implementations.
  5. Write a test that groups tests into multiple describe blocks for clarity.
  6. Write a test that dynamically imports a utility function using await import().
  7. Write a test that checks two modules do not leak mocks into each other.
  8. Write a test that verifies resetting mocks does not affect other test suites.
  9. Write a test that imports a dynamic module only inside a test case.
  10. Write a test for a React component wrapped in ErrorBoundary to show fallback on error.
  11. Write a test that throws an error inside a component and ensures fallback UI renders.
  12. Write a test that simulates a network error with Axios and checks “Error loading” message.
  13. Write a test that validates fallback UI is replaced when error is fixed.
  14. Write a test that triggers a timeout error in a promise and checks handling.
  15. Write a test that prints debug info using console.log inside a failing test.
  16. Write a test that runs with –detectOpenHandles and fixes an async leak.
  17. Write a test that simulates jsdom error (e.g., missing window.fetch) and mocks it.
  18. Write a test using debugger; statement in Jest test and ensure it halts.
  19. Write a test that runs with –runInBand and ensures sequential execution.
  20. Write a test that validates basic usage of Jest VSCode debugger (using debugger;).

 Intermediate Questions

  1. Write an integration test for a Redux reducer + React component that updates state on button click.
  2. Write an integration test for a Vuex store action updating component UI.
  3. Write an integration test where React component dispatches an async Redux action (API call).
  4. Write a test for combined components (Parent + Child) where child updates parent state.
  5. Write an integration test for a login flow (enter username, password → call API → show dashboard).
  6. Write an integration test that simulates API failure during login and shows error message.
  7. Write an integration test for an HTTP request + UI flow in Next.js API route.
  8. Write a test that checks end-to-end flow with Puppeteer visiting a login page.
  9. Write an E2E test with Puppeteer filling and submitting a form.
  10. Write an E2E test that mocks user navigation between two pages.
  11. Write an E2E test with Playwright that verifies button click updates DOM.
  12. Write an E2E test with Puppeteer mocking API response.
  13. Write an E2E test with Playwright simulating invalid form submission.
  14. Write an integration test for component + custom hook (useAuth) combined.
  15. Write a test for a fallback component that loads when API is down.
  16. Write a test that uses jest.spyOn(console, “error”) to silence React error boundary logs.
  17. Write an integration test for Express.js API + Mongoose model (mocked DB).
  18. Write a test that simulates retry on API failure with mocked responses.
  19. Write a test for a multi-step form component (Step 1 → Step 2 → Step 3).
  20. Write a test that uses Jest snapshots to capture combined component tree.

 Advanced Questions

  1. Write an E2E test with Puppeteer that logs into an app, navigates to profile, and verifies username.
  2. Write an E2E test with Playwright that uploads a file and checks success message.
  3. Write an integration test for Redux + API + UI where API success updates state + DOM.
  4. Write an integration test for Redux + API + UI where API error updates state + error DOM.
  5. Write an integration test for a React ErrorBoundary + Async API component combined.
  6. Write an E2E test with Puppeteer that simulates invalid login → shows “Invalid Credentials”.
  7. Write an E2E test with Playwright that simulates cart checkout flow (Add → Checkout → Success).
  8. Write an advanced test that uses jest.resetModules() to isolate imports across tests.
  9. Write a test that runs Jest with –detectOpenHandles and finds a hanging Promise, then fixes it.
  10. Write a hybrid test (Integration + E2E) where Playwright fills a form → submits → backend mocked with Jest → success UI rendered.