Skip to content

test(webauthn): select mock.module option shape by Node version (#692)#720

Merged
millsmillsymills merged 1 commit into
mainfrom
fix/692-mock-module-exports-shim
Jun 10, 2026
Merged

test(webauthn): select mock.module option shape by Node version (#692)#720
millsmillsymills merged 1 commit into
mainfrom
fix/692-mock-module-exports-shim

Conversation

@millsmillsymills

Copy link
Copy Markdown
Owner

What

infra/lambdas/webauthn_demo/tests/verify-success.test.mjs mocked @simplewebauthn/server via mock.module(..., { namedExports }). The single exports option — and the DeprecationWarning for the legacy namedExports/defaultExport keys — landed in Node 25.9.0 (nodejs/node#61727, released 2026-04-01). CI pins Node 22 (only understands namedExports, silently ignores exports); local toolchains on Node 25.9+ emit the deprecation warning, tripping the zero-warnings policy on scripts/ci-local.sh.

This selects the option shape the running Node supports:

const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(Number);
const supportsExportsOption = nodeMajor > 25 || (nodeMajor === 25 && nodeMinor >= 9);
  • CI (Node 22)namedExports branch — byte-equivalent to the prior code, stays green.
  • Local (Node 25.9+)exports branch — warning-free.

A naive swap to exports was rejected: it silently no-ops the mock on Node 22 (unknown option ignored → verified:true never forced → the four success tests fail). Verified empirically against the real mock.module API on Node 22 vs 25.9.

Verification

Exact CI command on local Node 25.9.0:

node --experimental-test-module-mocks --disable-warning=ExperimentalWarning --test 'infra/lambdas/webauthn_demo/tests/**/*.test.mjs'
→ tests 41 / pass 41 / fail 0 — NO warnings (previously: DeprecationWarning on namedExports)

Closes #692

🤖 Generated with Claude Code

`options.exports` and the `DeprecationWarning` for the legacy
`namedExports`/`defaultExport` keys landed in Node 25.9.0 (nodejs/node
#61727). CI pins Node 22, which only understands `namedExports`, while
local toolchains on Node 25.9+ trip the deprecation warning under the
zero-warnings policy.

Feature-detect the running Node version and pass `exports` where
supported, falling back to `namedExports` on Node 22. The CI runtime
takes the unchanged `namedExports` branch; newer local runs go warning-free.

Closes #692

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@millsmillsymills millsmillsymills merged commit 1358bd8 into main Jun 10, 2026
5 checks passed
@millsmillsymills millsmillsymills deleted the fix/692-mock-module-exports-shim branch June 10, 2026 02: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.

Migrate webauthn_demo test mocks off deprecated mock.module namedExports before Node bump

1 participant