mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-28 10:03:54 +08:00
Add browser-based unit tests for xiaozhi test modules
- 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
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
# Quick Start - Browser Tests (No npm required!)
|
||||
|
||||
## Run Tests in 3 Steps
|
||||
|
||||
1. **Start a local server:**
|
||||
```bash
|
||||
cd main/xiaozhi-server/test
|
||||
python -m http.server 8007
|
||||
```
|
||||
|
||||
2. **Open in browser:**
|
||||
```
|
||||
http://localhost:8007/test-runner.html
|
||||
```
|
||||
|
||||
3. **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 tests
|
||||
- `js/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 `.js` files 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
|
||||
Reference in New Issue
Block a user