Skip to content

test(compat): add SSR import smoke tests for framework packages - #250

Merged
truthixify merged 1 commit into
wraith-protocol:developfrom
lowfjell:test/ssr-import-smoke
Oct 16, 2026
Merged

truthixify merged 1 commit into
wraith-protocol:developfrom
lowfjell:test/ssr-import-smoke

Conversation

@lowfjell

Copy link
Copy Markdown
Contributor

Why

Framework companions can pass their jsdom tests while breaking server imports by reading browser globals. This adds a server-only import and minimal SSR smoke check to the existing pnpm test:compat job on Node 20, 22, and 24.

Closes #248

What changed

  • Discover every packages/sdk-* companion and require an SSR scenario for it.
  • Bundle each companion's source with dependencies external, then import it in a fresh Node process. Reads of browser globals from companion or core code fail with a source location. Third-party feature detection retains Node's normal behavior.
  • After import, restore the globals and render React, Vue, Svelte, or Solid, or instantiate the agent client. Empty inputs avoid network calls.

Scope

React and agent import and render successfully. Vue, Svelte, and Solid still fail to import because of #249. Each has a strict expected-failure entry for the missing core exports. A successful import or a different error fails the check, requiring removal or investigation of the entry.

The React Native entry is excluded. Fixing #249 remains separate. The three affected SSR scenarios cannot run normally until that fix lands.

Verification

Before this change, test:compat did not import framework companions. With this change, adding window.x; at the top of the React entry makes the full command exit 1 and report:

FAIL ssr import @wraith-protocol/sdk-react: reads browser global window at <anonymous> (packages/sdk-react/src/index.ts:1:1)

After reverting the planted read, test:compat passes again.

Verified locally on Node 22 after pnpm install --ignore-scripts:

  • pnpm build, pnpm test:compat, and pnpm format:check pass.
  • pnpm test passes with 1,453 tests plus 10 Svelte tests; five existing tests are skipped.
  • pnpm api:check, pnpm test:types, pnpm test:exports, and pnpm pack:check pass.

Revert

Safe to revert. Only compatibility scripts and documentation change. No published files, dependencies, or public APIs change, so no version bump is needed.

Import every packages/sdk-* companion in a server-only Node process with
window, document, storage and browser crypto trapped for the import, then
render or instantiate its minimal SSR path. Runs as a step of
pnpm test:compat, so the compat CI job covers it on Node 20, 22 and 24.

sdk-vue, sdk-svelte and sdk-solid are recorded as known import failures:
they import Wraith, WraithAgent and Chain from @wraith-protocol/sdk, which
stopped exporting them when sdk-agent became its own package. The entries are
strict, so the check fails once those imports are fixed until the entries
are removed.

Closes wraith-protocol#248
@drips-wave

drips-wave Bot commented Oct 16, 2026

Copy link
Copy Markdown

@lowfjell Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@truthixify truthixify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge ref passes the full build and compatibility suite on my local Node 24 run. The new check discovers every companion, isolates imports in fresh server processes, fails on authored import-time browser-global reads, and exercises the supported SSR paths. The three existing #249 failures are strict expected failures, so a successful import or a changed failure will make the suite fail until the exception is removed.

@truthixify truthixify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge ref passes the full build and compatibility suite on my local Node 24 run. The new check discovers every packages/sdk-* companion, isolates imports in fresh server processes, fails on authored import-time browser-global reads, and exercises the supported SSR paths. The three existing #249 failures are strict expected failures, so a successful import or a changed failure will make the suite fail until the exception is removed.

@truthixify
truthixify merged commit 7e7a247 into wraith-protocol:develop Oct 16, 2026
22 checks passed
@lowfjell
lowfjell deleted the test/ssr-import-smoke branch October 16, 2026 13:53
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.

[Wave 10] Add SSR import smoke tests for every framework package

2 participants