Skip to content

Conversation

@thanhhoan-v2
Copy link

This pull request introduces a testing framework to the project, addressing the "test code" item noted in the README.md's to-do list.

By setting up Jest and React Testing Library, this provides a foundation for writing unit and component tests, improving code quality and maintainability.

Key Changes:

  • Added Dependencies: Installed jest, react-testing-library, ts-jest, and other necessary testing-related packages as development dependencies.
  • Jest & TypeScript Configuration:
    • Created jest.config.js to configure Jest to work with TypeScript and a JSDOM environment.
    • Updated tsconfig.json to include the necessary types for Jest and Testing Library.
  • Initial Tests: Added an initial test suite for the AnimatedNumbers component in tests/index.test.tsx. These tests verify:
    • The component renders thousand separators correctly.
    • The final digits of the target number are present in the component's output.
  • Mocking: Implemented a mock for ResizeObserver to allow the component to render correctly within the JSDOM test environment.
  • NPM Script: Added a test script to package.json for easy execution of the test suite.

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.

1 participant