|
4 | 4 | * Custom agent with a get_weather custom tool demonstrating custom tool integration. |
5 | 5 | */ |
6 | 6 |
|
7 | | -import { describe, test, expect, beforeAll } from 'bun:test' |
| 7 | +import { describe, test, expect, beforeAll, beforeEach } from 'bun:test' |
8 | 8 | import { z } from 'zod/v4' |
9 | 9 |
|
10 | 10 | import { CodebuffClient, getCustomToolDefinition } from '../../src' |
11 | | -import { EventCollector, getApiKey, skipIfNoApiKey, isAuthError, MOCK_WEATHER_DATA, DEFAULT_TIMEOUT } from '../utils' |
| 11 | +import { |
| 12 | + EventCollector, |
| 13 | + getApiKey, |
| 14 | + isAuthError, |
| 15 | + ensureBackendConnection, |
| 16 | + MOCK_WEATHER_DATA, |
| 17 | + DEFAULT_TIMEOUT, |
| 18 | +} from '../utils' |
12 | 19 |
|
13 | 20 | import type { AgentDefinition } from '../../src' |
14 | 21 |
|
@@ -49,14 +56,16 @@ Always report the temperature and conditions clearly.`, |
49 | 56 | }) |
50 | 57 |
|
51 | 58 | beforeAll(() => { |
52 | | - if (skipIfNoApiKey()) return |
53 | 59 | client = new CodebuffClient({ apiKey: getApiKey() }) |
54 | 60 | }) |
55 | 61 |
|
| 62 | + beforeEach(async () => { |
| 63 | + await ensureBackendConnection() |
| 64 | + }) |
| 65 | + |
56 | 66 | test( |
57 | 67 | 'custom weather tool is called and returns data', |
58 | 68 | async () => { |
59 | | - if (skipIfNoApiKey()) return |
60 | 69 |
|
61 | 70 | const collector = new EventCollector() |
62 | 71 |
|
@@ -93,7 +102,6 @@ Always report the temperature and conditions clearly.`, |
93 | 102 | test( |
94 | 103 | 'custom tool handles unknown city gracefully', |
95 | 104 | async () => { |
96 | | - if (skipIfNoApiKey()) return |
97 | 105 |
|
98 | 106 | const collector = new EventCollector() |
99 | 107 |
|
|
0 commit comments