Fix the build failure because of imports - #46
Conversation
📝 WalkthroughWalkthroughThe PR fixes the Jest test suite to work with the current codebase. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/SearchBar/SearchBar.test.tsx`:
- Around line 82-83: The querySelector on document is too broad and can match
unrelated SVGs in the test suite, causing false positives. Instead of using
document.querySelector('svg'), scope the query to only the rendered SearchBar
component's container. Query the SVG element from within the specific render
tree of the SearchBar component (typically by getting a reference to the
rendered container or using a more specific selector that targets elements
within the SearchBar component specifically) so that the test validates only the
SearchBar's SVG element.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6f9db528-90cb-4daf-8457-e5763bf8c9c2
📒 Files selected for processing (6)
package.jsonsrc/__mocks__/@wso2/oxygen-ui.jssrc/components/ConnectorCard/ConnectorCard.test.tsxsrc/components/Pagination/Pagination.test.tsxsrc/components/SearchBar/SearchBar.test.tsxsrc/setupTests.ts
Description
Root cause:
@wso2/oxygen-ui ships an ESM-only bundle (mixed var declarations + import statements) that Jest's CommonJS runtime cannot parse. It also pulls in more ESM-only transitive deps (@mui/x-data-grid, date-fns, @mui/x-date-pickers), making the
The transformIgnorePatterns approach is a whack-a-mole.
Changes made:
- @wso2/oxygen-ui → proxied to a local mock that re-exports from @mui/material (CJS-compatible)
- @wso2/oxygen-ui-icons-react → redirected to its .cjs build (it ships both ESM and CJS)
By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.