cypress-plugins
cypress-plugins copied to clipboard
How to send custom message with stages and attach html report
@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:
@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
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 .
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 🤘🏽
@luisaangelicag @HernanMinted ☝🏾 :)
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
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
@luisaangelicag have you been able to fix this issue? may you share what was your path to make it work?
Just to clarify you cannot provide the --custom-url
property a relative path from your machine.
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>
Custom blocks coming soon, you'll be able to add as many of these as you want 👌🏾
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 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.
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
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?
@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