test(mobile): narrow the incompatible-reply error by instanceof, not by cast

The two new tests in f741b2ea82 read the error through `as` casts, which the
changed-code casting gate rejects. An `instanceof` guard narrows the same value
and checks the class at the same time.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
This commit is contained in:
Jinwoo-H
2026-09-15 23:21:08 -04:00
parent 5f3f184fdf
commit 71d8c6a1e2
+7 -6
View File
@@ -330,12 +330,13 @@ describe('an incompatible reply', () => {
{}
).catch((thrown: unknown) => thrown)
expect((caught as Error).message).toBe(
'The host sent a reply this app could not read (worktree.ps)'
)
expect((caught as Error).message).not.toContain('incompatible_reply')
expect((caught as RpcIncompatibleReplyError).code).toBe(RPC_INCOMPATIBLE_REPLY_CODE)
expect((caught as Error).name).toBe('RpcIncompatibleReplyError')
if (!(caught instanceof RpcIncompatibleReplyError)) {
throw new Error('expected an incompatible-reply error')
}
expect(caught.message).toBe('The host sent a reply this app could not read (worktree.ps)')
expect(caught.message).not.toContain('incompatible_reply')
expect(caught.code).toBe(RPC_INCOMPATIBLE_REPLY_CODE)
expect(caught.name).toBe('RpcIncompatibleReplyError')
})
// A second bundle copy of this module fails `instanceof`, so the name is the fallback.