> ## Documentation Index
> Fetch the complete documentation index at: https://adcp-docs-ja.pier1.co.jp/llms.txt
> Use this file to discover all available pages before exploring further.

# Testable examples demo

# テスト可能なドキュメント例

このページは、実際のテストエージェントに対して動作する完全なコード例を使い、テスト可能なドキュメント機能を紹介します。

## JavaScript の例

### クリエイティブフォーマットの一覧取得

```javascript theme={null}
import { testAgent } from '@adcp/client/testing';

const result = await testAgent.listCreativeFormats({});

console.log(`✓ Found ${result.data?.formats?.length || 0} creative formats`);
```

## Python の例

### クリエイティブフォーマットの一覧取得

```python theme={null}
import asyncio
from adcp.testing import test_agent

async def list_formats():
    result = await test_agent.simple.list_creative_formats()
    print(f"✓ Found {len(result.formats)} supported creative formats")

asyncio.run(list_formats())
```

## CLI の例

### uvx (Python CLI) の使用例

```bash theme={null}
uvx adcp \
  https://test-agent.adcontextprotocol.org/mcp \
  list_creative_formats \
  '{}' \
  --auth 1v8tAhASaUYYp4odoQ1PnMpdqNaMiTrCRqYo9OJp6IQ
```

## テスト可能なドキュメントの仕組み

フロントマターに `testable: true` を設定すると、このページ内のすべてのコードブロックが抽出され、テスト時に実行されます。

### テストの実行

```bash theme={null}
# Run all tests including snippet validation
npm run test:all
```

### テスト可能ページの要件

すべてのコードブロックは次を満たす必要があります。

* 完結しており自己完結していること
* 必要な依存関係をすべてインポートしていること
* エラーなく実行できること
* 成功を確認できる出力を生成すること

### ページをテスト可能とマークするタイミング

ページに `testable: true` を付けるのは、次の条件をすべて満たす場合に限ります。

* すべてのコードブロックが完全な実行例です
* コード断片や不完全なスニペットがない
* すべての例がテストエージェントの認証情報を使用しています
* 依存関係がインストール済みである（`@adcp/client`, `adcp`）

### ページをテスト可能としない場合

次のようなページに `testable: true` を付けてはいけません。

* パターンを示すだけのコード断片があります
* 不完全な例が含まれます
* 概念的な疑似コードが含まれます
* 本番用の認証情報が必要な例があります
* テスト可能な内容とそうでない内容が混在しています

詳しくは [Testable Snippets Guide](./testable-snippets.md) を参照してください。
