-
Notifications
You must be signed in to change notification settings - Fork 1.7k
chai matchers improvements #7176
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
Conversation
🦋 Changeset detectedLatest commit: f61ab8a The changes in this PR will be included in the next version bump. This PR includes changesets to release 21 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the Hardhat Ethers Chai matchers by renaming .reverted() to .revert(), introducing a deprecation warning for the legacy .reverted property, and updating all balance change matchers to accept HardhatEthers instead of EthereumProvider for API consistency.
- Renames the
.reverted()matcher method to.revert()across all test files and implementation - Adds a new
.revertedproperty that throws a deprecation error to prevent accidental usage - Updates balance change matchers to use
HardhatEthersinstead ofEthereumProviderfor consistency
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| v-next/hardhat-ethers-chai-matchers/test/multi-network-connections.ts | Updates changeEtherBalance calls to use ethers instead of provider |
| v-next/hardhat-ethers-chai-matchers/test/matchers/reverted/revert.ts | Renames all .reverted() calls to .revert() and updates test descriptions |
| v-next/hardhat-ethers-chai-matchers/test/matchers/reverted/legacyReverted.ts | New test file for the deprecated .reverted property behavior |
| v-next/hardhat-ethers-chai-matchers/test/matchers/changeTokenBalance.ts | Updates all balance change matcher calls to use ethers instead of provider |
| v-next/hardhat-ethers-chai-matchers/test/matchers/changeEtherBalances.ts | Updates balance change matcher calls to use ethers parameter |
| v-next/hardhat-ethers-chai-matchers/test/matchers/changeEtherBalance.ts | Updates balance change matcher calls to use ethers parameter |
| v-next/hardhat-ethers-chai-matchers/src/type-extensions.ts | Updates type definitions to use HardhatEthers instead of EthereumProvider |
| v-next/hardhat-ethers-chai-matchers/src/internal/utils/balance.ts | Refactors balance utilities to use HardhatEthers and direct provider calls |
| v-next/hardhat-ethers-chai-matchers/src/internal/matchers/reverted/revert.ts | Renames matcher from REVERTED_MATCHER to REVERT_MATCHER |
| v-next/hardhat-ethers-chai-matchers/src/internal/matchers/reverted/legacyReverted.ts | New implementation for deprecated .reverted property with error throwing |
| v-next/hardhat-ethers-chai-matchers/src/internal/matchers/changeTokenBalance.ts | Updates to use HardhatEthers and direct provider calls instead of raw requests |
| v-next/hardhat-ethers-chai-matchers/src/internal/matchers/changeEtherBalances.ts | Updates parameter types and function calls to use HardhatEthers |
| v-next/hardhat-ethers-chai-matchers/src/internal/matchers/changeEtherBalance.ts | Updates to use HardhatEthers and direct provider calls |
| v-next/hardhat-ethers-chai-matchers/src/internal/constants.ts | Adds new constants for legacy and new matcher names |
| v-next/hardhat-ethers-chai-matchers/src/internal/add-chai-matchers.ts | Registers both legacy and new matcher implementations |
| v-next/hardhat-errors/src/descriptors.ts | Adds new error descriptor for deprecated matcher usage |
This PR:
.reverted()to.revert().revertedas a property that always throws an errorEthereumProvidertakeHardhatEthersnow.The reason for the first two is that while migrating a HH2 project it was easy to forget to call
.rejectedand just leave it like that, which lead to an unhandled promise rejection.The latter is for consistency.