Skip to content

feat!: migrate tests to node:test and require Node 24#3049

Draft
bennypowers wants to merge 5 commits intonode24/typescript-upgradefrom
node24/test-and-esm
Draft

feat!: migrate tests to node:test and require Node 24#3049
bennypowers wants to merge 5 commits intonode24/typescript-upgradefrom
node24/test-and-esm

Conversation

@bennypowers
Copy link
Member

Summary

BREAKING CHANGE: Node 24+ is now required. All packages emit ESM output.

Combined test migration (formerly PR2) + CJS-to-ESM (formerly PR3):

Test migration

  • Migrate all test files from mocha/chai to node:test + node:assert
  • Use --experimental-transform-types --test-force-exit --test-timeout
  • Fix browser-logs stack trace assertions (regex instead of hardcoded column offsets)
  • Add import type to all type-only imports/exports across ~125 source files
  • Split parse5 type imports for Node 24 native type stripping compatibility

CJS to ESM

  • Add "type": "module" to all TypeScript packages
  • Update exports to use "default" condition, remove "module" field
  • Delete 34 index.mjs shim files
  • Fix CJS interop (import.meta.resolve, createRequire, import.meta.dirname)
  • Keep JSDoc packages (parse5-utils, config-loader, etc.) as CJS until PR3
  • Strip ESM export keywords from browser-injected scripts
  • Add .nvmrc (v24.11.1)
  • Update CI workflows to Node 24

Stack (3 PRs)

  1. node24/typescript-upgrade -- TypeScript upgrade + .ts imports (chore: upgrade TypeScript to 5.9.3 and enable .ts imports #3043)
  2. This PR -- test migration + CJS to ESM + Node 24 requirement
  3. 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 build passes with zero TS errors
  • Lint passes
  • Tests exit promptly (no 30-minute hangs)
  • CI passes

Generated with Claude Code

Combined PR2 (test migration) + PR3 (CJS to ESM):

Test migration:
- Migrate all test files from mocha/chai to node:test + node:assert
- Use --experimental-transform-types --test-force-exit --test-timeout
- Fix browser-logs stack trace assertions (regex instead of hardcoded columns)
- Split parse5 type imports for Node 24 native type stripping
- Add import type to all type-only imports/exports for verbatimModuleSyntax compat

CJS to ESM:
- Add "type": "module" to all TypeScript packages
- Update exports to use "default" condition
- Delete index.mjs shim files
- Fix CJS interop (import.meta.resolve, createRequire, import.meta.dirname)
- Keep JSDoc packages (parse5-utils, config-loader, etc.) as CJS
- Strip ESM export keywords from browser-injected scripts
- Add .nvmrc (v24.11.1)
- Update CI workflows to Node 24

BREAKING CHANGE: Node 24+ is now required.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Mar 24, 2026

🦋 Changeset detected

Latest commit: 2e5c050

The changes in this PR will be included in the next version bump.

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

- Update 21 packages' test scripts from fix/node24 (mocha -> node --test)
- Add --test-force-exit --test-timeout --experimental-transform-types flags
- Fix remaining .js -> .ts imports in test files
- Fix type-only imports (EntrypointBundle, etc.)

Note: 8 test-runner packages still use mocha because fix/node24
didn't migrate their browser-based integration tests.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Convert remaining .js -> .ts in test file imports
- Revert .ts back to .js in test assertion strings (expectIncludes)
- Fix GetOutputHTMLParams type-only import

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dev-server-import-maps test config referenced ../index.mjs which was
deleted. Import from ../dist/index.js instead.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@storybook/preview/globals renamed 'globals' to 'globalPackages'
in newer versions. The ESM export doesn't include the old name.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant