YOU54F / cypress-plugins

A home for various Cypress Plugins
https://cypress-plugins.saf.dev/
MIT License
168 stars 46 forks source link

"Unknown error occurred whilst sending slack message" on gitlabCI #991

Closed mikeyhoang closed 6 months ago

mikeyhoang commented 3 years ago

I understand that gitlab isn't supported yet. But I'm purely using this to send a brief PASS/FAIL to my Slack channel. It seems to be working locally after running these steps.

e2e-tests:
  script:
    - npm ci
    - npm run e2e:ci 
    - npm run e2e:consolidate:report # consolidate test reports
    - npm run e2e:report:send # sends consolidated report to Slack

And I have a before-script to export the SLACK_WEBHOOK_URL

variables:
  SLACK_WEBHOOK: https://hooks.slack.com/services/XXXX

before_script:
  - export SLACK_WEBHOOK_URL=$SLACK_WEBHOOK

But for some reason I'm getting this error in my gitlab ci

> npx cypress-slack-reporter --report-dir mochareports/mochawesome.json --ci-provider none
{"level":30,"time":1618502686655,"pid":591,"hostname":"runner-x8zlwexr-project-25494770-concurrent-0","data":{"attachments":[{"color":"#36a64f","fallback":"Report available at mochareports/mochawesome.json/mochawesome.json","text":"Total Passed:  26","actions":[{"type":"button","text":"Test Report","url":"mochareports/mochawesome.json/mochawesome.json","style":"primary"},{"type":"button","text":"Build Logs","url":"undefined","style":"primary"}]},{"text":"","color":"#36a64f"}],"unfurl_links":false,"unfurl_media":false},"msg":"passing run"}
{"level":50,"time":1618502686660,"pid":591,"hostname":"runner-x8zlwexr-project-25494770-concurrent-0","e":{},"msg":"Unknown error occurred whilst sending slack message"}
(node:591) UnhandledPromiseRejectionWarning: Error: Error: An error occurred whilst sending slack message
    at Object.exports.slackRunner (/e2e-tests/node_modules/cypress-slack-reporter/bin/slack/slack-alert.js:162:15)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:591) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:591) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Have you come accross this issue by any chance?

YOU54F commented 3 years ago

Hey @mikeyhoang sorry for the late reply.

looks like it has some data being logged out here but its failing at sending the actual webhook to slack

https://github.com/YOU54F/cypress-slack-reporter/blob/35d0f201e96b0b7200d562077d0074a609daa11b/src/slack/slack-alert.ts#L181

You could try and use that data that has been logged out as send arguments and just trying to call the slack webhook from your local machine.

I do have a gitlab account, so if you can setup a example I would be happy to try it out when I get some time

YOU54F commented 6 months ago

Please raise as new issues, with reproducers if this is still affecting people