mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-25 16:43: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.1 KiB
1.1 KiB
Quick Start - Browser Tests (No npm required!)
Run Tests in 3 Steps
-
Start a local server:
cd main/xiaozhi-server/test python -m http.server 8007 -
Open in browser:
http://localhost:8007/test-runner.html -
Click "▶ Run All Tests"
That's it! No npm, no package.json, no dependencies needed.
What Gets Tested?
- ✅ Microphone availability detection (3 tests)
- ✅ HTTP non-localhost detection (5 tests)
- ✅ Live2D action execution (5 tests)
- ✅ Error handling and edge cases
Total: 13 unit tests (8 recorder tests + 5 tools tests)
Test Files
js/core/audio/recorder.test.browser.js- Audio/recorder testsjs/core/mcp/tools.test.browser.js- MCP tools and Live2D tests
Troubleshooting
Tests don't run?
- Make sure you're using a local server (not
file://) - Check browser console for errors
- Ensure all
.jsfiles are accessible
Some tests fail?
- Check the error message in the test results
- Verify mocks are set up correctly
- Check browser console for detailed errors