Repository navigation
Port ignition core tests from mocha to node - #8869
Merged
Merged
Conversation
Move test:integrations 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. The unit tests still run on Mocha.
Move test:unit from Mocha to node --test with the repo's test reporter, importing describe, it and the hooks from node:test. Chai stays for now, with test/setup.ts loaded through --import.
assert.isDefined(x) becomes assert.notEqual(x, undefined) and assert.isUndefined(x) becomes assert.equal(x, undefined), forms that chai and node:assert share.
assert.isTrue(x) becomes assert.equal(x, true) and assert.isFalse(x) becomes assert.equal(x, false).
isString and typeOf become a typeof comparison, isArray becomes assert.ok(Array.isArray(x)), lengthOf compares .length, and instanceOf becomes assert.ok(x instanceof C).
include and notInclude become assert.ok over .includes(), and the one includeMembers, with a single member, becomes the same.
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.
Three of the rewritten error assertions are HardhatErrors: compare them with assertThrowsHardhatError and assertRejectsWithHardhatError, by descriptor and message arguments, instead of by message text.
The two duplicate future id tests in staticCall.ts throw an INVALID_MODULE HardhatError, as the equivalent tests in call.ts do. Compare them with assertThrowsHardhatError, as call.ts does, instead of by message text.
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 strictly, where chai's equal is loose and its deepEqual ignores prototypes. One test compared an account runtime value with a plain object; it now compares with an instance.
Both suites 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 over both suites. ignition-core now runs under test:file.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new c8 command omits coverage checks and the previous thresholds, allowing test:coverage to pass below the formerly enforced minimums.
1 open issue
1 file not reviewed
pnpm-lock.yaml: Generated file
What changed in this PR
Migrates Ignition core’s unit and Hardhat-backed integration tests from Mocha and Chai to Node’s built-in test runner and strict assertions, aligning the package with the repository’s Node-based test tooling.
Changes:
- Ports test suites, lifecycle hooks, and assertions to
node:test,node:assert/strict, and Hardhat test helpers. - Replaces NYC with c8 and removes obsolete Mocha, Chai, and coverage configuration.
- Enables Ignition core in the shared single-file test script while retaining the existing fixture setup.
| File | Description |
|---|---|
| scripts/test-file.ts | Enables single-file testing for Ignition core. |
| pnpm-lock.yaml | Updates test and coverage dependencies. |
| packages/ignition-core/tsconfig.json | Removes Mocha global types. |
| packages/ignition-core/test/wipe.ts | Ports wipe tests and assertions. |
| packages/ignition-core/test/verify.ts | Ports verification tests and assertions. |
| packages/ignition-core/test/validations/identifier-validators.ts | Converts identifier validation assertions. |
| packages/ignition-core/test/validations/id-rules.ts | Switches validation tests to Node imports. |
| packages/ignition-core/test/utils/replace-within-arg.ts | Ports utility tests and hooks. |
| packages/ignition-core/test/utils/future-id-builders.ts | Switches future-ID tests to Node imports. |
| packages/ignition-core/test/utils/check-automined-network.ts | Converts automining assertions. |
| packages/ignition-core/test/utils/adjacency-list.ts | Switches adjacency-list tests to Node imports. |
| packages/ignition-core/test/useModule.ts | Ports module tests and promise handling. |
| packages/ignition-core/test/types/deployment-loader.ts | Converts deployment-loader assertions. |
| packages/ignition-core/test/track-transaction.ts | Switches transaction tracking tests to Node imports. |
| packages/ignition-core/test/status.ts | Switches status tests to Node imports. |
| packages/ignition-core/test/staticCall.ts | Ports static-call assertions and error checks. |
| packages/ignition-core/test/setup.ts | Removes Chai plugin setup. |
| packages/ignition-core/test/send.ts | Ports send tests and assertions. |
| packages/ignition-core/test/reconciliation/reconciler.ts | Switches reconciler tests to Node imports. |
| packages/ignition-core/test/reconciliation/helpers.ts | Uses Node assertions in reconciliation helpers. |
| packages/ignition-core/test/reconciliation/futures/reconcileSendData.ts | Ports send-data reconciliation tests. |
| packages/ignition-core/test/reconciliation/futures/reconcileReadEventArgument.ts | Ports event-argument reconciliation tests. |
| packages/ignition-core/test/reconciliation/futures/reconcileNamedStaticCall.ts | Ports static-call reconciliation tests. |
| packages/ignition-core/test/reconciliation/futures/reconcileNamedLibraryDeployment.ts | Ports named-library reconciliation tests. |
| packages/ignition-core/test/reconciliation/futures/reconcileNamedEncodeFunctionCall.ts | Ports call-encoding reconciliation tests. |
| packages/ignition-core/test/reconciliation/futures/reconcileNamedContractDeployment.ts | Ports named-contract deployment reconciliation tests. |
| packages/ignition-core/test/reconciliation/futures/reconcileNamedContractCall.ts | Ports contract-call reconciliation tests. |
| packages/ignition-core/test/reconciliation/futures/reconcileNamedContractAt.ts | Ports named contract-at reconciliation tests. |
| packages/ignition-core/test/reconciliation/futures/reconcileArtifactLibraryDeployment.ts | Ports artifact-library reconciliation tests. |
| packages/ignition-core/test/reconciliation/futures/reconcileArtifactContractDeployment.ts | Ports artifact-contract deployment reconciliation tests. |
| packages/ignition-core/test/reconciliation/futures/reconcileArtifactContractAt.ts | Ports artifact contract-at reconciliation tests. |
| packages/ignition-core/test/readEventArgument.ts | Converts event-argument membership assertions. |
| packages/ignition-core/test/listDeployments.ts | Switches deployment-list tests to Node imports. |
| packages/ignition-core/test/list-transactions.ts | Switches transaction-list tests to Node imports. |
| packages/ignition-core/test/libraryFromArtifact.ts | Ports artifact-library tests and assertions. |
| packages/ignition-core/test/library.ts | Ports library tests and assertions. |
| packages/ignition-core/test/ignition-module-serializer.ts | Switches serializer tests to Node imports. |
| packages/ignition-core/test/helpers.ts | Converts shared assertion helpers. |
| packages/ignition-core/test/getParameter.ts | Uses class instances for strict comparison. |
| packages/ignition-core/test/getAccount.ts | Switches account tests to Node imports. |
| packages/ignition-core/test/execution/views/find-result-for-future-by-id.ts | Ports future-result lookup tests. |
| packages/ignition-core/test/execution/utils/convert-evm-tuple-to-solidity-param.ts | Ports tuple conversion tests. |
| packages/ignition-core/test/execution/reducers/start-a-new-run.ts | Ports run-start reducer tests and hooks. |
| packages/ignition-core/test/execution/reducers/running-send-data.ts | Converts send-data reducer assertions and hooks. |
| packages/ignition-core/test/execution/reducers/running-contract-at.ts | Ports contract-at reducer tests and hooks. |
| packages/ignition-core/test/execution/reducers/running-a-static-call.ts | Ports static-call reducer tests and hooks. |
| packages/ignition-core/test/execution/reducers/running-a-read-event-arg.ts | Ports event-argument reducer tests and hooks. |
| packages/ignition-core/test/execution/reducers/running-a-named-library-deploy.ts | Ports library-deployment reducer tests and hooks. |
| packages/ignition-core/test/execution/reducers/running-a-named-contract-deploy.ts | Converts contract-deployment reducer assertions and hooks. |
| packages/ignition-core/test/execution/reducers/running-a-call.ts | Converts call reducer assertions and hooks. |
| packages/ignition-core/test/execution/nonce-management/json-rpc-nonce-manager.ts | Ports nonce-manager tests. |
| packages/ignition-core/test/execution/nonce-management/get-nonce-sync-messages.ts | Ports nonce synchronization tests and hooks. |
| packages/ignition-core/test/execution/libraries.ts | Converts library-linking assertions. |
| packages/ignition-core/test/execution/future-processor/named-contract-deploy.ts | Ports contract-deployment processor tests. |
| packages/ignition-core/test/execution/future-processor/named-contract-at-deploy.ts | Ports contract-at processor tests. |
| packages/ignition-core/test/execution/future-processor/helpers/network-interaction-execution.ts | Ports network interaction assertions and hooks. |
| packages/ignition-core/test/execution/future-processor/helpers/build-initialize-message-for.ts | Ports initialization-message tests and hooks. |
| packages/ignition-core/test/execution/execution-engine.ts | Switches execution-engine tests to Node imports. |
| packages/ignition-core/test/execution/abi.ts | Converts ABI assertions and Hardhat error checks. |
| packages/ignition-core/test/encodeFunctionCall.ts | Ports encoding assertions and promise handling. |
| packages/ignition-core/test/contractFromArtifact.ts | Ports artifact deployment assertions and promise handling. |
| packages/ignition-core/test/contractAtFromArtifact.ts | Ports artifact contract-at tests and assertions. |
| packages/ignition-core/test/contractAt.ts | Ports contract-at tests and assertions. |
| packages/ignition-core/test/contract.ts | Ports contract assertions and promise handling. |
| packages/ignition-core/test/call.ts | Ports call assertions and promise handling. |
| packages/ignition-core/test/build-module.ts | Uses Node tests and Hardhat exception helpers. |
| packages/ignition-core/test/batcher.ts | Ports batcher tests and assertions. |
| packages/ignition-core/test-integrations/test-execution-result-fixtures.ts | Ports execution-result integration assertions. |
| packages/ignition-core/test-integrations/internal/execution/jsonrpc-client.ts | Ports JSON-RPC integration tests and rejection checks. |
| packages/ignition-core/test-integrations/helpers/hardhat-projects.ts | Imports Node lifecycle hooks for fixtures. |
| packages/ignition-core/package.json | Configures Node test commands, c8, and dependencies. |
| packages/ignition-core/.nycrc | Removes legacy NYC configuration. |
| packages/ignition-core/.mocharc.json | Removes legacy Mocha configuration. |
Review effort: Balanced
kanej
force-pushed
the
port-ignition-core-tests-from-mocha-to-node
branch
from
November 20, 2026 16:21
5f4ed9e to
ccc0100
Compare
ChristopherDedominici
approved these changes
Nov 20, 2026
|
|
||
| let prevWorkingDir: string; | ||
|
|
||
| // todo: whenever these tests are migrated to node:test, |
Contributor
There was a problem hiding this comment.
Minor: should we do it now?
Member
Author
There was a problem hiding this comment.
I will tackle the fixtures in its own PR at the end of this chain.
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 core package's tests to
node:test(frommocha). This involves both:pnpm test:unitpnpm test:integrationsReview
Tip
Review a commit at a time
node:testI have intentionally not touched fixture setup (there is a custom version in Ignition that can be ported to the test utils version).