botphusCore
是botphus
的核心测试程序,通过底层使用puppeteer提供web测试单元任务配置和执行.
![node version](https://camo.githubusercontent.com/567e61886a093479678892f2bf0fa2e1f4e84e41dcdae45488acde4795825aa2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6e6f64652e6a732d2533453d5f362d677265656e2e7376673f7374796c653d666c61742d737175617265)
- 使用任务单元组成的测试任务,可以按需执行特定部分.如:
- 执行Web页面测试
- 连接数据库/Redis缓存进行数据验证
- Web页面事件捕获
- 服务端和PC客户端均可使用
npm install botphus-core --save
import BotphusCore, {TaskMessage, TaskType, TaskTypeDomSubType} from 'botphus-core';
const botphusCore = new BotphusCore();
(async () => {
// Create task cache file
const taskNo = await botphusCore.createTask('Test task', new Date().getTime(), [
{
argments: ['div'],
assertion: ['data === "wrong assertion rule"'],
subType: TaskTypeDomSubType.SUB_TYPE_GET_TEXT,
type: TaskType.TYPE_DOM
}
]);
// Start task & listen child process message
const subProcess = await botphusCore.startTask(taskNo, 'https://bing.com/');
// Get task exec message info
subProcess.on('message', ([error, messageData]: TaskMessage) => {
if (error) {
global.console.log(error.stack);
}
global.console.log(messageData);
});
// Process close
subProcess.on('close', (code) => {
global.console.log('done:', code);
});
})();