Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to selectively suppress warnings #5544

Closed
AndreyBelym opened this issue Sep 15, 2020 · 16 comments
Closed

Allow to selectively suppress warnings #5544

AndreyBelym opened this issue Sep 15, 2020 · 16 comments

Comments

@AndreyBelym
Copy link
Contributor

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.

@maldzi
Copy link

maldzi commented Jun 9, 2021

Please move forward this issue.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jun 9, 2021
@github-actions
Copy link

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 github-actions bot removed STATE: Need response An issue that requires a response or attention from the team. STATE: Outdated proposal labels Jun 10, 2021
@di5ko
Copy link

di5ko commented Oct 13, 2021

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

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Oct 13, 2021
@miherlosev
Copy link
Collaborator

Hi @di5ko

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

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Oct 18, 2021
@TAkbay
Copy link

TAkbay commented Jan 6, 2023

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.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 6, 2023
@miherlosev miherlosev removed the STATE: Need response An issue that requires a response or attention from the team. label Jan 9, 2023
@Jgrabenbauer
Copy link

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

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label May 3, 2023
@Dmitry-Ostashev Dmitry-Ostashev removed the STATE: Need response An issue that requires a response or attention from the team. label May 4, 2023
@qualityshepherd
Copy link

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

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label May 22, 2023
@miherlosev miherlosev removed the STATE: Need response An issue that requires a response or attention from the team. label May 24, 2023
@ghost
Copy link

ghost commented Jul 9, 2023

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.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jul 9, 2023
@Artem-Babich
Copy link
Contributor

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.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jul 11, 2023
@Jgrabenbauer
Copy link

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

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jul 12, 2023
@Artem-Babich
Copy link
Contributor

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.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jul 13, 2023
@Jgrabenbauer
Copy link

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

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Sep 5, 2023
@AlexKamaev
Copy link
Contributor

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

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Sep 7, 2023
@gooddaytoday
Copy link

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.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Oct 18, 2023
@AlexKamaev
Copy link
Contributor

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

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Oct 19, 2023
@Jgrabenbauer
Copy link

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

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 16, 2024
@PavelMor25 PavelMor25 removed the STATE: Need response An issue that requires a response or attention from the team. label Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests