test: stabilize suite and add coverage heatmap (#373)
* test: stabilize suite and add coverage heatmap * ci: run full bun test suite in pr checks
This commit is contained in:
@@ -4,6 +4,7 @@ const originalEnv = { ...process.env }
|
||||
const originalFetch = globalThis.fetch
|
||||
|
||||
async function importFreshModule() {
|
||||
mock.restore()
|
||||
return import(`./apiPreconnect.ts?ts=${Date.now()}-${Math.random()}`)
|
||||
}
|
||||
|
||||
@@ -14,11 +15,15 @@ beforeEach(() => {
|
||||
afterEach(() => {
|
||||
process.env = { ...originalEnv }
|
||||
globalThis.fetch = originalFetch
|
||||
mock.restore()
|
||||
})
|
||||
|
||||
describe('preconnectAnthropicApi', () => {
|
||||
test('does not fetch when OpenAI mode is enabled', async () => {
|
||||
process.env.CLAUDE_CODE_USE_OPENAI = '1'
|
||||
mock.module('./model/providers.js', () => ({
|
||||
getAPIProvider: () => 'openai',
|
||||
}))
|
||||
const fetchMock = mock(() => Promise.resolve(new Response(null, { status: 200 })))
|
||||
globalThis.fetch = fetchMock as typeof globalThis.fetch
|
||||
|
||||
@@ -30,6 +35,9 @@ describe('preconnectAnthropicApi', () => {
|
||||
|
||||
test('does not fetch when Gemini mode is enabled', async () => {
|
||||
process.env.CLAUDE_CODE_USE_GEMINI = '1'
|
||||
mock.module('./model/providers.js', () => ({
|
||||
getAPIProvider: () => 'gemini',
|
||||
}))
|
||||
const fetchMock = mock(() => Promise.resolve(new Response(null, { status: 200 })))
|
||||
globalThis.fetch = fetchMock as typeof globalThis.fetch
|
||||
|
||||
@@ -41,6 +49,9 @@ describe('preconnectAnthropicApi', () => {
|
||||
|
||||
test('does not fetch when GitHub mode is enabled', async () => {
|
||||
process.env.CLAUDE_CODE_USE_GITHUB = '1'
|
||||
mock.module('./model/providers.js', () => ({
|
||||
getAPIProvider: () => 'github',
|
||||
}))
|
||||
const fetchMock = mock(() => Promise.resolve(new Response(null, { status: 200 })))
|
||||
globalThis.fetch = fetchMock as typeof globalThis.fetch
|
||||
|
||||
@@ -58,6 +69,9 @@ describe('preconnectAnthropicApi', () => {
|
||||
delete process.env.CLAUDE_CODE_USE_VERTEX
|
||||
delete process.env.CLAUDE_CODE_USE_FOUNDRY
|
||||
|
||||
mock.module('./model/providers.js', () => ({
|
||||
getAPIProvider: () => 'firstParty',
|
||||
}))
|
||||
const fetchMock = mock(() => Promise.resolve(new Response(null, { status: 200 })))
|
||||
globalThis.fetch = fetchMock as typeof globalThis.fetch
|
||||
|
||||
|
||||
Reference in New Issue
Block a user