oicq icon indicating copy to clipboard operation
oicq copied to clipboard

能否添加自动化测试相关支持

Open dislido opened this issue 1 year ago • 1 comments

比如允许启动oicq但不进行真实登陆操作,方便使用mock事件数据进行测试,以及对api调用的监听或hook 使用例

const { createClient } = require("oicq");
const account = 123123;
const client = createClient(account);
client.on("notice.group.poke", e => {
  e.reply("收到戳一戳消息");
});
client.login({ fakeLogin: true }); // 加一个类似选项,不进行实际登录操作,直接视为登录成功

const mockPoke = {
    "post_type": "notice",
    "notice_type": "group",
    "sub_type": "poke",
    // 略
};

client.emit('notice.group.poke', mockPoke);

// 添加对api调用的监听或拦截能力(可能非测试也有地方会用到)
client.on('sendGroupMsg', (e) => {
  console.log('发送群消息', e);
  e.prevent(); // 能够阻止此次调用
});

dislido avatar Jul 29 '22 09:07 dislido

这个挺好的,最好再额外带一个交互式模式,也方便人工测试

Arondight avatar Sep 07 '22 11:09 Arondight