Skip to content

Port ignition core tests from mocha to node - #8869

Merged
kanej merged 11 commits into
mainfrom
port-ignition-core-tests-from-mocha-to-node
Nov 20, 2026
Merged

kanej merged 11 commits into
mainfrom
port-ignition-core-tests-from-mocha-to-node

Conversation

@kanej

@kanej kanej commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Port the Ignition core package's tests to node:test (from mocha). This involves both:

  • unit tests - pnpm test:unit
  • integration tests that pull in Hardhat to test the network stack - pnpm test:integrations

Review

Tip

Review a commit at a time

  • The first commit migrates the integration tests completely
  • The second port the unit tests to node:test
  • A series of commits port from chai assert to node's own assert, each commit shifts a different pattern of usage
  • final commit is cleanup

I have intentionally not touched fixture setup (there is a custom version in Ignition that can be ported to the test utils version).

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.
@kanej kanej added no changeset needed This PR doesn't require a changeset no docs needed This PR doesn't require links to documentation no peer bump needed labels Nov 20, 2026
@kanej
kanej requested a balanced review from Copilot November 20, 2026 16:17
@NomicFoundation NomicFoundation deleted a comment from changeset-bot Bot Nov 20, 2026
@NomicFoundation NomicFoundation deleted a comment from github-actions Bot Nov 20, 2026
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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

Comment thread packages/ignition-core/package.json Resolved
@kanej
kanej force-pushed the port-ignition-core-tests-from-mocha-to-node branch from 5f4ed9e to ccc0100 Compare November 20, 2026 16:21
@NomicFoundation NomicFoundation deleted a comment from changeset-bot Bot Nov 20, 2026
@NomicFoundation NomicFoundation deleted a comment from github-actions Bot Nov 20, 2026
@kanej
kanej added this pull request to stack #8871 November 20, 2026 17:40

let prevWorkingDir: string;

// todo: whenever these tests are migrated to node:test,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: should we do it now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will tackle the fixtures in its own PR at the end of this chain.

@kanej
kanej added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit c6a0b31 Nov 20, 2026
243 checks passed
@kanej
kanej deleted the port-ignition-core-tests-from-mocha-to-node branch November 20, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changeset needed This PR doesn't require a changeset no docs needed This PR doesn't require links to documentation no peer bump needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants