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

chore: integrate vitest matchers globally #3425

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

starc007
Copy link

Summary

This PR integrates Vitest matchers globally for fuel-gauge tests, improving test maintainability and type safety.

Changes

  • Add global setup for vitest matchers in test/setup.ts
  • Add proper TypeScript types for custom matcher toEqualBn
  • Remove individual expect.extend() calls from test files
  • Remove @ts-expect-error comments for toEqualBn usage

Testing

  • ✅ All existing tests pass
  • ✅ Type checking passes without errors
  • ✅ Matcher functionality remains unchanged

Copy link

vercel bot commented Nov 26, 2024

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

Name Status Preview Comments Updated (UTC)
ts-docs-api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 29, 2024 8:59pm

@CLAassistant
Copy link

CLAassistant commented Nov 26, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

vercel bot commented Nov 26, 2024

@starc007 is attempting to deploy a commit to the Fuel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

codspeed-hq bot commented Nov 27, 2024

CodSpeed Performance Report

Merging #3425 will improve performances by 47.93%

Comparing starc007:starc007/feat/integrate-vitest-matchers-globally (b142a13) with master (d29e884)

Summary

⚡ 1 improvements
✅ 17 untouched benchmarks

Benchmarks breakdown

Benchmark master starc007:starc007/feat/integrate-vitest-matchers-globally Change
Instantiate from an address 576.7 µs 389.8 µs +47.93%

Copy link
Contributor

@Torres-ssf Torres-ssf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @starc007,

Thank you so much for this contribution. We really appreciate it 🙏

It appears that the current solution hasn’t resolved the TS errors.

Screenshot 2024-11-27 at 9 13 42 AM

@Torres-ssf Torres-ssf added chore Issue is a chore good first issue Suitable for newcomers looking to contribute and removed feat Issue is a feature labels Nov 27, 2024
@Torres-ssf Torres-ssf changed the title feat: integrate vitest matchers globally chore: integrate vitest matchers globally Nov 27, 2024
Copy link
Contributor

@danielbate danielbate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR also needs a changeset, please run pnpm changeset from the root directory.

@starc007
Copy link
Author

Hey @Torres-ssf

Issue:
When running pnpm lint (type:check-tests), the type checker fails because the matchers aren't being recognized globally. However, when importing setupTestMatchers directly in the test file (e.g. abi-coder.test.ts), it works as expected.

This suggests the setupFiles configuration in vitest.shared.config.mts isn't being properly loaded during type checking.

Questions:

  1. Is there a different way we should be configuring the global setup file for both runtime and type checking?
  2. Should we be using a different approach to register global matchers that works with the type system?

Any guidance on the correct way to set this up would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Issue is a chore good first issue Suitable for newcomers looking to contribute
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate vitest matchers globally
4 participants