一键导入
testing-guide
Use when working on Vitest configuration, appliance-backed tests, fixtures, or debugging test failures.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when working on Vitest configuration, appliance-backed tests, fixtures, or debugging test failures.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Use when making Safeguard API calls, wiring auth strategies, or following SDK request and response patterns.
Use when wiring certificate-based A2A retrieval, brokering, or related Safeguard event listeners in Node.js.
Use when changing module structure, auth internals, conditional exports, or the HTTP and storage layers.
Use when changing tsdown config, Azure Pipelines, publishing flow, or version derivation.
基于 SOC 职业分类
| name | testing-guide |
| description | Use when working on Vitest configuration, appliance-backed tests, fixtures, or debugging test failures. |
| trigger | Working on tests, test failures, appliance setup, debugging test output |
tests/unit/ — pure logic only, minimal mockingtests/integration/ — live appliance validationvitest.config.ts (unit), vitest.integration.config.ts (integration)npm run test # Unit tests only
npm run test:watch # Unit tests in watch mode
npm run test:integration # Integration tests (requires env vars)
| Variable | Required | Default | Description |
|---|---|---|---|
SPP_HOST | Yes | — | Appliance hostname. Tests auto-skip when unset. |
SPP_USERNAME | No | Admin | Safeguard user |
SPP_PASSWORD | Yes | — | Password |
SPP_CA_FILE | No | — | CA cert path (omit → verify: false) |
SPP_CERT_FILE | No | — | Client cert for cert auth tests |
SPP_KEY_FILE | No | — | Client key |
SPP_KEY_PASSPHRASE | No | — | Key passphrase |
SPP_A2A_API_KEY | No | — | Pre-configured A2A API key |
SPP_EXTERNAL_PROVIDER | No | — | External auth provider name |
SPP_HOST is unsetUse SgJs_<8hex> prefix for test resources created on the appliance (matches PySafeguard's PySg_ pattern).
getPasswordClient(), getCertClient(), getAnonymousClient()For the rare case where unit testing needs HTTP mocking, use undici's built-in MockAgent:
import { MockAgent, setGlobalDispatcher } from 'undici';
const agent = new MockAgent();
setGlobalDispatcher(agent);
const pool = agent.get('https://appliance.example.com');
pool.intercept({ path: '/RSTS/oauth2/token', method: 'POST' })
.reply(200, { access_token: 'test-token' });