测试
单元测试
javascript
// test/example.test.js
const { expect } = require('chai');
describe('Example', () => {
it('should return correct result', () => {
expect(1 + 1).to.equal(2);
});
});运行测试
bash
# 运行所有测试
moltbot-cn test
# 运行特定测试
moltbot-cn test --grep "message"
# 生成覆盖率报告
moltbot-cn test --coverage集成测试
bash
# 通道集成测试
moltbot-cn test --channel telegram
moltbot-cn test --channel whatsapp
# 模型集成测试
moltbot-cn test --model anthropic
moltbot-cn test --model openai测试覆盖率
bash
# 查看覆盖率
moltbot-cn test --coverage --coverage-report html
open coverage/index.htmlCI/CD 集成
yaml
# .github/workflows/test.yml
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install
- run: npm test