I'm trying to filter OUT some tests that we have been skipping. "test.skip" is the default way to skip tests, but TestCafe has had issues with runs freezing after skipping a test.
In the mean time, they have a filter option for their testcaferc file that I'd like to use to basically ignore the tests. Since the ignored tests don't show on the report using the filter option, I'm hoping it means that TestCafe won't freeze after ignoring the test.
Their documentation says how to use the filter to only run specified tests, but lacks the negative aspect of this:
https://testcafe.io/documentation/402638/reference/configuration-file#filter
I have been able to filter out a single test just fine, but we have multiple tests we need to ignore for now and when I attempt to add a new regex, the run stops and says "No tests match your filter."
I am looking for a way to have multiple regex so TestCafe knows to ignore multiple tests.
Here's what works:
"filter": {
"testGrep":
"^((?!user_is_able_to_add_a_section_column_row_and_element_to_editor).)*$"
}
Here's what doesn't work:
"filter": {
"testGrep": [
"^((?!user_is_able_to_add_a_section_column_row_and_element_to_editor).)*$",
"^((?!pop_up_element_displays_during_page_preview).)*$"
]
}
The testGrep configuration option only supports a single regex. You can specify a regex with alternation to ignore multiple tests:
"filter": {
"testGrep": "^(?!.*(Test One|Test Two)).*$"
}
Another way is to use the JS configuration file instead of JSON. It allows you to specify a method in which you can filter tests in any way you want:
module.exports = {
src: './tests/test.js',
filter: (testName => !testName.includes('Test One') && !testName.includes('Test Two'))
}
This approach is similar to the Runner.filter method.