Skip to content

test(dev-server-rollup): migrate tests from mocha/chai to node:test#3096

Open
bennypowers wants to merge 1 commit into
masterfrom
migrate/dev-server-rollup-node-test
Open

test(dev-server-rollup): migrate tests from mocha/chai to node:test#3096
bennypowers wants to merge 1 commit into
masterfrom
migrate/dev-server-rollup-node-test

Conversation

@bennypowers
Copy link
Copy Markdown
Member

Summary

  • Migrate all 8 test files and shared test-helpers from mocha/chai to node:test/node:assert/strict
  • Replace __dirname with import.meta.dirname throughout
  • Change source imports (../../src/) to dist imports (../../dist/) for native type stripping compatibility
  • Change local .js imports to .ts (strip-types cannot resolve .js to .ts)
  • Convert this.timeout(N) to { timeout: N } test option
  • Add createRequire(import.meta.url) for require.resolve() in babel tests
  • Add import type for type-only imports (DevServerCoreConfig, Logger, RollupPlugin, AstNode)
  • Use quoted glob in test script so Node's built-in glob expansion handles nested directories
  • Remove mocha and chai devDependencies

Pre-existing issues noticed (not fixed here)

  • babel.test.ts describe block says @rollup/plugin-alias instead of @rollup/plugin-babel (copy-paste error)
  • node-resolve.test.ts:71 has a leftover console.log(text) debugging statement

Test plan

  • All 43 tests pass locally on Node 22.22.3 (8 files, 11 suites)
  • Browser-based tests pass with CHROME_PATH set
  • Lint passes
  • Verified quoted glob is necessary for npm scripts (sh does not expand ** recursively)

Replace mocha/chai with node:test and node:assert/strict across all 8
test files and the shared test-helpers module. Key changes:

- describe/it from node:test, assert from node:assert/strict
- __dirname replaced with import.meta.dirname
- Source imports (../../src/) changed to dist imports (../../dist/)
- Local .js imports changed to .ts (strip-types can't resolve .js->.ts)
- this.timeout(N) converted to { timeout: N } test option
- require.resolve() in babel tests uses createRequire(import.meta.url)
- import type for type-only imports (DevServerCoreConfig, RollupPlugin)
- Test script uses quoted glob for node's built-in glob expansion
- Removed mocha and chai devDependencies

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

changeset-bot Bot commented Jun 2, 2026

⚠️ No Changeset found

Latest commit: 8534981

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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