Skip to content

Restore Node.js test registration in ESM - #1039

Merged
dahlia merged 1 commit into
fedify-dev:2.0-maintenancefrom
dahlia:bugfix/node-test
Sep 18, 2026
Merged

dahlia merged 1 commit into
fedify-dev:2.0-maintenancefrom
dahlia:bugfix/node-test

Conversation

@dahlia

@dahlia dahlia commented Sep 17, 2026

Copy link
Copy Markdown
Member

On 2.0-maintenance, @fedify/fixture swallows the missing require() error in ESM, so Node.js reports passing files without running their tests. This ports the createRequire() fix from fab1c07, removes the catch, and keeps Workers on its test-collection path without changing the maintenance branch's test API.

Regression tests load the built ESM/CJS exports in separate Node.js processes, so the adapter cannot silently skip its own tests. The newly running actor tests use public IP literals to avoid DNS lookups before mocked fetches, and await rejects() so failures reach the runner.

Affected Node/Deno/Bun suites, mise run check, and a local Workers smoke test pass. The full Node.js run still has unrelated ansi-escapes dependency failures in @fedify/init, @fedify/create, and @fedify/cli.

Fixes #1036.

The fixture swallowed require() errors in ESM, so Node reported passing
files without executing their tests.  Resolve node:test with
createRequire and let registration errors propagate, while retaining
Workers' collection path and the existing maintenance-branch test API.

Add independent subprocess checks for both package export formats, test
and step failures, ignored tests, registration errors, and Workers-like
collection.  Use public IP literals and await rejects() in the newly
exercised actor tests so Node's address validation does not depend on
DNS.

Partially port the registration fix from
fab1c07.  When forwarding to main,
retain its portable test types and corrected step behavior, merge the
subprocess checks with its existing type tests, and keep its equivalent
actor fix. Re-run vocab on each maintenance branch, especially 2.3's
extra actor tests.

Validated mise run check, affected Node/Deno/Bun suites, and a local
Workers MemoryKvStore test.  Full Node testing passed 23 package suites;
init/create/cli still fail because inquirer-toggle lacks ansi-escapes,
reproduced independently of the fixture.

Independent code reviews used OpenCode (deepseek-flash), Codex
(gpt-6-astra), and Claude Code (claude-fable-5-1).  Claude Code
(claude-opus-5) reviewed the implementation plan.

Fixes fedify-dev#1036

Changelog: none
Assisted-by: Codex:gpt-6-astra
Assisted-by: Claude Code:claude-opus-5
@dahlia dahlia self-assigned this Sep 17, 2026
@dahlia dahlia added runtime/node Node.js runtime related component/testing Testing utilities (@fedify/testing) labels Sep 17, 2026
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 7c3b239f-ba6b-4e2a-aaf3-1c884d5c287b

📥 Commits

Reviewing files that changed from the base of the PR and between d863a12 and cd3a6cc.

📒 Files selected for processing (3)
  • packages/fixture/src/test.test.ts
  • packages/fixture/src/test.ts
  • packages/vocab/src/actor.test.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The fixture harness now loads node:test only in supported Node environments. New probes cover ESM, CommonJS, failure behavior, ignored tests, registration errors, and Workers collection. The actor handle test uses IP-based WebFinger mocks and awaits its rejection assertion.

Changes

Fixture Node registration

Layer / File(s) Summary
Guarded Node test loading
packages/fixture/src/test.ts
The harness uses createRequire to load node:test when running on Node outside Cloudflare Workers. Other runtimes skip test execution and retain definitions in testDefinitions.
Fixture runtime probes
packages/fixture/src/test.test.ts
Isolated ESM and CommonJS probes verify registration, execution, failure propagation, ignored callbacks, registration failures, and Workers collection.

WebFinger test stability

Layer / File(s) Summary
WebFinger mock and assertion updates
packages/vocab/src/actor.test.ts
WebFinger mocks use 1.1.1.1 and 8.8.8.8. Expected handles and actor identifiers use the new hosts. The no-WebFinger rejection assertion is awaited.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant ProbeProcess
  participant FixtureHarness
  participant NodeTest
  participant TestDefinitions
  ProbeProcess->>FixtureHarness: Load fixture and register tests
  FixtureHarness->>NodeTest: Register tests in supported Node
  NodeTest-->>ProbeProcess: Emit test results and diagnostics
  FixtureHarness->>TestDefinitions: Collect definitions in Workers
  TestDefinitions-->>ProbeProcess: Expose collected definitions without execution
Loading

Merge Risk: ⚪ Minimal · up to cd3a6

The Node registration fix preserves the supported Workers configuration and is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: restoring Node.js test registration for ESM builds.
Description check ✅ Passed The description directly explains the Node.js ESM registration failure, the createRequire() fix, preserved Workers behavior, regression tests, and validation results.
Linked Issues check ✅ Passed Issue #1036 requires Node.js registration for fixture tests, preserved Workers collection, preserved maintenance-branch API, and regression coverage. packages/fixture/src/test.ts now uses `createReq…
Out of Scope Changes check ✅ Passed The actor-test changes use public IP literals and await rejects() so the newly active Node.js tests do not fail because of DNS resolution or an unobserved promise. These changes support the registra…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dahlia
dahlia requested review from 2chanhaeng and sij411 September 17, 2026 16:25
@dahlia
dahlia merged commit 1a2b510 into fedify-dev:2.0-maintenance Sep 18, 2026
17 checks passed
@dahlia
dahlia deleted the bugfix/node-test branch September 18, 2026 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/testing Testing utilities (@fedify/testing) runtime/node Node.js runtime related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@fedify/fixture's test() registers nothing on Node.js in 2.0-maintenance

1 participant