test: share remote-server setup across response-shape describes (#1313)#1319
Conversation
Hoist startRemoteServer(0) out of per-it() bodies into describe-scope beforeAll/afterAll for the authentication, dangerouslyOmitAuth, endpoint-error-paths, and Origin-validation describes — every it() in these blocks only fires a single request and asserts response shape, so one shared server per describe is safe. Storage and additional-coverage describes are unchanged: their tests mutate per-test filesystem state at common paths or use heterogeneous server options, so sharing would require reorganizing the suite (out of scope per the issue). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@claude review |
|
Claude finished @cliffhall's task in 1m 15s —— View job Code Review
SummaryThis is a clean, well-scoped cleanup that matches what the PR description promises. The four targeted describes ( Correctness
Minor observations (non-blocking)
Verification
VerdictLooks good to merge. The refactor does exactly what the linked issue asks for, within the scope the issue explicitly set. Non-refactored blocks ( |
Summary
startRemoteServer(0)out of per-it()bodies into describe-scopebeforeAll/afterAllforauthentication,when dangerouslyOmitAuth is true,endpoint error paths, andOrigin validationinclients/web/src/test/integration/mcp/remote/transport.test.ts. Eachit()in these blocks only fires a single request and asserts response shape, so one shared server per describe is safe.Origin validationis split into two nested describes (with allowedOrigins configured/without allowedOrigins configured) because one test needs a server with different options.Scope notes
beforeEach, but the acceptance criterion "runtime drops measurably (~150ms)" only holds withbeforeAll—beforeEachstill spawns one server per test and saves no socket bind/close time. UsingbeforeAllmakes the cleanup local (ownafterAll) so the outerafterEach'sif (remoteServer)check skips these servers naturally.storageandadditional coverage pathsdescribes are intentionally not changed:storage: 6 of 13 tests read/write the same path/api/storage/test-storeand would collide on a shared server. Refactoring would require unique storeIds per test, which is reorganizing the suite.additional coverage paths: tests with no options are interspersed with tests usinglogger/storageDir/mcpHttpServer. Sharing would require splitting into option-grouped sub-describes — also a reorganization.Result
npm run test:integrationcumulative test time: 85.80s → 84.80s (≈1s saved; e2e tests dominate per-file numbers).npm run validateandnpm run test:storybookboth pass.Test plan
npm run test:integrationpassesnpm run validatepassesnpm run test:storybookpasses🤖 Generated with Claude Code