cypress-plugins icon indicating copy to clipboard operation
cypress-plugins copied to clipboard

How to send custom message with stages and attach html report

Open HernanMinted opened this issue 3 years ago • 12 comments

@YOU54F I have a question about, how I can create a custom message and if is possible add at what stage of my ci pipeline is running this and who triggered it (idk if with Gitlab this is possible). as for I have is "slack-report": "npx cypress-slack-reporter --report-dir './cypress/report/output.json' --custom-url './final-report/output.html' --ci-provider custom --vcs-provider none --verbose true ".

what I tried to do with custom-url is to get that .html as a clickable attachment in the message to get redirected to that but my slack message is the following:

image

HernanMinted avatar Jun 08 '21 20:06 HernanMinted

@YOU54F Encountering the same issue. The custom url merges to the screenshot directory for the Test Report attachment/button

npx cypress-slack-reporter --report-dir cypress/reports/mochareports --ci-provider custom --custom-url ~/cypress/reports/mochareports/report.html

image

luisaangelicag avatar Jul 22 '21 14:07 luisaangelicag

Custom url is the basepath for somewhere you are sorting artefacts if not on circleci iirc

On Thu, 22 Jul 2021 at 15:39, Luisa Gloria @.***> wrote:

@YOU54F https://github.com/YOU54F Encountering the same issue. The custom url merges to the screenshot directory for the Test Report attachment/button

npx cypress-slack-reporter --report-dir cypress/reports/mochareports --ci-provider custom --custom-url ~/cypress/reports/mochareports/report.html

[image: image] https://user-images.githubusercontent.com/63622377/126657739-3fb0b1d0-930c-4988-a925-e4beea79a0d4.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/YOU54F/cypress-slack-reporter/issues/1034#issuecomment-884966202, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYCJ4KCPOUK7WXUYO2YIM3TZAUSZANCNFSM46KVCKBQ .

YOU54F avatar Jul 22 '21 14:07 YOU54F

See here for info

https://github.com/YOU54F/cypress-slack-reporter/issues/497#issuecomment-630514390

It would probably be worth adding this into the readme. Would be happy to accept contributions if this works for you 🤘🏽

YOU54F avatar Jul 22 '21 18:07 YOU54F

@luisaangelicag @HernanMinted ☝🏾 :)

YOU54F avatar Jul 22 '21 18:07 YOU54F

Hi @YOU54F

checked the issue you linked above though it wasn't able to address my issue. i'm using the file location since i'm running the scripts locally too. will it be possible to use the root directory? from what i'm seeing, the custom-url appends to the screenshots directory

luisaangelicag avatar Jul 29 '21 07:07 luisaangelicag

FYI,

I am going to support sending custom blocks in the new rollout, details to come soon, but it will allow users to send any number of structured (and typed) objects to the message builder, so it should be infinitely customisable

YOU54F avatar Apr 27 '22 13:04 YOU54F

@luisaangelicag have you been able to fix this issue? may you share what was your path to make it work?

HernanMinted avatar Apr 27 '22 21:04 HernanMinted

Just to clarify you cannot provide the --custom-url property a relative path from your machine.

Screenshot 2022-04-29 at 01 46 59

If needs to be a valid web URL.

A link will need to appear like this in slack to render

<http://sometesturl.com/pnggrad16rgb.png|Screenshot:- pnggrad16rgb.png>

Screenshot 2022-04-29 at 01 48 18

Custom blocks coming soon, you'll be able to add as many of these as you want 👌🏾

Screenshot 2022-04-29 at 01 47 38

BTW where are you expecting to serve your URL's from? if you provide the uri root for where your report is, you should be fine, with the current version

YOU54F avatar Apr 29 '22 00:04 YOU54F

@YOU54F Ohh I see, so my custom-url is not doing anything haha 🤣 , although my main concern here is that in my case, I can only see a certain amount of only Test passed (if all passed it shows me 141 even tho there are 200+ test that passed) and if it fails then it throws me Test passed: 0, what I'm seeing at least for Luisa side is that she have been able to split how many test passed, failed and the total of tests that run, basically at first this is what I need right now, screenshots and video or html report would be a nice to have.

HernanMinted avatar Apr 29 '22 02:04 HernanMinted

I'd need to see your report json file to understand why the numbers are incorrect.

or take your json and pipe it into jq

cat cypress/reports/html/index.json | jq .stats
{
  "suites": 2,
  "tests": 20,
  "passes": 20,
  "pending": 0,
  "failures": 0,
  "start": "2022-04-28T22:38:51.534Z",
  "end": "2022-04-28T22:39:28.478Z",
  "duration": 24373,
  "testsRegistered": 20,
  "passPercent": 100,
  "pendingPercent": 0,
  "other": 0,
  "hasOther": false,
  "skipped": 0,
  "hasSkipped": false
}

They are extracted here

https://github.com/YOU54F/cypress-plugins/blob/c4b4a29d7a40fc9618b12f569184be64b43fb80f/src/slack/slack-alert.ts#L536-L550

and built into the message here

https://github.com/YOU54F/cypress-plugins/blob/c4b4a29d7a40fc9618b12f569184be64b43fb80f/src/slack/slack-alert.ts#L381-L444

Also --report-dir './cypress/report/output.json' this should be a directory, which is why the flag is called --report-dir, drop the /output.json

YOU54F avatar Apr 29 '22 13:04 YOU54F

Is there a way to add also the skipped test into the report? or are taken as Error for the webhook? the --custom-url for screenshots, since I'm using gitlab for CI/CD you can access the artifacts but then you have to download them to see them, in this case I would need to put them on a server in order to actually see the link correctly to it right?

HernanMinted avatar May 09 '22 20:05 HernanMinted

@YOU54F not sure if this needs a separate issue ticket, but I've encountered issues viewing the generated HTML report. It's just blank upon clicking the Test Report, but inspecting the page shows that the test report details are there

image

luisaangelicag avatar Jul 15 '22 02:07 luisaangelicag