Skip to content

Share remote-server setup across endpoint-error tests (#1307 follow-up) #1313

@cliffhall

Description

@cliffhall

Background

In #1312, the new `endpoint error paths` describe block in `clients/web/src/test/core/remote-transport.test.ts` (code) spins up a fresh Hono server inside each `it` (10 tests). Each `startRemoteServer(0)` binds + closes a fresh socket, even though none of the tests mutate server state — they all just fire a request and assert response shape.

Proposed change

Fold the common setup into a `beforeEach` at the describe scope:

```ts
describe("endpoint error paths", () => {
let baseUrl: string;
let authToken: string;
beforeEach(async () => {
const started = await startRemoteServer(0);
remoteServer = started.server;
baseUrl = started.baseUrl;
authToken = started.authToken;
});
// each it() just fires a request against baseUrl/authToken
});
```

The same pattern likely applies to a few other describes in `remote-transport.test.ts` (the `storage` block, the `authentication` block) that also call `startRemoteServer(0)` inside every `it`. Easy follow-up scan.

Why

  • ~150ms shaved off the integration suite.
  • Tests describe the intent ("verify response-shape validation") rather than re-establishing the harness.
  • The afterEach already exists at the outer describe scope, so cleanup is unchanged.

Acceptance criteria

  • `endpoint error paths` (and any other server-spawning describes whose `it`s are pure request/response shape tests) share a single server per describe via `beforeEach`.
  • `npm run test:integration` still passes and runtime drops measurably.
  • No `it` mutates shared server state in a way the new structure breaks.

Out of scope

  • Reorganizing `remote-transport.test.ts` more broadly. This is a targeted cleanup.

Origin

PR #1312 review comment (observation #2).

Metadata

Metadata

Assignees

No one assigned

    Labels

    v2Issues and PRs for v2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions