gpt4 book ai didi

cypress - 使用 cypress-each 插件时如何将 @smoke 标签应用于某些测试

转载 作者:行者123 更新时间:2023-12-05 03:16:48 25 4
gpt4 key购买 nike

我正在使用 cypress-each 运行动态测试,但总体测试数量很大,我想使用 cypress-grep 将 @smoke 标签添加到数据中,并运行一小部分测试。

如何添加标签

const title = (data) => `Testing ${data}`
it.each(data)(title, (data) => {})

我可以使用函数自定义标题,如何自定义选项对象?

这是我试过的,

const title = (data) => `Testing ${data}`
it.each(data)(title, {tags: '@smoke'}, (data) => {})

但显然它不起作用 - smoke 标签应用于所有测试(作为标签语法的示例添加)。

最佳答案

我不认为你可以动态地添加标签到cypress-each

但你可以做到 standard如果您将数据包装在对象中的方式。

const data = [
{value:'a', tag:'@smoke}, // only first will run when grepping @smoke
{value:'b'},
{value:'c'}
]

data.forEach(data => {
const title = `Testing ${data}`
const options = {tags: data.tag} // when data.tag is undefined,
// effectively no tag applies

it(title, options, (data) => {
...
})
})

关于cypress - 使用 cypress-each 插件时如何将 @smoke 标签应用于某些测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74468842/

25 4 0