mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 09:33:55 +08:00
- Add browser-compatible test files (no npm required) - recorder.test.browser.js: 8 tests for microphone and HTTP detection - tools.test.browser.js: 5 tests for Live2D actions and error handling - Add test runner (test-runner.html) with built-in test framework - Add null safety checks in tools.js for DOM element access - Add documentation (English and Chinese versions) - README_TESTS.md / README_TESTS_CN.md: Complete test guide - QUICK_START_TEST.md / QUICK_START_TEST_CN.md: Quick start guides - Total: 13 unit tests covering microphone detection, HTTP detection, Live2D actions, and error handling
1.2 KiB
1.2 KiB
快速开始 - 浏览器测试(无需 npm!)
3 步运行测试
-
启动本地服务器:
cd main/xiaozhi-server/test python -m http.server 8007 -
在浏览器中打开:
http://localhost:8007/test-runner.html -
点击 "▶ Run All Tests"(运行所有测试)
就这么简单!无需 npm,无需 package.json,无需任何依赖。
测试内容
- ✅ 麦克风可用性检测(3 个测试)
- ✅ HTTP 非本地访问检测(5 个测试)
- ✅ Live2D 动作执行(5 个测试)
- ✅ 错误处理和边界情况
总计:13 个单元测试(8 个录音器测试 + 5 个工具测试)
测试文件
js/core/audio/recorder.test.browser.js- 音频/录音器测试js/core/mcp/tools.test.browser.js- MCP 工具和 Live2D 测试
故障排除
测试无法运行?
- 确保使用本地服务器(不要使用
file://) - 检查浏览器控制台是否有错误
- 确保所有
.js文件都可以访问
部分测试失败?
- 查看测试结果中的错误信息
- 验证模拟设置是否正确
- 检查浏览器控制台获取详细错误信息