update-api-client-tests
Update api-client integration tests after spec regeneration. Use when generated code has changed and tests need to match.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Update api-client integration tests after spec regeneration. Use when generated code has changed and tests need to match.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | update-api-client-tests |
| description | Update api-client integration tests after spec regeneration. Use when generated code has changed and tests need to match. |
The integration tests in packages/api-client/src/__tests__/ use generated functions from packages/api-client/src/generated/. When the OpenAPI spec changes and code is regenerated, the tests may break.
Run the typecheck to find errors in the test files:
npx tsc --noEmit -p packages/api-client/tsconfig.json
If there are no errors, the tests already match the generated code — stop here.
For each error, read the relevant generated file to understand the new signature. Generated code lives in:
packages/api-client/src/generated/crm/crm.ts — account and person endpointspackages/api-client/src/generated/support/support.ts — case endpointspackages/api-client/src/generated/models/ — all model and body typesCommon changes to look for:
Apply fixes to the test files:
packages/api-client/src/__tests__/accounts-crud.integration.test.tspackages/api-client/src/__tests__/people.integration.test.tspackages/api-client/src/__tests__/support.integration.test.tspackages/api-client/src/__tests__/crm.integration.test.tsclient("path", ...) ky calls for operations that have a generated function. This is the entire point: if the spec changes, the test should break at compile time.opts(client) from ./setup.js to pass the ky instance as the options argument.as FooBody — the generated body types extend AbstractBean which requires Created and Updated, but the API doesn't need these on requests.as unknown as Model — list endpoints return PaginatedResponse<T> at runtime but the generated response type doesn't reflect this.afterAll — it prevents test data from accumulating.Importing generated functions:
import { accountGetAllAccounts, accountAddAccount } from "../generated/crm/crm.js";
import type { Account, AccountAddAccountBody } from "../generated/models/index.js";
Calling a list endpoint:
const res = await accountGetAllAccounts(undefined, opts(client));
const body = res.data as unknown as PaginatedResponse<Account>;
Calling a create endpoint:
const res = await accountAddAccount(
{ Name: "Test", PersonAccount: [...] } as AccountAddAccountBody,
undefined, // params
opts(client),
);
const created = res.data as unknown as Account;
Calling a get/update/delete endpoint:
const res = await accountGetAccount(uid, opts(client));
const res = await accountUpdateAccount(uid, body as AccountUpdateAccountBody, opts(client));
const res = await accountDeleteAccount(uid, opts(client));
Run the typecheck again to confirm all errors are resolved:
npx tsc --noEmit -p packages/api-client/tsconfig.json