JEST Assignment- 5

Basic Questions

  1. Write a Jest test that verifies your GitHub Action runs tests on every push.
  2. Create a test that ensures CI fails if a single unit test fails.
  3. Add a Jest test command to package.json and run it in a simulated CI pipeline.
  4. Write a test that checks whether test results are generated as a report (–coverage).
  5. Simulate a GitHub Action that runs tests on PR (Pull Request) and validate failing PR.
  6. Write a sample workflow YAML for running Jest tests and test if workflow executes.
  7. Create a React component and use Jest to check render time is <100ms.
  8. Write a Jest test to measure performance of a function that sorts 10,000 items.
  9. Test if rendering <MyButton /> twice does not exceed a defined time threshold.
  10. Use jest-extended and test if an array contains only numbers.
  11. Write a Jest test using toBeEmpty matcher from jest-extended.
  12. Use jest-extended to check if an object has only specific keys.
  13. Write a Jest test that integrates with React Testing Library to check button click.
  14. Write a Jest test using Vue Test Utils to verify props are passed correctly.
  15. Write a Jest test with Storybook snapshot integration for <Card />.
  16. Write a test that ensures all .test.js files inside __tests__ folder run automatically.
  17. Organize a test folder with /unit, /integration, /e2e and run them separately.
  18. Write a Jest test for DRY principle: create a helper function and reuse it across tests.
  19. Simulate a flaky test (random timeout) and fix it with Jest stable mocks.
  20. Write a deterministic test for API fetch that always resolves the same result.

 Intermediate Questions

  1. Configure a GitHub Action YAML that runs Jest and generates coverage report.
  2. Write a test that uploads Jest coverage results as an artifact in CI.
  3. Write a test workflow that runs tests on Node v14, v16, and v18 in CI.
  4. Write a Jest test that checks component render performance using performance.now().
  5. Write a Jest test to profile 5 renders of <List /> component and compare results.
  6. Create a custom performance matcher toRenderUnder(time) and use it in Jest.
  7. Write a test with jest-extended that validates a string is a valid date.
  8. Write a Jest test with jest-extended for toBeWithinRange(1,10).
  9. Use React Testing Library with Jest to simulate form submit with validation.
  10. Use Vue Test Utils with Jest to test slot rendering.
  11. Write a test for Storybook visual regression using Jest snapshots.
  12. Simulate folder structure /tests/unit/ and /tests/integration/ and test isolated runs.
  13. Write a test that dynamically imports a module and checks execution.
  14. Use beforeEach and afterEach hooks to clean mocks across large test suite.
  15. Write a Jest test to ensure all test files follow .spec.js naming convention.
  16. Create a test that ensures at least one unit test, one integration test, and one E2E test exists in the project.
  17. Write a test that mocks API response to ensure deterministic results across test runs.
  18. Create a test to detect flaky test by re-running it 5 times and ensuring stable output.
  19. Write a test that retries on failure using Jest retryTimes.
  20. Write a test that ensures large dataset search (100k items) runs under 200ms.

 Advanced Questions

  1. Create a full GitHub Actions CI/CD pipeline YAML that installs dependencies, runs Jest, and deploys only if tests pass.
  2. Write a Jest test that triggers deployment failure if code coverage drops below 80%.
  3. Use Jest with –runInBand in CI and measure the impact vs parallel runs.
  4. Create a Jest test that benchmarks rendering performance of <Dashboard /> with 10,000 rows.
  5. Build a custom matcher in jest-extended to check if a MongoDB ObjectId is valid.
  6. Write a Jest integration test where React Testing Library simulates Redux state update.
  7. Write a Jest test with Vue Test Utils to simulate multiple event emitters in a component.
  8. Build a Storybook + Jest test that validates visual consistency of a ThemeSwitcher.
  9. Write a Jest utility that auto-generates test suites for all components in /src/components.
  10. Write a Jest test that identifies flaky API tests, retries with stable mocks, and logs failures in CI.