带有 mocha 的 puppeteer 中是否有类似于 TestNG 中的 dataProvider 的功能?
Is there any functionality in puppeteer with mocha similar to dataProvider in TestNG?
我在 TestNG 测试框架中使用 mocha 作为 dataProvider 在 puppeteer 中寻找类似的功能。任何人都可以建议如何在 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 库。
顺便说一下,在 jest 你可以轻松做到。
我在 TestNG 测试框架中使用 mocha 作为 dataProvider 在 puppeteer 中寻找类似的功能。任何人都可以建议如何在 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 库。
顺便说一下,在 jest 你可以轻松做到。