planning-poker icon indicating copy to clipboard operation
planning-poker copied to clipboard

Migrate to rsbuild

Open L4Ph opened this issue 11 months ago • 10 comments

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-scripts with rsbuild as the build tool, updating the start, build, and test scripts in package.json accordingly. Added @rsbuild/core and @rsbuild/plugin-react as dependencies. [1] [2]
  • Introduced a new rsbuild.config.ts file to configure rsbuild with React plugin support and environment variable definitions.

Testing Configuration Enhancements:

  • Added a new jest.config.ts file to configure jest with jsdom as the test environment, SWC for TypeScript transformation, and stub mapping for static assets.
  • Updated package.json to include jest, jest-environment-jsdom, and jest-transform-stub as dependencies for the new testing setup.

Test Suite Improvements:

  • Improved mocking practices across test files:
    • Mocked CardConfigs in CardPicker.test.tsx to stub getRandomEmoji and added a beforeEach block to clear mocks before each test. [1] [2] [3]
    • Simplified PlayerCard.test.tsx by fully mocking playerService and removing unnecessary jest.spyOn calls. [1] [2]
    • Enhanced Poker.test.tsx by switching to type-safe mocks for gamesService and adding an afterEach block to restore mocks after each test. [1] [2] [3] [4]
  • Added beforeEach to clear mocks in games.test.ts, improving test isolation.

Minor Updates:

  • Updated the favicon path in index.html to use the assetPrefix variable for better compatibility with the new build system.

L4Ph avatar May 07 '25 07:05 L4Ph

close #105

L4Ph avatar May 07 '25 07:05 L4Ph

@L4Ph - the builds seems to be failing in CI, looks like yarn lock file is out of sync. Can you take a look pls?

hellomuthu23 avatar May 08 '25 06:05 hellomuthu23

I think you need to make some changes on the CI side. Would you like to make those changes? @hellomuthu23

L4Ph avatar May 08 '25 06:05 L4Ph

Or would it be better to submit a PR without using berry (yarn v2 or later)?

L4Ph avatar May 08 '25 06:05 L4Ph

yes, that would be ideal!.

hellomuthu23 avatar May 08 '25 07:05 hellomuthu23

@hellomuthu23 fixed

L4Ph avatar May 08 '25 08:05 L4Ph

🤔

L4Ph avatar May 14 '25 02:05 L4Ph

I think that eslint cannot be found because it does not exist in deps, so why does this error occur ...

L4Ph avatar May 14 '25 02:05 L4Ph

Ah, I see. So eslint is included in the CRA...

L4Ph avatar May 14 '25 02:05 L4Ph

https://github.com/facebook/create-react-app/blob/main/packages%2Feslint-config-react-app%2Findex.js

L4Ph avatar May 14 '25 02:05 L4Ph