testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Allow to selectively suppress warnings

Open AndreyBelym opened this issue 3 years ago • 4 comments

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.

AndreyBelym avatar Sep 15 '20 08:09 AndreyBelym

Please move forward this issue.

maldzi avatar Jun 09 '21 12:06 maldzi

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.

github-actions[bot] avatar Jun 10 '21 07:06 github-actions[bot]

@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.

di5ko avatar Oct 13 '21 12:10 di5ko

Hi @di5ko

It looks like a TestCafe issue. Please create a new issue and attach a full example to it.

miherlosev avatar Oct 18 '21 08:10 miherlosev

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.

TAkbay avatar Jan 06 '23 09:01 TAkbay

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

Jgrabenbauer avatar May 03 '23 13:05 Jgrabenbauer

Please get rid of these warnings... they are unnecessary, unwelcome and cloud actual results.

qualityshepherd avatar May 22 '23 22:05 qualityshepherd

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.

ghost avatar Jul 09 '23 12:07 ghost

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.

Artem-Babich avatar Jul 11 '23 14:07 Artem-Babich

Thanks for the code @Artem-Babich! Using these hooks/functions I cannot get this to work.

Jgrabenbauer avatar Jul 12 '23 14:07 Jgrabenbauer

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 avatar Jul 13 '23 07:07 Artem-Babich

@Artem-Babich this is why, there are more warnings than useful information about the results: https://d.pr/i/NqHENf

Jgrabenbauer avatar Sep 05 '23 20:09 Jgrabenbauer

@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.

AlexKamaev avatar Sep 07 '23 10:09 AlexKamaev

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 avatar Oct 18 '23 11:10 gooddaytoday

@gooddaytoday Thank you for sharing the information about your reporter with us. I checked it. It works perfectly.

AlexKamaev avatar Oct 19 '23 06:10 AlexKamaev

@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.

Jgrabenbauer avatar Jan 16 '24 14:01 Jgrabenbauer