[英]Run a mocha test with multiple js files and generate separate JSON reports
我在当前目录中有几个mocha&chakram测试用例文件:
test1.js
test2.js
test3.js
..and so on
我想按顺序运行Mocha测试并为每个测试用例生成JSON报告。
我想要的是
Test1.json (result of test1.js)
Test2.json (result of test2.js)
Test3.json (result of test3.js)
..and so on
我尝试过的
创建一个批处理文件,其中包含:
mocha test1.js --reporter json > Test1.json mocha test2.js --reporter json > Test2.json mocha test3.js --reporter json > Test3.json
当我运行它时,它仅运行第一行
将批处理文件修改为仅一行
mocha test1.js --reporter json > Test1.json test2.js --reporter json > Test2.json test3.js --reporter json > Test3.json
这样只会生成一个文件“ Test3” .json。 要么
mocha "./testfolder/*.js" --reporter json > Test.json
这样只会生成一个文件。
使用mocha --recursive
mocha --recursive *.js --reporter > test1.json
它适用于所有子文件夹。 即使此方法有效,也只会生成一个文件。 重新组织文件夹可能不是一个选择。
我也尝试使用mochawesome,但是在这种情况下,我想要JSON文件作为结果/报告者。
我该如何实现?
mocha -R json test/main.js 2>&1 | tee ./selenium-results/selenium-results.json
这对我有用。 您可以在./selenium-results/selenium-results.json
文件中定义文件路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.