![](/img/trans.png)
[英]Testcafe - reporter does not read options from testcaferc.json
[英]TestCafe - How to have multiple regex for testGrep in testcaferc file
我正在嘗試過濾掉我們一直在跳過的一些測試。 “test.skip”是跳過測試的默認方式,但 TestCafe 在跳過測試后遇到了運行凍結的問題。
同時,他們的 testcaferc 文件有一個過濾器選項,我想用它來基本上忽略測試。 由於使用過濾器選項忽略的測試不會顯示在報告中,我希望這意味着 TestCafe 在忽略測試后不會凍結。
他們的文檔說明了如何使用過濾器只運行指定的測試,但缺乏這方面的負面影響:
https://testcafe.io/documentation/402638/reference/configuration-file#filter
我已經能夠很好地過濾掉一個測試,但是我們現在需要忽略多個測試,當我嘗試添加新的正則表達式時,運行停止並顯示“沒有測試與您的過濾器匹配”。
我正在尋找一種擁有多個正則表達式的方法,以便 TestCafe 知道忽略多個測試。
這是有效的:
"filter": {
"testGrep":
"^((?!user_is_able_to_add_a_section_column_row_and_element_to_editor).)*$"
}
這是不起作用的:
"filter": {
"testGrep": [
"^((?!user_is_able_to_add_a_section_column_row_and_element_to_editor).)*$",
"^((?!pop_up_element_displays_during_page_preview).)*$"
]
}
testGrep 配置選項僅支持單個正則表達式。 您可以指定一個帶有交替的正則表達式來忽略多個測試:
"filter": {
"testGrep": "^(?!.*(Test One|Test Two)).*$"
}
另一種方法是使用JS配置文件代替JSON。 它允許您指定一種方法,您可以在其中以任何您想要的方式過濾測試:
module.exports = {
src: './tests/test.js',
filter: (testName => !testName.includes('Test One') && !testName.includes('Test Two'))
}
這種方法類似於Runner.filter方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.