javascript - puppeteer 中是否有类似于 TestNG 中的 dataProvider 的 mocha 功能?
问题描述
我在 puppeteer 中寻找类似的功能,使用 mocha 作为 TestNG 测试框架中的 dataProvider。任何人都可以建议如何在 puppeteer 中实现它。提前致谢。
解决方案
Mocha 中没有针对此的构建方法。但是您可以使用简单的forEach
方法轻松实现它。
const SITES = ['https://github.com', 'https://google.com'];
SUITES.forEach(expected => {
describe('Suites:', () => {
it(`go to the ${expected} url`, => async () {
await page.goto(expected);
});
});
});
或者使用mocha-testdata库。
顺便说一句,你可以很容易地做到这一点。
推荐阅读
- angular - 正确显示可观察对象值
- vb.net - 根据 Type 变量将异常转换为 NonGenericException
- python - flask-sqlalchemy 动态构造查询
- java - 在程序运行时将代码从网页的 iframe 复制到 Java 编译器
- powershell - 搜索程序产品代码,然后使用它来卸载程序
- php - 格式数字,如果不是整数,用小数显示,否则显示整数
- sitefinity - 是否可以将 sitefinity 小部件添加到我的自定义小部件?
- python - 在对列表进行双重递归时,“预检查”是避免添加无类型或空字符串的首选方法吗?
- java - 组件图是否仅指物理组件?
- angularjs - 使用 ng-controller 时如何让 ui-router 解析工作?