Skip to content

fix(tests): stop partial mock.module calls from dropping real exports#13

Merged
rldyourmnd merged 2 commits into
mainfrom
fix/mock-module-export-drops
Jul 24, 2026
Merged

fix(tests): stop partial mock.module calls from dropping real exports#13
rldyourmnd merged 2 commits into
mainfrom
fix/mock-module-export-drops

Conversation

@rldyourmnd

Copy link
Copy Markdown

What

Three CI suites have been failing on mainclaw-server, agent, and server-api. They share one root cause.

Bun's mock.module replaces the whole module for the remainder of a bun test run and leaks across files. A factory that returns only the symbol under test therefore deletes every other export. The next file that loads and imports a dropped symbol dies with Export named 'X' not found, surfaced as an unhandled error between tests rather than a failing assertion.

Suite Poisoner Dropped export
claw-server tests/services/tab-group-ops.test.ts textResult (browser-mcp tool framework)
agent modules/llm-providers/oauth-provider-flow.hooks.test.ts providerTemplates, providerTypeOptions
server-api tests/api/services/chat-service.test.ts tool (the ai package)

server-api looked environmental because that job also logs Chromium/dbus noise and an AppImage cache miss. It is not — the browser started fine and the workflow handles the cache miss.

The fix is the idiom two sibling tests already used: import the real module and spread it, overriding only what the test needs.

Why it was invisible locally

macOS and Linux walk directories in different orders. On macOS the real module happens to load first, so the suites pass. Each fix was therefore proven with an explicit two-file ordering that fails before and passes after — not by running the suite and hoping.

Also fixed

Forcing every mock.module file to run first within its CI group surfaced two more latent instances: provider-factory-acp dropped most of node:fs/promises and browseros-dir, and metrics blanked INLINED_ENV, which src/config.ts reads.

The misleading comments that argued for the partial mocks were corrected too.

Verification

Suite Result
claw-server 370 pass / 0 fail
app 292 pass / 0 fail
server-api / agent / lib 154 / 301 / 266 pass, 0 fail
bun run check exit 0

Not fixed, reported honestly

tests/lib/mcp-manager/reconcile.test.ts fails under some multi-file orderings. It is an assertion mismatch from shared singleton state, not this export-drop class, and it does not occur in CI order (server-lib is green). It could not be narrowed to a minimal repro, so it was left alone rather than guessed at.

Second commit

docs/nddev-fork.md §3 described a six-hourly upstream auto-merge that opens a conflict issue. The workflow is Upstream Sync (Quarantined)workflow_dispatch only, printing a stop condition, because the fork and upstream have no common ancestor. fork-lifecycle.md explicitly forbids claiming the relationship is synchronized, and issues are disabled on this repository so the conflict-issue path could not work either.

Bun's mock.module replaces the whole module for the rest of the run and leaks
across files, so a factory that returns only the symbol under test silently
deletes every other export. Any file that loads later and imports a dropped
symbol dies with 'Export named X not found', which is reported as an unhandled
error between tests rather than as a failing assertion.

This broke three CI suites, each with a different victim: claw-server dropped
textResult from browser-mcp's tool framework, agent dropped providerTemplates
and providerTypeOptions, and server-api dropped tool from the ai package. The
last one looked environmental because the job also logs Chromium dbus noise; it
is not.

The suites pass on macOS because directory traversal order differs from Linux
and happens to load the real module first. Each fix was proven with an explicit
two-file ordering that fails before and passes after.

Two further latent instances were found by forcing every mock.module file to run
first within its CI group: provider-factory-acp dropped most of node:fs/promises
and browseros-dir, and metrics blanked INLINED_ENV, which src/config.ts reads.

Suites now: claw-server 370, app 292, server-api 154, agent 301, lib 266, all
with zero failures; bun run check exits 0.
Section 3 described a workflow that merges upstream every six hours and opens a
tracking issue on conflict. That workflow is Upstream Sync (Quarantined):
workflow_dispatch only, contents: read, and its single job prints the stop
condition. The fork and upstream have no common ancestor, so an ordinary merge
cannot synchronize them.

fork-lifecycle.md already forbids claiming the upstream relationship is
synchronized, so the section contradicted the repository's own rule. It also
described opening a conflict issue, which cannot work because this repository
has issues disabled.
@github-actions github-actions Bot added the fix label Jul 24, 2026
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

✅ Tests passed — 1446/1450

Suite Passed Failed Skipped
agent 292/292 0 0
build 32/32 0 0
⚠️ claw-app 0/0 0 0
⚠️ claw-onboard 0/0 0 0
⚠️ claw-server 0/0 0 0
eval 91/91 0 0
server-agent 301/301 0 0
server-api 154/154 0 0
server-browser 10/10 0 0
server-integration 10/10 0 0
server-lib 265/266 0 1
server-root 37/40 0 3
server-tools 254/254 0 0

View workflow run

@rldyourmnd
rldyourmnd merged commit 85cb2ff into main Jul 24, 2026
33 of 34 checks passed
@rldyourmnd
rldyourmnd deleted the fix/mock-module-export-drops branch July 24, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant