【问题标题】:Is there any functionality in puppeteer with mocha similar to dataProvider in TestNG?puppeteer 中是否有类似于 TestNG 中的 dataProvider 的 mocha 功能?
【发布时间】:2020-01-13 07:23:05
【问题描述】:

我在 puppeteer 中寻找类似的功能,使用 mocha 作为 TestNG 测试框架中的 dataProvider。任何人都可以建议如何在 puppeteer 中实现它。 提前致谢。

【问题讨论】:

    标签: javascript node.js automation puppeteer browser-automation


    【解决方案1】:

    在 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 库。

    顺便说一句,在jest你可以轻松做到。

    【讨论】:

      猜你喜欢
      • 2019-03-31
      • 2021-04-11
      • 2011-12-29
      • 1970-01-01
      • 1970-01-01
      • 2013-04-22
      • 1970-01-01
      • 1970-01-01
      • 2012-08-01
      相关资源
      最近更新 更多