Skip to content

maxNumberOfFailuresToShow doesn't seem to work as expected. #125

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

Closed
samixchoumi opened this issue May 7, 2024 · 8 comments
Closed

maxNumberOfFailuresToShow doesn't seem to work as expected. #125

samixchoumi opened this issue May 7, 2024 · 8 comments
Labels
bug Something isn't working Stale

Comments

@samixchoumi
Copy link

samixchoumi commented May 7, 2024

Bug description

Looking at the example from the doc here : maxNumberOfFailuresToShow, it doesn't seem to work as expected when I set maxNumberOfFailuresToShow to 0 in my cli_config.json file like that : "maxNumberOfFailuresToShow": 0,

How to reproduce (please include a snippet of your Playwright Slack Reporter configuration)

  1. Set the config maxNumberOfFailuresToShow to '0'
  2. Run your test with some failing tests cases.
  3. See some failure reported in your Slack.

Not sure if it's useful, but I use :

"sendUsingWebhook": {
    "webhookUrl": "my slack webhook URL"
}

Expected behavior

No failure shown in the Slack report.

Environment & setup

  • OS: macOS
  • Node.js version: v21.1.0

playwright-slack-report version

"playwright-slack-report": "^1.1.72"
@samixchoumi samixchoumi added the bug Something isn't working label May 7, 2024
@ryanrosello-og
Copy link
Owner

ryanrosello-og commented May 8, 2024

yeah this is a legit bug. Seems this bit of the code https://github.com/ryanrosello-og/playwright-slack-report/blob/main/src/SlackReporter.ts#L77 is treating zero as falsy so its always falling back to showing 10 failures even though you specified 0 as its value.

should be straight-forward fix:

this.maxNumberOfFailuresToShow
  = slackReporterConfig.maxNumberOfFailuresToShow !== undefined ? slackReporterConfig.maxNumberOfFailuresToShow : 10;

leave it with me. I can take a look

@samixchoumi
Copy link
Author

Okey ! Waiting for the fix then ! Thanks 🙏🏻

@samixchoumi
Copy link
Author

samixchoumi commented May 13, 2024

Hello, @ryanrosello-og FYI, I tested by replacing the value to 1, I still have multiple error shown in the slack reporting and still have the message : There are too many failures to display - 5 out of 28 failures shown

My cli_config.json looks like that :

{
  "sendResults": "always",
  "slackLogLevel": "error",
  "sendUsingWebhook": {
    "webhookUrl": "$SLACK_WEBHOOK_URL"
  },
  "meta": [
    { "key": "branch", "value" : "$CI_COMMIT_BRANCH"},
    { "key": "commit", "value" : "$CI_COMMIT_SHA"}
  ],
  "maxNumberOfFailuresToShow": 1,
  "disableUnfurl": true
}

ryanrosello-og added a commit that referenced this issue May 14, 2024
* chore: Update maxNumberOfFailuresToShow default value in SlackReporter
#125

* chore: Bump version to 1.1.73 in package.json
@samixchoumi
Copy link
Author

samixchoumi commented May 16, 2024

@ryanrosello-og Hello, I updated to the latest version : "playwright-slack-report": "^1.1.80",
I still have multiple errors appearing when setting "maxNumberOfFailuresToShow": 0,

See my cli_config.json file :

{
  "sendResults": "always",
  "slackLogLevel": "error",
  "sendUsingWebhook": {
    "webhookUrl": "$SLACK_WEBHOOK_URL"
  },
  "meta": [
    { "key": "Pipeline", "value" : "$CI_PIPELINE_URL"}
  ],
  "maxNumberOfFailuresToShow": 0,
  "disableUnfurl": true
}

Here is a resume of the slack report :

:performing_arts: Playwright Results
:white_check_mark: 24 | :x: 59 | :large_yellow_circle: 0 | :fast_forward: 0
Pipeline :    $CI_PIPELINE_URL

 72 |     // Set currency
> 74 |     await this.page.getByText(currency).click();
    |                                         ^
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
 - waiting for getByText('USD ($)')

:warning: There are too many failures to display - 5 out of 59 failures shown

@ryanrosello-og
Copy link
Owner

@samixchoumi it turns out your config is using the wrong key, use "maxNumberOfFailures": 0,
instead of "maxNumberOfFailuresToShow": 0,

When you provided maxNumberOfFailuresToShow, it was causing it to fallback to the default value (5) see ....

https://github.com/ryanrosello-og/playwright-slack-report/blob/main/src/cli/cli_schema.ts#L30

2024-05-16_20-25-59

@samixchoumi
Copy link
Author

Oh, I though I needed to use this parameter : https://github.com/ryanrosello-og/playwright-slack-report?tab=readme-ov-file#maxnumberoffailurestoshow
I update my config file to see if it's fixed then. Thanks

@samixchoumi
Copy link
Author

It works !
Thanks (maybe updating the documentation to avoid conflict between both parameter ?)

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

2 participants