Loading...
Loading...
Compare original and translation side by side
rules/GET /repos/:owner/:repo/pullsrules/GET /repos/:owner/:repo/pulls| Category | Rules | Impact | When to Use |
|---|---|---|---|
| Seed Config | 1 | HIGH | Setting up emulate.config.yaml for test environments |
| Service Selection | 1 | MEDIUM | Choosing GitHub/Vercel/Google for your tests |
| Webhook Setup | 1 | MEDIUM | Testing webhook delivery with HMAC verification |
| Parallel CI | 1 | HIGH | Running tests in parallel without port collisions |
| Auth Tokens | 1 | MEDIUM | Seeding tokens mapped to emulated users |
undefinedundefinedundefinedundefined| Service | Default Port | Coverage |
|---|---|---|
| GitHub | | Repos, PRs, issues, comments, reviews, Actions, webhooks, orgs, teams |
| Vercel | | Projects, deployments, domains, env vars, teams |
| Google OAuth | | OAuth 2.0 authorize, token exchange, userinfo |
references/api-coverage.md| 服务 | 默认端口 | 覆盖范围 |
|---|---|---|
| GitHub | | 仓库、PR、议题、评论、评审、Actions、Webhook、组织、团队 |
| Vercel | | 项目、部署、域名、环境变量、团队 |
| Google OAuth | | OAuth 2.0授权、令牌交换、用户信息 |
references/api-coverage.mdundefinedundefined
See `rules/seed-config.md` for full schema and best practices.
完整的Schema和最佳实践请查看`rules/seed-config.md`。import { createEmulator } from 'emulate'
const github = await createEmulator({ service: 'github', port: 4001 })
// github.url -> 'http://localhost:4001'
// State is real — create a PR and it appears in the list
const res = await fetch(`${github.url}/repos/org/repo/pulls`, {
method: 'POST',
headers: { Authorization: 'Bearer dev_token' },
body: JSON.stringify({ title: 'Test PR', head: 'feature', base: 'main' })
})
const prs = await fetch(`${github.url}/repos/org/repo/pulls`)
// -> includes the PR we just created
// Cleanup
github.reset() // Synchronous state wipe
await github.close() // Shut down serverreferences/sdk-patterns.mdimport { createEmulator } from 'emulate'
const github = await createEmulator({ service: 'github', port: 4001 })
// github.url -> 'http://localhost:4001'
// 状态是真实的——创建PR后,它会出现在列表中
const res = await fetch(`${github.url}/repos/org/repo/pulls`, {
method: 'POST',
headers: { Authorization: 'Bearer dev_token' },
body: JSON.stringify({ title: 'Test PR', head: 'feature', base: 'main' })
})
const prs = await fetch(`${github.url}/repos/org/repo/pulls`)
// -> 包含我们刚刚创建的PR
// 清理
github.reset() // 同步清空状态
await github.close() // 关闭服务器references/sdk-patterns.mdimport crypto from 'crypto'
function verifyWebhook(payload: string, signature: string, secret: string): boolean {
const expected = 'sha256=' + crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex')
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))
}rules/webhook-setup.mdimport crypto from 'crypto'
function verifyWebhook(payload: string, signature: string, secret: string): boolean {
const expected = 'sha256=' + crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex')
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))
}rules/webhook-setup.mdundefinedundefinedundefinedundefined// vitest.config.ts
const workerPort = 4001 + parseInt(process.env.VITEST_WORKER_ID || '0')rules/parallel-ci.md// vitest.config.ts
const workerPort = 4001 + parseInt(process.env.VITEST_WORKER_ID || '0')rules/parallel-ci.md| Tool | When to Use | Stateful? | Platforms |
|---|---|---|---|
| emulate (FIRST CHOICE) | GitHub/Vercel/Google API testing | YES | GitHub, Vercel, Google |
| Pact | Contract verification between services | No | Any |
| MSW | In-browser/Node HTTP mocking | No | Any |
| Nock | Node.js HTTP intercept | No | Any |
| WireMock | HTTP stub server | Partial | Any |
| 工具 | 使用场景 | 支持状态持久化? | 支持平台 |
|---|---|---|---|
| emulate(首选) | GitHub/Vercel/Google API测试 | 是 | GitHub、Vercel、Google |
| Pact | 服务间契约验证 | 否 | 任意 |
| MSW | 浏览器/Node.js HTTP Mock | 否 | 任意 |
| Nock | Node.js HTTP拦截 | 否 | 任意 |
| WireMock | HTTP stub服务器 | 部分支持 | 任意 |
testing-integrationtesting-e2etesting-unitsecurity-patternstesting-integrationtesting-e2etesting-unitsecurity-patternsreferences/cli-reference.mdreferences/cli-reference.mdreferences/sdk-patterns.mdcreateEmulator()createEmulator()references/sdk-patterns.md