1
0

docs: 重写 README 为结构化项目文档,精简示例配置

This commit is contained in:
2026-05-16 20:58:04 +08:00
parent 146cef982e
commit 04c24e6796
2 changed files with 128 additions and 273 deletions

View File

@@ -48,34 +48,8 @@ targets:
- json:
path: "$.slideshow.slides[0].title"
contains: "Wake"
- json:
path: "$.slideshow.slides[0].type"
equals: "all"
- regex: '"title"'
- name: "HTML 页面 — CSS 选择器"
type: http
http:
url: "https://httpbin.org/html"
expect:
body:
- css:
selector: "h1"
contains: "Moby-Dick"
- css:
selector: "body"
exists: true
- name: "HTML 页面 — XPath 提取节点文本"
type: http
http:
url: "https://httpbin.org/html"
expect:
body:
- xpath:
path: "/html/body/h1/text()"
contains: "Melville"
- name: "POST 接口测试"
type: http
http:
@@ -94,61 +68,6 @@ targets:
path: "$.json.version"
gte: 1
- name: "请求头验证"
type: http
http:
url: "https://httpbin.org/headers"
headers:
X-Custom-Header: "dial-server"
expect:
status: [200]
body:
- json:
path: "$.headers.X-Custom-Header"
equals: "dial-server"
- name: "响应头自定义校验"
type: http
http:
url: "https://httpbin.org/response-headers"
headers:
accept: "application/json"
expect:
body:
- json:
path: "$.Content-Type"
equals: "application/json"
- name: "多状态码允许"
type: http
http:
url: "https://httpbin.org/status/200"
expect:
status: [200, 201, 204]
- name: "状态码范围匹配"
type: http
http:
url: "https://httpbin.org/status/204"
expect:
status: ["2xx"]
- name: "自签名证书跳过 SSL"
type: http
http:
url: "https://internal.local/health"
ignoreSSL: true
expect:
status: ["2xx"]
- name: "跟随重定向"
type: http
http:
url: "https://httpbin.org/redirect/1"
maxRedirects: 5
expect:
status: [200]
# ========== Cmd targets ==========
- name: "Bun 版本输出匹配"
@@ -162,55 +81,6 @@ targets:
stdout:
- match: "^\\d+\\.\\d+\\.\\d+"
- name: "自定义文本输出"
type: cmd
cmd:
exec: "bun"
args: ["-e", "console.log('check ok')"]
expect:
stdout:
- equals: "check ok\n"
maxDurationMs: 3000
- name: "脚本执行无 stderr"
type: cmd
cmd:
exec: "bun"
args: ["-e", "process.stdout.write('ok')"]
expect:
exitCode: [0]
stderr:
- empty: true
- name: "日期脚本输出包含年份"
type: cmd
cmd:
exec: "bun"
args: ["-e", "console.log(new Date().getFullYear())"]
expect:
stdout:
- match: "^20\\d{2}\n?$"
- name: "环境变量覆盖"
type: cmd
cmd:
exec: "bun"
args: ["-e", "console.log(process.env.LANG ?? '')"]
env:
LANG: "C"
expect:
stdout:
- contains: "C"
- name: "运行平台非空输出"
type: cmd
cmd:
exec: "bun"
args: ["-e", "console.log(process.platform)"]
expect:
stdout:
- match: ".+"
- name: "多规则 stdout 顺序校验"
type: cmd
interval: "5m"
@@ -243,16 +113,6 @@ targets:
expect:
maxDurationMs: 1000
- name: "SQLite 内存数据库查询行数"
type: db
db:
url: "sqlite://:memory:"
query: "SELECT 1 as cnt"
expect:
maxDurationMs: 1000
rowCount:
gte: 1
- name: "SQLite 内存数据库多列结果校验"
type: db
db: