Repository navigation
Conversation
kanej
commented
Nov 20, 2026
| chainUpdates: (c: TestChainHelper) => Promise<void>, | ||
| ) => ReturnType<typeof runDeploy>; | ||
| config: Partial<DeployConfig>; | ||
| } |
Member
Author
There was a problem hiding this comment.
Pass it explicitly rather than attaching it to the mocha context.
kanej
force-pushed
the
port-hardhat-ignition-tests-from-mocha-to-node
branch
from
November 20, 2026 17:56
59783bf to
8a6a555
Compare
kanej
commented
Nov 20, 2026
| }; | ||
| // Handle both outcomes: `finished.finally()` would return a second promise | ||
| // that rejects whenever `finished` does, and nothing would handle it. | ||
| void finished.then(stop, stop); |
Member
Author
There was a problem hiding this comment.
This is a bug claude found in the helper.
Basically stop, stop means pass stop whether we resolve or reject.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The test migration introduces shared-fixture races, skips required Ignition setup, removes coverage enforcement, and leaves tests without finite timeouts.
4 open issues
1 file not reviewed
pnpm-lock.yaml: Generated file
What changed in this PR
Migrates the Hardhat Ignition plugin’s tests from Mocha and Chai to Node’s built-in test runner, aligning the package with the repository’s test tooling.
Changes:
- Converts suites, hooks, assertions, and fixture access to
node:testand explicit project objects. - Replaces nyc with c8, updates dependencies, and enables Ignition in
test:file. - Adds local Sinon cleanup and prevents unhandled rejections in the pending-transaction helper.
| File | Description |
|---|---|
| scripts/test-file.ts | Enables Ignition test-file runs. |
| pnpm-lock.yaml | Updates test-tool dependencies. |
| packages/hardhat-ignition/tsconfig.json | Removes Mocha global types. |
| packages/hardhat-ignition/test/utils/resolve-deployment-id.ts | Migrates deployment-ID assertions. |
| packages/hardhat-ignition/test/utils/open.ts | Migrates command-selection tests. |
| packages/hardhat-ignition/test/utils/load-module.ts | Uses structured Hardhat error assertions. |
| packages/hardhat-ignition/test/utils/error-deployment-result-to-exception-message.ts | Migrates error-formatting tests. |
| packages/hardhat-ignition/test/utils/bigintReviver.ts | Migrates bigint utility tests. |
| packages/hardhat-ignition/test/ui/pretty-event-handler.ts | Migrates UI tests and restores Sinon stubs. |
| packages/hardhat-ignition/test/ui/helpers/calculate-starting-message.ts | Migrates starting-message tests. |
| packages/hardhat-ignition/test/ui/helpers/calculate-list-transactions-display.ts | Migrates transaction-display tests. |
| packages/hardhat-ignition/test/ui/helpers/calculate-deployment-status-display.ts | Migrates status-display tests. |
| packages/hardhat-ignition/test/ui/helpers/calculate-deployment-complete-display.ts | Migrates completion-display tests. |
| packages/hardhat-ignition/test/ui/helpers/calculate-deploying-module-panel-display.ts | Migrates module-panel tests. |
| packages/hardhat-ignition/test/ui/helpers/calculate-batch-display.ts | Migrates batch-display tests. |
| packages/hardhat-ignition/test/test-helpers/wait-for-pending-txs.ts | Handles both deployment promise outcomes. |
| packages/hardhat-ignition/test/test-helpers/use-ignition-project.ts | Replaces Mocha context with project objects. |
| packages/hardhat-ignition/test/test-helpers/clear-pending-transactions-from-memory-pool.ts | Uses Node assertions. |
| packages/hardhat-ignition/test/tasks/verify.ts | Migrates verification-task tests. |
| packages/hardhat-ignition/test/strategies/only-built-in-strategies.ts | Migrates strategy validation tests. |
| packages/hardhat-ignition/test/strategies/generic-strategy-constraints.ts | Migrates strategy tests and bigint expectations. |
| packages/hardhat-ignition/test/strategies/create2.ts | Migrates CREATE2 assertions and fixtures. |
| packages/hardhat-ignition/test/setup.ts | Removes global Mocha/Chai setup. |
| packages/hardhat-ignition/test/plan/index.ts | Uses explicit visualization-test fixtures. |
| packages/hardhat-ignition/test/plan/build-invocation.ts | Migrates visualization build tests. |
| packages/hardhat-ignition/test/module-parameters.ts | Migrates parameter and error assertions. |
| packages/hardhat-ignition/test/module-api/use-module.ts | Migrates module-composition tests. |
| packages/hardhat-ignition/test/module-api/static-calls.ts | Migrates static-call tests. |
| packages/hardhat-ignition/test/module-api/params.ts | Migrates parameter API tests. |
| packages/hardhat-ignition/test/module-api/libraries.ts | Migrates library deployment tests. |
| packages/hardhat-ignition/test/module-api/fully-qualified-names.ts | Migrates qualified-name tests. |
| packages/hardhat-ignition/test/module-api/existing-contract.ts | Migrates existing-contract tests. |
| packages/hardhat-ignition/test/module-api/events.ts | Migrates event-reading tests. |
| packages/hardhat-ignition/test/module-api/contracts.ts | Migrates contract deployment tests. |
| packages/hardhat-ignition/test/module-api/calls.ts | Migrates contract-call tests. |
| packages/hardhat-ignition/test/migrate/verifyArtifactsVersion.ts | Migrates artifact-version checks. |
| packages/hardhat-ignition/test/migrate/migrate.ts | Migrates deployment migration tests. |
| packages/hardhat-ignition/test/integration/chain-id.ts | Migrates chain-ID reconciliation tests. |
| packages/hardhat-ignition/test/integration/basic-success.ts | Migrates CI deployment smoke test. |
| packages/hardhat-ignition/test/deploy/writeLocalhost.ts | Migrates localhost persistence tests. |
| packages/hardhat-ignition/test/deploy/timeouts/deploy-run-times-out.ts | Migrates deployment-timeout assertions. |
| packages/hardhat-ignition/test/deploy/reset.ts | Migrates deployment-reset tests. |
| packages/hardhat-ignition/test/deploy/rerun/rerun-with-new-contract-deploy.ts | Migrates incremental rerun tests. |
| packages/hardhat-ignition/test/deploy/rerun/rerun-after-kill.ts | Migrates interrupted-deployment tests. |
| packages/hardhat-ignition/test/deploy/rerun/rerun-a-deploy-that-timed-out.ts | Migrates timeout recovery tests. |
| packages/hardhat-ignition/test/deploy/nonce-checks/revert-nonce-on-simulation-error.ts | Migrates simulation-error assertions. |
| packages/hardhat-ignition/test/deploy/nonce-checks/rerun-with-replaced-confirmed-user-transaction.ts | Migrates confirmed-replacement tests. |
| packages/hardhat-ignition/test/deploy/nonce-checks/rerun-with-pending-ignition-transactions.ts | Migrates pending-transaction rerun tests. |
| packages/hardhat-ignition/test/deploy/nonce-checks/rerun-with-now-complete-ignition-transactions.ts | Migrates completed-transaction rerun tests. |
| packages/hardhat-ignition/test/deploy/nonce-checks/rerun-with-dropped-ignition-transaction.ts | Migrates dropped-transaction recovery tests. |
| packages/hardhat-ignition/test/deploy/nonce-checks/error-on-user-transaction-sent.ts | Migrates user-interference tests. |
| packages/hardhat-ignition/test/deploy/nonce-checks/error-on-transaction-dropped.ts | Migrates dropped-transaction error tests. |
| packages/hardhat-ignition/test/deploy/nonce-checks/error-on-rerun-with-replaced-pending-user-transaction.ts | Migrates pending-replacement error tests. |
| packages/hardhat-ignition/test/deploy/nonce-checks/error-on-pending-user-transactions.ts | Migrates pending-user-transaction tests. |
| packages/hardhat-ignition/test/deploy/multiple-batch-contract-deploy.ts | Migrates multi-batch deployment tests. |
| packages/hardhat-ignition/test/deploy/gas-estimation.ts | Migrates gas-estimation error assertions. |
| packages/hardhat-ignition/test/deploy/default-sender.ts | Migrates default-sender tests. |
| packages/hardhat-ignition/test/deploy/build-profile.ts | Migrates build-profile tests. |
| packages/hardhat-ignition/test/deploy/build-invocation.ts | Migrates deployment build tests. |
| packages/hardhat-ignition/test/config.ts | Migrates configuration tests. |
| packages/hardhat-ignition/package.json | Configures Node tests, c8, and dependencies. |
| packages/hardhat-ignition/.nycrc | Removes nyc configuration. |
| packages/hardhat-ignition/.mocharc.json | Removes Mocha configuration. |
Review effort: Balanced
Base automatically changed from
port-ignition-core-tests-from-mocha-to-node
to
main
November 20, 2026 18:29
useEphemeralIgnitionProject and useFileIgnitionProject set hre, connection, ignition and the rest on Mocha's this. Have them return an object they fill in before each test instead, and read project.hre where tests read this.hre. Mocha still runs the tests; this removes the one thing node:test has no equivalent for.
waitForPendingTxs stops polling when the deploy settles, through finished.finally(). That returns a second promise, which rejects whenever the deploy does, as it does on purpose when a test kills a deploy, and nothing handles it. Mocha lets the unhandled rejection pass; node:test fails the test that is running. Use then() with the same callback for both outcomes instead.
Move test from Mocha to node --test with the repo's test reporter, importing describe, it and the hooks from node:test. Chai stays for now: test/setup.ts is loaded with --import so chai-as-promised is still registered. --test-concurrency=1 keeps Mocha's one-file-at-a-time order. The tests build and deploy inside the shared fixture projects, so files running in parallel collide there. node:test hooks take options, not a title, so the hook titles go. The three this.timeout(60000) calls go too, as node:test has no default timeout to raise. setup.ts's root sinon.restore() moves into the one file that relied on it.
assert.isDefined(x) becomes assert.notEqual(x, undefined), and assert.isNotNull(x) becomes assert.ok(x !== null), which narrows the type as isNotNull did.
isTrue and isFalse become assert.equal(x, true|false), and include becomes assert.ok over .includes().
isFulfilled(p) becomes a plain await of p. isRejected and throws become hardhat-test-utils' assertRejects and assertThrows, checking the error message against the same regex or substring. Files left with no chai assertion drop the chai import.
Seven of the rewritten error assertions are HardhatErrors: compare them with assertRejectsWithHardhatError and assertThrowsHardhatError, by descriptor and message arguments, instead of by message text. The module-outside-directory test keeps its Windows path separator as a message argument.
Swap chai's assert for node:assert/strict. The assertions left after the previous commits are the same calls in both. node:assert/strict compares with ===, where chai's equal is loose. Some tests relied on that: contract reads return bigints but were compared with numbers, and one balance is a hex string compared with a bigint. Their expected values are now bigints, and the balance is converted.
kanej
force-pushed
the
port-hardhat-ignition-tests-from-mocha-to-node
branch
from
November 20, 2026 18:29
8a6a555 to
5e71e3d
Compare
The tests now run on node:test with node:assert, so delete .mocharc.json, .nycrc and test/setup.ts, drop the Mocha, chai, chai-as-promised and nyc dependencies, and measure coverage with c8, one file at a time as the tests run.
kanej
force-pushed
the
port-hardhat-ignition-tests-from-mocha-to-node
branch
from
November 20, 2026 21:52
5e71e3d to
3cdd19e
Compare
Contributor
hardhatTotal size of the bundle: List of dependencies (sorted by size) |
kanej
marked this pull request as ready for review
November 20, 2026 21:55
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Port the Ignition plugin package from
mochatonode:test.Review
Tip
Review a commit at a time
this. A pattern mocha allows butnode:testdoes not.node:testwas in play.node:testbut keeps chai assert