等待 mock server 收到某个 pathname 的请求
(server: MockServer, pathname: string, timeoutMs = 15_000)
| 19 | |
| 20 | /** 等待 mock server 收到某个 pathname 的请求 */ |
| 21 | async function waitForHit(server: MockServer, pathname: string, timeoutMs = 15_000): Promise<void> { |
| 22 | await expect |
| 23 | .poll(() => server.hits(pathname), { |
| 24 | message: `waiting for request to ${pathname} (got: ${JSON.stringify(server.requestLog.map((r) => r.pathname))})`, |
| 25 | timeout: timeoutMs, |
| 26 | intervals: [100, 250, 500, 1_000], |
| 27 | }) |
| 28 | .toBeGreaterThan(0); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * 打开目标页面并等待脚本输出哨兵 JSON 行。脚本注入相对安装存在异步窗口, |
no outgoing calls
no test coverage detected