Skip to content

Commit 5545341

Browse files
test: centralize mock env defaults in fixtures and update createMockEnv
1 parent b39690f commit 5545341

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

mcp-worker/test/helpers/auth.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { UserProps, DevCycleJWTClaims } from '../../src/types'
2+
import { defaultEnv } from './fixtures'
23

34
/**
45
* Creates a mock JWT token for testing
@@ -77,16 +78,9 @@ export function createMockOAuthKV() {
7778
*/
7879
export function createMockEnv(overrides: Partial<Env> = {}): Env {
7980
return {
80-
NODE_ENV: 'test',
81-
API_BASE_URL: 'https://api-test.devcycle.com',
82-
AUTH0_DOMAIN: 'test-auth.devcycle.com',
83-
AUTH0_AUDIENCE: 'https://api-test.devcycle.com/',
84-
AUTH0_SCOPE: 'openid profile email offline_access',
85-
AUTH0_CLIENT_ID: 'test-client-id',
86-
AUTH0_CLIENT_SECRET: 'test-client-secret',
87-
ENABLE_OUTPUT_SCHEMAS: 'false',
81+
...defaultEnv,
8882
OAUTH_KV: createMockOAuthKV(),
89-
MCP_OBJECT: {} as any, // Mock Durable Object
83+
MCP_OBJECT: {} as any,
9084
...overrides,
9185
} as Env
9286
}

mcp-worker/test/helpers/fixtures.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,17 @@ export const mockApiResponses = {
8484
},
8585
],
8686
}
87+
88+
/**
89+
* Default test environment values
90+
*/
91+
export const defaultEnv = {
92+
NODE_ENV: 'test',
93+
API_BASE_URL: 'https://api-test.devcycle.com',
94+
AUTH0_DOMAIN: 'test-auth.devcycle.com',
95+
AUTH0_AUDIENCE: 'https://api-test.devcycle.com/',
96+
AUTH0_SCOPE: 'openid profile email offline_access',
97+
AUTH0_CLIENT_ID: 'test-client-id',
98+
AUTH0_CLIENT_SECRET: 'test-client-secret',
99+
ENABLE_OUTPUT_SCHEMAS: 'false',
100+
} as const

0 commit comments

Comments
 (0)