Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Unit tests in Wallet migration branch #988

Open
wants to merge 50 commits into
base: new-delegate-factory
Choose a base branch
from

Conversation

hernandoagf
Copy link
Collaborator

@hernandoagf hernandoagf commented Mar 18, 2025

What does this PR do?

  • Replace Jest for Vitest to fix incompatibilities with Wagmi and Viem ESM exports
  • Fix some bugs introduced in the migration detected by the tests failing
  • Update some number formats in the tests to match the new export values from the APIs
  • Mock some of the web3 interactions

Copy link

vercel bot commented Mar 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
governance-portal-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2025 8:12pm

Copy link

socket-security bot commented Mar 18, 2025

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@babel/[email protected] None +1 21 kB nicolo-ribaudo
npm/@babel/[email protected] None 0 9.19 kB nicolo-ribaudo
npm/@bcoe/[email protected]1.0.2 None 0 25.8 kB bcoe
npm/@esbuild/[email protected] None 0 9.5 MB evanw
npm/@esbuild/[email protected] None 0 9.57 MB esbuild, evanw
npm/@rollup/[email protected] None 0 1.69 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.36 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.34 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.54 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.19 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.56 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.35 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.34 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.28 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.18 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.64 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.96 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.43 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 4.05 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.57 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.56 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.91 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 2.69 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@rollup/[email protected] None 0 3.57 MB guybedford, lukastaegert, rich_harris, ...1 more
npm/@testing-library/[email protected], 8.20.110.4.0 None 0 2.43 MB testing-library-bot
npm/@testing-library/[email protected]16.2.0 None 0 337 kB brrianalexis, cmckinstry, dfcook, ...13 more
npm/@types/[email protected]29.5.14 Transitive: environment +3 177 kB types
npm/@types/[email protected], 17.0.3217.0.33 None 0 60.4 kB types
npm/@vitejs/[email protected] Transitive: environment, filesystem +25 11.7 MB vitebot
npm/@vitest/[email protected] Transitive: environment +3 163 kB antfu, oreanno, patak, ...1 more
npm/@vitest/[email protected] None 0 0 B
npm/@vitest/[email protected] None 0 0 B
npm/@vitest/[email protected] None 0 0 B
npm/@vitest/[email protected] None 0 0 B
npm/@vitest/[email protected] None 0 0 B
npm/@vitest/[email protected] None 0 0 B
npm/@vitest/[email protected] None 0 158 kB antfu, oreanno, patak, ...1 more
npm/[email protected], 5.1.35.3.0 None 0 192 kB jessebeach
npm/[email protected] None 0 5.83 kB chaijs
npm/[email protected] None +1 575 kB chaijs
npm/[email protected] None 0 11.4 kB chaijs
npm/[email protected] None 0 23.9 kB chaijs
npm/[email protected] None 0 9.86 kB bjy
npm/[email protected] environment, filesystem, network, shell 0 133 kB evanw
npm/[email protected] filesystem 0 11.6 kB lukeed
npm/[email protected] None 0 3.79 kB sindresorhus
npm/[email protected] environment, filesystem 0 3.04 MB eslintbot

🚮 Removed packages: npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@jest/[email protected], npm/@jest/[email protected], npm/@jest/[email protected], npm/@jest/[email protected], npm/@jest/[email protected], npm/@jest/[email protected], npm/@jest/[email protected], npm/@jest/[email protected], npm/@jest/[email protected], npm/@jest/[email protected], npm/@jest/[email protected], npm/@sinonjs/[email protected], npm/@sinonjs/[email protected], npm/@tootallnate/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

Copy link

what-the-diff bot commented Mar 18, 2025

PR Summary

  • Transition from Jest to Vitest Testing Framework
    The team has moved from using Jest to Vitest for testing. This change is reflected in the updated mock function patterns (jest.mock to vi.mock and jest.Mock to Mock) across several test files, including setup.tsx and component tests. The package.json commands have also been updated in line with this transition. As part of this transition, happy-dom and vite-tsconfig-paths have been introduced as new dependencies, with several testing library versions being increased.

  • Refined Test Rendering and IntersectionObserver Mocking
    We improved our testing procedure by creating a new render function (renderWithRealWagmiConnector), which helps render components with Wagmi and React Query. In addition, the IntersectionObserver mock has been improved to use Vitest's functionality (vi.fn()) over Jest's functionality (jest.fn()).

  • Amended Test Component & File Handling
    Test components now use the new renderWithRealWagmiConnector instead of renderWithTheme, adapting to new dependencies. Furthermore, a couple of JavaScript files have been converted to TypeScript with appropriate renaming (e.g., theme.js to theme.tsx).

  • Enhanced Number Handling in Tests
    We've improved the precision in our tests, especially around mkrSupport and percentage values. Changes have been made to accurately reflect these as part of large-scale values (trillions). Total participation metrics have also been converted to represent larger numerical values, changing from smaller integers to their corresponding BigDecimal values.

  • Improved String Formatting and Test Implementation
    The logic for string formatting has been adjusted to ensure correct locale settings. In addition, the test implementations have been refined to match new component characteristics and ensure Vitest mocking approach is used.

  • Configuration for Vitest
    A new configuration file for Vitest has been added (vitest.config.mts), complete with its plugins and environment settings, with Jest entries appropriately removed.

  • Vote.ts Validation Logic Change
    The logic for signature validation has been inverted in vote.ts (from if (isSignatureValid) to if (!isSignatureValid)) providing a more effective check.

  • Larger Scale Representation in Tests
    All test numerical values, including totalMkrParticipation and totalMkrActiveParticipation, now primarily use string representations. The test descriptions and logic flow have been maintained and structured, ensuring consistency while preparing for a larger scale of use in computations.

@hernandoagf hernandoagf changed the title Replace jest for vitest Fix Unit tests in Wallet migration branch Mar 18, 2025
@hernandoagf hernandoagf marked this pull request as ready for review March 18, 2025 16:20
Base automatically changed from wallet-refactor to new-delegate-factory March 18, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants