为了给用户提供更好的使用体验,UIRecoder 第 3 版对 Reporter 和底层执行库做了升级,稳定性和效率有所增强,且更加贴近用户使用习惯。




/reports 目录下,包含上述渲染效果的文件 index.html ,同时也将执行结果的数据快照保存至文件 json-final.json ,以支持二次开发。常见的二次开发场景比如:
更多关于 macaca-reporter:https://macacajs.github.io/macaca-reporter/zh/

mocha-parallel-tests  采用各子进程分别执行一个测试用例脚本,主进程收集各子进程执行结果的方式,使得每个测试用例脚本并行执行结果与单独执行该测试用例脚本结果一致。而并行执行的方式,明显提高了测试用例的执行效率。macaca-mocha-parallel-tests 及 macaca-circular-json 依赖包并针对 Web 回归测试场景做了相关优化,后续通过自主维护的方式,使得并行执行库的迭代优化更加可控。uirecorder 录制即可,运行命令如下:
sudo npm update uirecorder -g       // 全局升级 uirecorder
uirecorder init                                 // 初始化测试用例工程
uirecorder start                                // 开始录制测试用例
uirecorder ,运行命令如下:sudo npm update uirecorder -g
 
修改 package.json 文件内容如下:

修改完成后,更新相关 npm 依赖包,运行命令如下:
npm update
// 或者运行
rm -rf node_modules
npm install
 *.spec.js 文件,修改的目的是引入每个步骤执行后的截图,修改内容如下:

appendToContext(self, filepath + '.png');
 
appendToContext  函数
function appendToContext(mocha, content) {
    try {
        const test = mocha.currentTest || mocha.test;
        if (!test.context) {
            test.context = content;
        } else if (Array.isArray(test.context)) {
            test.context.push(content);
        } else {
            test.context = [test.context];
            test.context.push(content);
        }
    } catch (e) {
        console.log('error', e);
    }
};