chore: migrate tests from mocha/chai to node:test#3044
Closed
bennypowers wants to merge 15 commits intonode24/typescript-upgradefrom
Closed
chore: migrate tests from mocha/chai to node:test#3044bennypowers wants to merge 15 commits intonode24/typescript-upgradefrom
bennypowers wants to merge 15 commits intonode24/typescript-upgradefrom
Conversation
🦋 Changeset detectedLatest commit: 225cfca The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This was referenced Mar 17, 2026
b5e6238 to
32ba55e
Compare
0a62b2c to
badf76c
Compare
badf76c to
059908a
Compare
037552b to
0c3de8d
Compare
- Migrate all test files across ~20 packages to Node.js native test runner - Replace mocha describe/it/before/after with node:test equivalents - Replace chai expect/assert with node:assert/strict - Update package.json test scripts to use `node --test` - Add tsx devDependency to test-runner-core for TypeScript test execution - Move rollup-plugin-html tests from test/src/ to test/ - Replace mocha-based test files with .mjs equivalents where needed - Add changeset for browser-logs test migration Tests only — no production source code changes. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The tsx devDependency added to test-runner-core was missing from the lock file, causing npm ci to fail. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix 48 test files with merge conflict markers from rebase - Remove unused path imports in test files flagged by eslint - Regenerate package-lock.json Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix config-loader, parse5-utils test imports to use src/ not dist/ - Fix rollup-plugin-copy, rollup-plugin-import-meta-assets test imports to use .js not .ts (JSDoc packages still have .js source on PR2) - Fix dev-server-core exports map: use "default" condition instead of "require"/"import" for Node 24 ESM compatibility - Resolve merge conflict markers in test files - Remove unused path imports Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
49b4991 to
2cc8e4e
Compare
- Add --experimental-transform-types flag to all node --test commands (needed for .ts import resolution without "type": "module") - Copy source files from fix/node24 for correct import type keywords and CJS interop (browser-compat-data, ua-parser-js, etc.) - Restore parse5 v6 types and CJS-compatible code for pre-PR3 output - Fix typeof comparison in rollupAdapter Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace hardcoded column offsets (N:23) with regex patterns (N:\d+) in browser-logs error stack trace tests. Column offsets vary by browser version and shouldn't be hardcoded. - Add --test-timeout 120000 to all node --test commands to prevent 30-minute hangs on Windows when a test server fails to shut down. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Node 24 native type stripping requires explicit `import type` for type-only parse5 imports (Document, Node, Element, Attribute, etc.). Without this, named imports fail at runtime because the types are stripped from the module's exports. Also fix remaining .js -> .ts import rewrites in multi-line from clauses that were missed by previous sed runs. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Node 24 runs .ts source files as ESM (native type stripping), so require.resolve() and __dirname are unavailable. Use import.meta.resolve() and import.meta.dirname with @ts-ignore to suppress TS1470 (import.meta not allowed in CJS output). The CJS output with import.meta is technically invalid but the dist isn't executed directly until PR3 adds "type": "module". Tests run source files directly on Node 24 where it works. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Revert source files that use import.meta back to __dirname and require.resolve. The import.meta in CJS compiled output causes Node to reparse as ESM, breaking dist execution. Source files will be migrated to import.meta in PR3 when "type": "module" is added. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests for packages whose source uses require.resolve/__dirname must import from compiled dist/ (CJS) instead of src/ (TS treated as ESM by Node 24). This avoids "require is not defined" errors. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
node --test doesn't exit when open handles remain (servers, browsers, sockets). Add --test-force-exit to force process exit after all tests complete, preventing 30-minute CI job timeouts. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
Replaced by #3049 (combined with PR3) |
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.
Summary
node:test+node:assertnode --experimental-transform-types --test--test-timeout 120000to prevent Windows hangstest/src/totest/import type) for Node 24 native type stripping compatibilitydist/for packages with CJS source deps (require.resolve, __dirname)Tests only -- no production source code changes. This is PR 2 of 4 in the Node 24 migration stack.
CI Status
Lint, browser tests, and storybook verification pass. Node test verification has 11 packages failing due to CJS interop issues (
require.resolvein transitive source deps loaded by Node 24 as ESM). These are resolved in PR3 when"type": "module"is added. Windows storybook fails due to a pre-existing lightningcss native module issue.Stack
node24/typescript-upgrade-- TypeScript upgrade +.tsimports (chore: upgrade TypeScript to 5.9.3 and enable .ts imports #3043)node24/esm-and-node24-- CJS to ESM + Node 24 requirement (feat!: require Node 24 and migrate CJS to ESM output #3045)node24/parse5-and-jsdoc-- parse5 v8 + JSDoc to TS conversions (feat!: migrate parse5 to v8 and convert JSDoc packages to TypeScript #3046)Test plan
npm run buildpasses with zero TS errorsGenerated with Claude Code