Uh oh!
There was an error while loading. Please reload this page.
tests: Add E2E Tests for MCP Worker - #488
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| export function createMockEnv(overrides: Partial<Env> = {}): Env { | ||
| return { | ||
| NODE_ENV: 'test', | ||
| API_BASE_URL: 'https://api-test.devcycle.com', | ||
| AUTH0_DOMAIN: 'test-auth.devcycle.com', | ||
| AUTH0_AUDIENCE: 'https://api-test.devcycle.com/', | ||
| AUTH0_SCOPE: 'openid profile email offline_access', | ||
| AUTH0_CLIENT_ID: 'test-client-id', | ||
| AUTH0_CLIENT_SECRET: 'test-client-secret', |
There was a problem hiding this comment.
shouldn't these be in the fixtures?
| [key: string]: any; | ||
| }, options?: DynamicDispatchOptions): Fetcher; | ||
| } | ||
| declare module 'cloudflare:test' { |
There was a problem hiding this comment.
duplicate definition from mcp-worker/test-types.d.ts?
There was a problem hiding this comment.
this file is auto-generated from wrangler, so not sure. Will run the type gen again and see.
…dflare Workers testing pool
- update vitest to ^3.2.4 and @cloudflare/vitest-pool-workers to ^0.8.62 - add @types/estree@1.0.5 resolution to fix TypeScript build errors - ensure both yarn test and yarn build work correctly
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
dbb33d7 to
5545341CompareThere was a problem hiding this comment.
Pull Request Overview
This PR introduces comprehensive end-to-end testing infrastructure for the MCP worker using Vitest and Cloudflare Workers testing pool.
- Sets up E2E test suite covering MCP protocol compliance, tool discovery, and worker startup functionality
- Configures Vitest with Cloudflare Workers testing pool for realistic worker environment testing
- Creates test-specific worker entry point to avoid AJV compatibility issues during testing
Reviewed Changes
Copilot reviewed 14 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updates test scripts to include worker tests and pins @types/estree version |
| mcp-worker/vitest.config.ts | Configures Vitest with Cloudflare Workers testing pool |
| mcp-worker/wrangler.test.toml | Test environment configuration for the worker |
| mcp-worker/tsconfig.json | Updates TypeScript config to include test files and types |
| mcp-worker/package.json | Adds Vitest and testing dependencies |
| mcp-worker/src/test-index.ts | Mock worker entry point for testing |
| mcp-worker/test/setup.ts | Global test setup file |
| mcp-worker/test/helpers/* | Test utilities for MCP client, fixtures, and auth mocking |
| mcp-worker/test/e2e/*.test.ts | E2E test suites for protocol compliance and functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Create a simple base64-encoded mock JWT (not cryptographically valid) | ||
| const header = btoa(JSON.stringify({ typ: 'JWT', alg: 'HS256' })) | ||
| const encodedPayload = btoa(JSON.stringify(payload)) |
There was a problem hiding this comment.
The mock JWT creation uses btoa() which is not available in the Cloudflare Workers runtime. Consider using a base64 encoding method compatible with the Workers environment.
| constencodedPayload=btoa(JSON.stringify(payload)) | |
| constheader=base64Encode(JSON.stringify({typ: 'JWT',alg: 'HS256'})) | |
| constencodedPayload=base64Encode(JSON.stringify(payload)) |
| const mockJWT = createMockJWT(jwtClaims) | ||
| // Parse the claims from the mock JWT | ||
| const payload = JSON.parse(atob(mockJWT.split('.')[1])) |
There was a problem hiding this comment.
The atob() function is not available in the Cloudflare Workers runtime. Use a base64 decoding method compatible with the Workers environment instead.
| constpayload=JSON.parse(atob(mockJWT.split('.')[1])) | |
| constpayload=JSON.parse(base64Decode(mockJWT.split('.')[1])) |
| 'createDevCycleVariation', | ||
| 'updateDevCycleVariation', | ||
| ] | ||
There was a problem hiding this comment.
The expectedToolNames array is defined but not used in the actual tests. This creates a maintenance burden as it may become outdated. Consider using this list in the test assertions or remove it if not needed.
| * | |
| */ |
jonathannorris
commented
Aug 14, 2025
These tests need a bunch of working, going to make them draft again |
This PR introduces comprehensive end-to-end testing infrastructure for the MCP worker using Vitest and Cloudflare Workers testing pool.
Changes
@types/estree@1.0.5to maintain build compatibilityTesting
yarn test:worker- Run the new E2E testsyarn build- Verified TypeScript compilation works correctlyFiles Added
mcpProtocol.test.ts,tools.test.ts,startup.test.ts,minimal.test.tsvitest.config.ts,wrangler.test.tomlAll tests passing ✅