Skip to content

Conversation

L4Ph
Copy link

@L4Ph L4Ph commented May 7, 2025

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
Copy link
Author

L4Ph commented May 7, 2025

close #105

@hellomuthu23
Copy link
Owner

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

@L4Ph
Copy link
Author

L4Ph commented May 8, 2025

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

@L4Ph
Copy link
Author

L4Ph commented May 8, 2025

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

@hellomuthu23
Copy link
Owner

yes, that would be ideal!.

@L4Ph
Copy link
Author

L4Ph commented May 8, 2025

@hellomuthu23 fixed

@L4Ph
Copy link
Author

L4Ph commented May 14, 2025

🤔

@L4Ph
Copy link
Author

L4Ph commented May 14, 2025

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

@L4Ph
Copy link
Author

L4Ph commented May 14, 2025

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

@L4Ph
Copy link
Author

L4Ph commented May 14, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants