Migrate to rsbuild
This pull request introduces significant updates to the testing configuration, build system, and test suite, transitioning from react-scripts to rsbuild and enhancing test reliability through better mocking practices. Key changes include the addition of rsbuild configuration, updates to jest setup, and improvements to test files for better maintainability.
Build System Updates:
- Replaced
react-scriptswithrsbuildas the build tool, updating thestart,build, andtestscripts inpackage.jsonaccordingly. Added@rsbuild/coreand@rsbuild/plugin-reactas dependencies. [1] [2] - Introduced a new
rsbuild.config.tsfile to configurersbuildwith React plugin support and environment variable definitions.
Testing Configuration Enhancements:
- Added a new
jest.config.tsfile to configurejestwithjsdomas the test environment, SWC for TypeScript transformation, and stub mapping for static assets. - Updated
package.jsonto includejest,jest-environment-jsdom, andjest-transform-stubas dependencies for the new testing setup.
Test Suite Improvements:
- Improved mocking practices across test files:
- Mocked
CardConfigsinCardPicker.test.tsxto stubgetRandomEmojiand added abeforeEachblock to clear mocks before each test. [1] [2] [3] - Simplified
PlayerCard.test.tsxby fully mockingplayerServiceand removing unnecessaryjest.spyOncalls. [1] [2] - Enhanced
Poker.test.tsxby switching to type-safe mocks forgamesServiceand adding anafterEachblock to restore mocks after each test. [1] [2] [3] [4]
- Mocked
- Added
beforeEachto clear mocks ingames.test.ts, improving test isolation.
Minor Updates:
- Updated the favicon path in
index.htmlto use theassetPrefixvariable for better compatibility with the new build system.
close #105
@L4Ph - the builds seems to be failing in CI, looks like yarn lock file is out of sync. Can you take a look pls?
I think you need to make some changes on the CI side. Would you like to make those changes? @hellomuthu23
Or would it be better to submit a PR without using berry (yarn v2 or later)?
yes, that would be ideal!.
@hellomuthu23 fixed
🤔
I think that eslint cannot be found because it does not exist in deps, so why does this error occur ...
Ah, I see. So eslint is included in the CRA...
https://github.com/facebook/create-react-app/blob/main/packages%2Feslint-config-react-app%2Findex.js