-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
这是用ai写的测试用例
`
async function diagnose() {
console.clear();
console.log("=== 🔍 系统深度诊断 ===");
// 1. 检查 http 模块是否存在
if (typeof http === 'undefined') {
console.error("❌ 致命: http 模块完全不存在!");
return;
}
console.log("✅ http 模块已加载");
// 2. 检查 http 模块里到底有什么方法
try {
// 尝试列出 http 对象的所有属性/方法
const keys = Object.keys(http);
console.log("📋 http 支持的方法: [" + keys.join(", ") + "]");
// 检查是否有 get/put/request
if (http.get) console.log(" - get: 存在 (类型: " + typeof http.get + ")");
else console.error(" - get: 缺失 ❌");
if (http.put) console.log(" - put: 存在 (类型: " + typeof http.put + ")");
else console.error(" - put: 缺失 ❌");
} catch (e) {
console.error("⚠️ 无法检查方法列表: " + e);
}
// 3. 尝试最原始的调用测试 (不使用 await,看直接返回值)
console.log("\n🧪 发起测试请求 (百度)...");
try {
// 故意不加 await,看看它到底返回什么东西
const result = http.get("https://www.baidu.com");
console.log("👉 直接返回值类型: " + typeof result);
if (typeof result === 'object') {
console.log("👉 返回值内容: " + JSON.stringify(result));
// 如果是 Promise,尝试处理
if (result.then) {
console.log("✅ 检测到 Promise,尝试解析...");
result.then(res => {
console.log("🎉 异步回调成功: 状态码 " + res.status);
}).catch(err => {
console.error("🔥 异步回调报错: " + err);
});
} else {
console.error("❌ 返回的不是 Promise 对象");
}
} else {
console.error("❌ 返回值无效 (undefined 或非对象)");
console.log("💡 推测: App 内部网络请求组件已损坏");
}
} catch (e) {
console.error("💥 调用瞬间崩溃: " + e);
}
}
diagnose();
`
Metadata
Metadata
Assignees
Labels
No labels
