From b5ea54d3d3cb9f58e84a43a9d2d81b87a709cca9 Mon Sep 17 00:00:00 2001 From: John Kane Date: Fri, 20 Nov 2026 11:35:49 +0000 Subject: [PATCH] Port ignition-ui tests from Mocha to node:test Run the to-mermaid tests under node --test with the repo's test reporter, using the template package's test, test:only and test:coverage scripts. Swap chai for node:assert/strict, nyc for c8, and drop the now unused Mocha and chai dependencies and the .mocharc.json and .nycrc files. ignition-ui now runs under node --test, so test:file can run it. --- packages/ignition-ui/.mocharc.json | 4 --- packages/ignition-ui/.nycrc | 12 ------- packages/ignition-ui/package.json | 15 ++++----- packages/ignition-ui/test/to-mermaid.ts | 4 ++- packages/ignition-ui/tsconfig.json | 2 +- pnpm-lock.yaml | 45 ++++++++++--------------- scripts/test-file.ts | 1 - 7 files changed, 29 insertions(+), 54 deletions(-) delete mode 100644 packages/ignition-ui/.mocharc.json delete mode 100644 packages/ignition-ui/.nycrc diff --git a/packages/ignition-ui/.mocharc.json b/packages/ignition-ui/.mocharc.json deleted file mode 100644 index ae3c252dfb3..00000000000 --- a/packages/ignition-ui/.mocharc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extension": ["ts"], - "node-option": ["import=tsx/esm"] -} diff --git a/packages/ignition-ui/.nycrc b/packages/ignition-ui/.nycrc deleted file mode 100644 index d4e4aca7ebd..00000000000 --- a/packages/ignition-ui/.nycrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "@istanbuljs/nyc-config-typescript", - "check-coverage": false, - "statements": 10, - "branches": 10, - "functions": 10, - "lines": 10, - "all": true, - "include": ["src/**/*.ts", "test/**/*.ts"], - "reporter": ["html", "lcov", "text", "text-summary"], - "report-dir": "coverage" -} diff --git a/packages/ignition-ui/package.json b/packages/ignition-ui/package.json index f05ed75f06e..9a8d095d83a 100644 --- a/packages/ignition-ui/package.json +++ b/packages/ignition-ui/package.json @@ -12,8 +12,10 @@ "dev": "vite --force", "build": "tsc --build .", "pretest": "pnpm build", - "test": "mocha --recursive \"test/**/*.ts\"", - "test:coverage": "nyc mocha --recursive \"test/**/*.ts\"", + "pretest:only": "pnpm build", + "test": "node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", + "test:only": "node --import tsx/esm --test --test-only --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", + "test:coverage": "c8 --reporter html --reporter text --all --exclude test --exclude \"src/**/{types,type-extensions}.ts\" --src src node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", "regenerate-deployment-example": "node ./scripts/generate-example-deployment-json.js", "lint": "pnpm eslint && pnpm prettier --check", "lint:fix": "pnpm eslint --fix && pnpm prettier --write", @@ -31,18 +33,15 @@ ], "devDependencies": { "@fontsource/roboto": "^5.3.0", + "@nomicfoundation/hardhat-node-test-reporter": "workspace:^3.1.0", "@nomicfoundation/ignition-core": "workspace:^3.1.2", - "@types/chai": "^5.2.3", - "@types/chai-as-promised": "^8.0.1", - "@types/mocha": ">=10.0.10", + "@types/node": "^22.0.0", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", "@vitejs/plugin-react": "^6.0.0", - "chai": "^6.2.2", - "chai-as-promised": "^8.0.0", + "c8": "^12.0.0", "eslint": "9.39.5", "mermaid": "^11.0.0", - "mocha": "^12.0.0", "prettier": "3.9.10", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/packages/ignition-ui/test/to-mermaid.ts b/packages/ignition-ui/test/to-mermaid.ts index dca706af4cc..5c20e29c347 100644 --- a/packages/ignition-ui/test/to-mermaid.ts +++ b/packages/ignition-ui/test/to-mermaid.ts @@ -1,9 +1,11 @@ +import assert from "node:assert/strict"; +import { describe, it } from "node:test"; + import { type Artifact, type IgnitionModule, buildModule, } from "@nomicfoundation/ignition-core"; -import { assert } from "chai"; import { toMermaid } from "../src/utils/to-mermaid.js"; diff --git a/packages/ignition-ui/tsconfig.json b/packages/ignition-ui/tsconfig.json index 14def873e07..14dc39899d3 100644 --- a/packages/ignition-ui/tsconfig.json +++ b/packages/ignition-ui/tsconfig.json @@ -12,7 +12,7 @@ "isolatedModules": true, "noEmit": true, "jsx": "react-jsx", - "types": ["mocha"], + "types": ["node"], /* Linting */ "strict": true, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7826a9a99f0..5d538fa59ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1989,18 +1989,15 @@ importers: '@fontsource/roboto': specifier: ^5.3.0 version: 5.3.0 + '@nomicfoundation/hardhat-node-test-reporter': + specifier: workspace:^3.1.0 + version: link:../hardhat-node-test-reporter '@nomicfoundation/ignition-core': specifier: workspace:^3.1.2 version: link:../ignition-core - '@types/chai': - specifier: ^5.2.3 - version: 5.2.3 - '@types/chai-as-promised': - specifier: ^8.0.1 - version: 8.0.2 - '@types/mocha': - specifier: '>=10.0.10' - version: 10.0.10 + '@types/node': + specifier: ^22.0.0 + version: 22.20.5 '@types/react': specifier: ^19.0.0 version: 19.3.0 @@ -2009,22 +2006,16 @@ importers: version: 19.3.0(@types/react@19.3.0) '@vitejs/plugin-react': specifier: ^6.0.0 - version: 6.1.2(vite@8.3.5(@types/node@24.19.2)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0)) - chai: - specifier: ^6.2.2 - version: 6.3.0 - chai-as-promised: - specifier: ^8.0.0 - version: 8.0.2(chai@6.3.0) + version: 6.1.2(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0)) + c8: + specifier: ^12.0.0 + version: 12.0.0 eslint: specifier: 9.39.5 version: 9.39.5(supports-color@8.1.1) mermaid: specifier: ^11.0.0 version: 11.17.2 - mocha: - specifier: ^12.0.0 - version: 12.0.3 prettier: specifier: 3.9.10 version: 3.9.10 @@ -2057,10 +2048,10 @@ importers: version: 6.0.3 vite: specifier: ^8.0.0 - version: 8.3.5(@types/node@24.19.2)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0) + version: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0) vite-plugin-singlefile: specifier: ^2.3.3 - version: 2.3.4(vite@8.3.5(@types/node@24.19.2)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0)) + version: 2.3.4(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0)) packages/template-package: devDependencies: @@ -9289,10 +9280,10 @@ snapshots: transitivePeerDependencies: - supports-color - '@vitejs/plugin-react@6.1.2(vite@8.3.5(@types/node@24.19.2)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0))': + '@vitejs/plugin-react@6.1.2(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0))': dependencies: '@rolldown/pluginutils': 1.0.1 - vite: 8.3.5(@types/node@24.19.2)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0) + vite: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0) JSONStream@1.3.5: dependencies: @@ -13092,12 +13083,12 @@ snapshots: - utf-8-validate - zod - vite-plugin-singlefile@2.3.4(vite@8.3.5(@types/node@24.19.2)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0)): + vite-plugin-singlefile@2.3.4(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0)): dependencies: picomatch: 4.0.7 - vite: 8.3.5(@types/node@24.19.2)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0) + vite: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0) - vite@8.3.5(@types/node@24.19.2)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0): + vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(tsx@4.23.15)(yaml@2.9.0): dependencies: lightningcss: 1.33.0 picomatch: 4.0.7 @@ -13105,7 +13096,7 @@ snapshots: rolldown: 1.2.16 tinyglobby: 0.2.17 optionalDependencies: - '@types/node': 24.19.2 + '@types/node': 22.20.5 esbuild: 0.28.2 fsevents: 2.3.3 tsx: 4.23.15 diff --git a/scripts/test-file.ts b/scripts/test-file.ts index c3495184a35..9209df9b46a 100644 --- a/scripts/test-file.ts +++ b/scripts/test-file.ts @@ -34,7 +34,6 @@ EXAMPLES // These use Mocha or composite runners and aren't supported by test:file. // Remove entries here once a package migrates to node --test. const UNSUPPORTED_TEST_RUNNERS = new Set([ - "@nomicfoundation/ignition-ui", "@nomicfoundation/hardhat-ignition", "@nomicfoundation/ignition-core", "@nomicfoundation/example-project",