testcafe
testcafe copied to clipboard
Allow to selectively suppress warnings
We need to provide some way to disable warnings. Sometimes you can't change the situation reported by a warning, and should be able to just suppress it.
Please move forward this issue.
We are focused on implementing features from our Roadmap. Since this enhancement is not there, we cannot tell you any time frames on when we will be able to address it. If this feature is important for you, please submit a Pull Request with its implementation. See the Сontribution guide for more information.
@AndreyBelym is there any way to not show The "filter" option from the configuration file will be ignored.
on each test run?
I actually do not have any filter
parameters set up in my .testcaferc.json
file, but I have a .filter(...)
directive present in my JS runner file, which makes this warning show up above and below every test run.
The "filter" option from the configuration file will be ignored.
Running tests in:
- Chrome 93.0.4577.0 / macOS 10.15.7
...
7 passed (1m 42s)
Warnings (1):
--
The "filter" option from the configuration file will be ignored.
Full content of .testcaferc.json
:
{
"selectorTimeout": 15000,
"assertionTimeout": 15000,
"pageLoadTimeout": 15000,
"stopOnFirstFail": true,
"skipUncaughtErrors": true,
"disablePageCaching": true
}
I believe my question partly matches this issue, but not 100% sure since I'm not confident that this warning should even show up because there is no filter
option inside my config file. If preferred I can make a new issue out of this and delete this comment.
Hi @di5ko
It looks like a TestCafe issue. Please create a new issue and attach a full example to it.
I would be also interested in this feature especially to supress the warning
The browser window was resized during the "x" test while TestCafe recorded a video.
or
TestCafe cannot interact with the x element because another element obstructs it.
This would be super helpful since we need to manually scroll within shoelace components and that throws in a whole lot of unnecessary stuff at the end of our reports.
https://d.pr/i/469pLX
Please get rid of these warnings... they are unnecessary, unwelcome and cloud actual results.
Joining the request to add a flag or configuration option to remove the printouts of the warnings from the output. They clutter the log excessively, requiring a lot of scrolling to navigate through them, and we don't intend to fix them because the tests are working as expected.
Currently, I can't find a solution to filter out these TestCafe warnings.
Hi,
The exact warning output depends on the reporter you are using. You can use the onBeforeWrite hook to prevent some text from being reported. Here is an example for the "spec" reporter:
// .testcaferc.js
const warningHeadingRegexp = /Warnings (\(\d\)):/;
const warningSplitRegexp = /--/;
const whiteSpaceRegexp = /\s/g;
function isWarning (text, warnings) {
if (warningHeadingRegexp.test(text) || warningSplitRegexp.test(text))
return true;
return warnings.some(msg => msg.replace(whiteSpaceRegexp, '') === text.replace(whiteSpaceRegexp, ''));
}
function hideWarningsHook (writeInfo) {
if (writeInfo.initiator === 'reportWarnings')
writeInfo.formattedText = '';
if (writeInfo.initiator === 'reportTaskDone') {
const warnings = writeInfo.data.warnings || [];
if (!warnings.length)
return;
if (isWarning(writeInfo.formattedText, warnings))
writeInfo.formattedText = '';
}
}
module.exports = {
hooks: {
reporter: {
onBeforeWrite: {
'spec': hideWarningsHook,
},
},
},
};
Please also note that the configuration option override warning message is rendered twice - on TestCafe start (in the console) and in the reporter's reportTaskDone method. Using this approach, you can only prevent the reporter warning from being shown.
This approach is a recommended way to hide warning messages. If it isn't suitable for you, feel free to reopen this issue and share your usage scenario.
Thanks for the code @Artem-Babich! Using these hooks/functions I cannot get this to work.
Hi @Jgrabenbauer,
We need more details about your usage scenario in order to give you any recommendations. Please share a simple runnable project illustrating the problematic behavior and the exact steps required to reproduce it.
@Artem-Babich this is why, there are more warnings than useful information about the results: https://d.pr/i/NqHENf
@Jgrabenbauer Unfortunately, we cannot give you any recommendations based on this .gif
file. Please share a simple working project to illustrate the problematic behavior and the exact steps to reproduce it.
TestCafe cannot interact with the x element because another element obstructs it.
There is a mask, that overlaps interface In our app to deny interact during async operations. So, we have 1500+ such warnings right now. hideWarningsHook
from upper message can't help cause it does 1500 blank lines.
To fix it, I've created fork of testcafe-reporter-spec with warnings filter, execution time for each test and overall progress - testcafe-reporter-spec-plus.
@gooddaytoday Thank you for sharing the information about your reporter with us. I checked it. It works perfectly.
@gooddaytoday the testcafe-reporter-spec-plus works great! Is there an option to do the same but with xunit? This would be great to suppress these warnings while running in CircleCi too.