fix: updated existing enzyme tests to use react testing library #36303
+11,555
−13,875
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR replaces Enzyme with React Testing Library (RTL) to improve test reliability and ensure compatibility with React 18. Enzyme is deprecated and no longer recommended for testing React applications.
Changes Made
1 - Replaced Enzyme with RTL – Aligns with modern testing practices.
2 - Mocked
BlockBrowserContainer
– Improves test isolation by removing external dependencies.3 - Rendered Main inside a Redux provider – Simulates the application state with mock props.
4 - Added
reportDownloadEndpoint
prop – Ensures the component receives all necessary props.5 - Updated dropdown interaction tests:
fetchCourseBlocksMock
is called with courseId andexcludedBlockTypes
.Other information
Dependencies
Added (RTL)
@testing-library/react@12.1.5
@testing-library/jest-dom@6.6.3
@testing-library/user-event@12.8.3
Removed (Enzyme)
enzyme@3.11.0
react-16-enzyme-adapter@1.15.8
jest-enzyme@7.1.2