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

Add hardhat-test-utils package #5492

Merged
merged 3 commits into from
Jul 8, 2024
Merged

Add hardhat-test-utils package #5492

merged 3 commits into from
Jul 8, 2024

Conversation

alcuadrado
Copy link
Member

@alcuadrado alcuadrado commented Jul 5, 2024

This PR introduces a new private package, @nomicfoundation/hardhat-test-utils, and installs it in all the v-next packages that are compatible with it (i.e. not dendencies of it).

This PR only introduces helpers for HardhatError related assertions, but it doesn't change any existing test.

A follow-up PR will change the existing tests to use the new utilities.

@alcuadrado alcuadrado added the v-next A Hardhat v3 development task label Jul 5, 2024
@alcuadrado alcuadrado requested a review from schaable July 5, 2024 21:03
Copy link

changeset-bot bot commented Jul 5, 2024

⚠️ No Changeset found

Latest commit: bdf581a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jul 5, 2024

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

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 8, 2024 7:25pm

@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Jul 5, 2024
@@ -38,9 +38,9 @@
"README.md"
],
"dependencies": {
"@nomicfoundation/ethereumjs-util": "9.0.4",
Copy link
Member Author

Choose a reason for hiding this comment

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

Jus an automatic reordering that pnpm did

@@ -61,6 +61,7 @@
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
"@ignored/hardhat-vnext-node-test-reporter": "workspace:^3.0.0-next.0",
"@nomicfoundation/hardhat-test-utils": "workspace:^",
Copy link
Member Author

Choose a reason for hiding this comment

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

Contrary to the rest of our packages, we do workspace:^ here because this is a private package, which we don't intend to publish, so versioning is not an issue.

Copy link
Member

@schaable schaable left a comment

Choose a reason for hiding this comment

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

LGTM! One minor suggestion regarding naming: I liked how Node assert distinguishes between throwing and rejecting.

assert.fail("Function did not throw any error");
}

export async function assertThrowsHardhatErrorAsync<
Copy link
Member

Choose a reason for hiding this comment

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

how about assertRejectsWithHardhatError?

@alcuadrado alcuadrado merged commit 29cef28 into v-next Jul 8, 2024
50 checks passed
@alcuadrado alcuadrado deleted the hardhat-test-utils branch July 8, 2024 19:26
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:ready This issue is ready to be worked on v-next A Hardhat v3 development task
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants