Skip to content

test(routes): make route-lifecycle test pass under the core resolver - #28

Merged
Upd4ting merged 1 commit into
mainfrom
fix/route-lifecycle-test-identity
Sep 24, 2026
Merged

Upd4ting merged 1 commit into
mainfrom
fix/route-lifecycle-test-identity

Conversation

@Upd4ting

Copy link
Copy Markdown
Member

Summary

src/tests/route-lifecycle.test.ts ("getRegisteredRouteHandlers" > "returns complete registered handlers without replacing the provider") passes in this repo but fails when run from an implementation module such as @antelopejs/api, because ajs module test there also runs the tests shipped in node_modules/@antelopejs/interface-api/dist/tests/.

Root cause: with @antelopejs/core >= 1.4.11, the shipped test's require("../index") is resolved as an interface import, so the exported functions are facades and every value passed to RegisterRoute(handler) is bound through the core. Objects holding functions become facades, so the registered handler stores wrapped callback, parameters and properties, and the reference checks (assert.strictEqual(registered.handler.callback, original.callback), and the same for the provider's onRegister payload) fail. In this repo ../index is a plain local import, so identity holds. The facades are intentional core behavior (module context capture, GetResponsibleModule, unload cleanup); no runtime or core change is needed.

What changed (test only):

  • callback: asserted by calling it (returns the route location) instead of by reference.
  • parameters / properties: structure asserted (length, null slot, keys, empty modifiers) and each provider still returns "parameter".
  • proto: deepEqual.
  • Provider not replaced: the onRegister payload and the registered handler are compared on stable fields (location, method, mode, module, priority) instead of object identity.
  • Kept: module is set on the registered handler and not added to the original object.
  • The explanatory comment now states that these tests also run from implementation modules under the core resolver, where passed values are facades.

No change to src/index.ts, dependencies, or antelope.test.ts.

A patch release of @antelopejs/interface-api is needed after merging so that the api repository can move to the latest interface version with a green test suite.

Related issue

None; the failure was found while bumping @antelopejs/interface-api to 0.0.13 and @antelopejs/core to 1.9.1 in AntelopeJS/api.

Verification

This repository (ajs 1.9.1, loopback-only network namespace because port 5010 is in use on the host):

  • pnpm prepack, pnpm lint (no new warnings), pnpm format:check, pnpm knip: pass
  • pnpm test: 83 passing, 0 failing

Implementation context (throwaway clone of AntelopeJS/api main, not pushed): @antelopejs/interface-api 0.0.13 and @antelopejs/core 1.9.1 installed, then node_modules/@antelopejs/interface-api/dist replaced with this branch's build, and pnpm test run:

  • Before (published 0.0.13 tests): 199 passing, 1 failing (Expected "actual" to be reference-equal to "expected" on completeRouteCallback)
  • After (this branch): 200 passing, 0 failing

Checklist

  • The pull request title follows Conventional Commits.
  • I added or updated tests when behavior changed.
  • I updated documentation when users or contributors are affected. (N/A: test-only change)
  • I documented breaking changes and migration steps. (N/A: no breaking change)
  • I did not include credentials or unrelated changes.

@Upd4ting
Upd4ting merged commit be195f9 into main Sep 24, 2026
2 checks passed
@Upd4ting
Upd4ting deleted the fix/route-lifecycle-test-identity branch September 24, 2026 07:26
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