JEST Assignment- 5
Basic Questions
- Write a Jest test that verifies your GitHub Action runs tests on every push.
- Create a test that ensures CI fails if a single unit test fails.
- Add a Jest test command to package.json and run it in a simulated CI pipeline.
- Write a test that checks whether test results are generated as a report (–coverage).
- Simulate a GitHub Action that runs tests on PR (Pull Request) and validate failing PR.
- Write a sample workflow YAML for running Jest tests and test if workflow executes.
- Create a React component and use Jest to check render time is <100ms.
- Write a Jest test to measure performance of a function that sorts 10,000 items.
- Test if rendering <MyButton /> twice does not exceed a defined time threshold.
- Use jest-extended and test if an array contains only numbers.
- Write a Jest test using toBeEmpty matcher from jest-extended.
- Use jest-extended to check if an object has only specific keys.
- Write a Jest test that integrates with React Testing Library to check button click.
- Write a Jest test using Vue Test Utils to verify props are passed correctly.
- Write a Jest test with Storybook snapshot integration for <Card />.
- Write a test that ensures all .test.js files inside __tests__ folder run automatically.
- Organize a test folder with /unit, /integration, /e2e and run them separately.
- Write a Jest test for DRY principle: create a helper function and reuse it across tests.
- Simulate a flaky test (random timeout) and fix it with Jest stable mocks.
- Write a deterministic test for API fetch that always resolves the same result.
Intermediate Questions
- Configure a GitHub Action YAML that runs Jest and generates coverage report.
- Write a test that uploads Jest coverage results as an artifact in CI.
- Write a test workflow that runs tests on Node v14, v16, and v18 in CI.
- Write a Jest test that checks component render performance using performance.now().
- Write a Jest test to profile 5 renders of <List /> component and compare results.
- Create a custom performance matcher toRenderUnder(time) and use it in Jest.
- Write a test with jest-extended that validates a string is a valid date.
- Write a Jest test with jest-extended for toBeWithinRange(1,10).
- Use React Testing Library with Jest to simulate form submit with validation.
- Use Vue Test Utils with Jest to test slot rendering.
- Write a test for Storybook visual regression using Jest snapshots.
- Simulate folder structure /tests/unit/ and /tests/integration/ and test isolated runs.
- Write a test that dynamically imports a module and checks execution.
- Use beforeEach and afterEach hooks to clean mocks across large test suite.
- Write a Jest test to ensure all test files follow .spec.js naming convention.
- Create a test that ensures at least one unit test, one integration test, and one E2E test exists in the project.
- Write a test that mocks API response to ensure deterministic results across test runs.
- Create a test to detect flaky test by re-running it 5 times and ensuring stable output.
- Write a test that retries on failure using Jest retryTimes.
- Write a test that ensures large dataset search (100k items) runs under 200ms.
Advanced Questions
- Create a full GitHub Actions CI/CD pipeline YAML that installs dependencies, runs Jest, and deploys only if tests pass.
- Write a Jest test that triggers deployment failure if code coverage drops below 80%.
- Use Jest with –runInBand in CI and measure the impact vs parallel runs.
- Create a Jest test that benchmarks rendering performance of <Dashboard /> with 10,000 rows.
- Build a custom matcher in jest-extended to check if a MongoDB ObjectId is valid.
- Write a Jest integration test where React Testing Library simulates Redux state update.
- Write a Jest test with Vue Test Utils to simulate multiple event emitters in a component.
- Build a Storybook + Jest test that validates visual consistency of a ThemeSwitcher.
- Write a Jest utility that auto-generates test suites for all components in /src/components.
- Write a Jest test that identifies flaky API tests, retries with stable mocks, and logs failures in CI.